diff options
author | Eduardo Julian | 2016-12-27 06:23:49 -0400 |
---|---|---|
committer | Eduardo Julian | 2016-12-27 06:23:49 -0400 |
commit | 4d2d4a1a1d9e40b2a628044382edb0f9cbfdbd9d (patch) | |
tree | 1dea6f2a90afda7ebd18d00be6e0669d16d11fae /luxc | |
parent | 1714be1b845c221008f694ad0d39eb33f7ddcb17 (diff) |
- Fixed a bug when encoding .0, where every zero was removed and only "." remained.
Diffstat (limited to '')
-rw-r--r-- | luxc/src/lux/compiler/host.clj | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/luxc/src/lux/compiler/host.clj b/luxc/src/lux/compiler/host.clj index eb2b0b889..c1ed8880d 100644 --- a/luxc/src/lux/compiler/host.clj +++ b/luxc/src/lux/compiler/host.clj @@ -687,18 +687,18 @@ (.visitInsn Opcodes/ARETURN) (.visitMaxs 0 0) (.visitEnd))) + ;; I commented-out some parts because a null-check was + ;; done to ensure variants were never created with null + ;; values (this would interfere later with + ;; pattern-matching). + ;; Since Lux itself doesn't have null values as part of + ;; the language, the burden of ensuring non-nulls was + ;; shifted to library code dealing with host-interop, to + ;; ensure variant-making was as fast as possible. + ;; The null-checking code was left as comments in case I + ;; ever change my mind. _ (let [;; $is-null (new Label) ] - ;; I commented out some parts because a null-check was - ;; done to ensure variants were never created with null - ;; values (this would interfere later with - ;; pattern-matching). - ;; Since Lux itself doesn't have null values as part of - ;; the language, the burden of ensuring non-nulls was - ;; shifted to library code dealing with host-interop, to - ;; ensure variant-making was as fast as possible. - ;; The null-checking code was left as comments in case I - ;; ever change my mind. (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "sum_make" "(ILjava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;" nil nil) (.visitCode) ;; (.visitVarInsn Opcodes/ALOAD 2) @@ -1027,9 +1027,19 @@ _ (let [$loop-start (new Label) $do-a-round (new Label) $not-set (new Label) - $next-iteration (new Label)] + $next-iteration (new Label) + $normal-path (new Label)] (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "encode_frac" "(J)Ljava/lang/String;" nil nil) (.visitCode) + ;; A quick corner-case to handle. + (.visitVarInsn Opcodes/LLOAD 0) + (.visitLdcInsn (long 0)) + (.visitInsn Opcodes/LCMP) + (.visitJumpInsn Opcodes/IFNE $normal-path) + (.visitLdcInsn ".0") + (.visitInsn Opcodes/ARETURN) + (.visitLabel $normal-path) + ;; Normal case (.visitLdcInsn (int (dec frac-bits))) (.visitVarInsn Opcodes/ISTORE 2) ;; Index (.visitLdcInsn (int frac-bits)) |