From 4d2d4a1a1d9e40b2a628044382edb0f9cbfdbd9d Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 27 Dec 2016 06:23:49 -0400 Subject: - Fixed a bug when encoding .0, where every zero was removed and only "." remained. --- luxc/src/lux/compiler/host.clj | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'luxc/src') 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)) -- cgit v1.2.3