diff options
author | Eduardo Julian | 2016-10-15 20:19:46 -0400 |
---|---|---|
committer | Eduardo Julian | 2016-10-15 20:19:46 -0400 |
commit | 2cfcc1a5780d6fcfdf90bfb1ff6098489e677e1d (patch) | |
tree | f07edb31df7f1fffae9e22fee66d7adfbf967ec3 /src | |
parent | b009b396ed92618974385575df7bbde87a4e2e96 (diff) |
- Shifted the burden of not having null values inside variants from the language to library code.
Diffstat (limited to 'src')
-rw-r--r-- | src/lux/compiler/host.clj | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/lux/compiler/host.clj b/src/lux/compiler/host.clj index 3b2a53929..6c1646933 100644 --- a/src/lux/compiler/host.clj +++ b/src/lux/compiler/host.clj @@ -687,11 +687,22 @@ (.visitInsn Opcodes/ARETURN) (.visitMaxs 0 0) (.visitEnd))) - _ (let [$is-null (new Label)] + _ (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) - (.visitJumpInsn Opcodes/IFNULL $is-null) + ;; (.visitVarInsn Opcodes/ALOAD 2) + ;; (.visitJumpInsn Opcodes/IFNULL $is-null) (.visitLdcInsn (int 3)) (.visitTypeInsn Opcodes/ANEWARRAY "java/lang/Object") (.visitInsn Opcodes/DUP) @@ -708,12 +719,12 @@ (.visitVarInsn Opcodes/ALOAD 2) (.visitInsn Opcodes/AASTORE) (.visitInsn Opcodes/ARETURN) - (.visitLabel $is-null) - (.visitTypeInsn Opcodes/NEW "java/lang/IllegalStateException") - (.visitInsn Opcodes/DUP) - (.visitLdcInsn "Can't create variant for null pointer") - (.visitMethodInsn Opcodes/INVOKESPECIAL "java/lang/IllegalStateException" "<init>" "(Ljava/lang/String;)V") - (.visitInsn Opcodes/ATHROW) + ;; (.visitLabel $is-null) + ;; (.visitTypeInsn Opcodes/NEW "java/lang/IllegalStateException") + ;; (.visitInsn Opcodes/DUP) + ;; (.visitLdcInsn "Can't create variant for null pointer") + ;; (.visitMethodInsn Opcodes/INVOKESPECIAL "java/lang/IllegalStateException" "<init>" "(Ljava/lang/String;)V") + ;; (.visitInsn Opcodes/ATHROW) (.visitMaxs 0 0) (.visitEnd)))] nil)) |