From b69495d6d3098ea39af5467063904b023a08adc0 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 20 Dec 2016 19:50:12 -0400 Subject: - Fixed a bug in Frac encoding, where the prefix dot was not being added for non-zero numbers. --- luxc/src/lux/compiler/host.clj | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'luxc/src') diff --git a/luxc/src/lux/compiler/host.clj b/luxc/src/lux/compiler/host.clj index 3d4172110..26fbda4db 100644 --- a/luxc/src/lux/compiler/host.clj +++ b/luxc/src/lux/compiler/host.clj @@ -939,15 +939,16 @@ (.visitInsn Opcodes/ARETURN) (.visitMaxs 0 0) (.visitEnd))) - _ (let [$is-zero (new Label) - $end (new Label)] + _ (let [$is-zero (new Label)] (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "encode_frac" "(J)Ljava/lang/String;" nil nil) (.visitCode) (.visitVarInsn Opcodes/LLOAD 0) (.visitLdcInsn (long 0)) (.visitInsn Opcodes/LCMP) (.visitJumpInsn Opcodes/IFEQ $is-zero) - ;; IF =/= 0 + ;; IF != 0 + ;; Add prefix dot for later usage. + (.visitLdcInsn ".") ;; Generate leading 0s (.visitLdcInsn (long 1)) (.visitVarInsn Opcodes/LLOAD 0) @@ -964,12 +965,13 @@ (.visitInsn Opcodes/AALOAD) ;; Join leading 0s with number text (.visitMethodInsn Opcodes/INVOKEVIRTUAL "java/lang/String" "concat" "(Ljava/lang/String;)Ljava/lang/String;") + ;; Join with prefix dot + (.visitMethodInsn Opcodes/INVOKEVIRTUAL "java/lang/String" "concat" "(Ljava/lang/String;)Ljava/lang/String;") ;; FINISH - (.visitJumpInsn Opcodes/GOTO $end) + (.visitInsn Opcodes/ARETURN) ;; IF == 0 (.visitLabel $is-zero) (.visitLdcInsn ".0") - (.visitLabel $end) (.visitInsn Opcodes/ARETURN) (.visitMaxs 0 0) (.visitEnd))) -- cgit v1.2.3