diff options
author | nea <nea@nea.moe> | 2023-08-10 02:05:19 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-08-10 02:05:19 +0200 |
commit | e4661bf1fecf5a214a020a56b9658dc49565e162 (patch) | |
tree | 524d4a5b3774e31c88dbdfa8259f2522457f1696 | |
parent | 74371302593ee2ee365e697911c364246f460b63 (diff) | |
download | nealisp-e4661bf1fecf5a214a020a56b9658dc49565e162.tar.gz nealisp-e4661bf1fecf5a214a020a56b9658dc49565e162.tar.bz2 nealisp-e4661bf1fecf5a214a020a56b9658dc49565e162.zip |
Add more true/false builtins
-rw-r--r-- | res/builtins.lisp | 5 | ||||
-rw-r--r-- | src/Builtins.kt | 5 | ||||
-rw-r--r-- | src/CoreBindings.kt | 5 |
3 files changed, 9 insertions, 6 deletions
diff --git a/res/builtins.lisp b/res/builtins.lisp index 7bab9b4..4348e52 100644 --- a/res/builtins.lisp +++ b/res/builtins.lisp @@ -14,3 +14,8 @@ (defun noop () (return nil)) (export noop) +(comment "boolean atoms") +(def true :true) +(def false :false) +(export true false) + diff --git a/src/Builtins.kt b/src/Builtins.kt index 484ea3a..6ca60e9 100644 --- a/src/Builtins.kt +++ b/src/Builtins.kt @@ -9,8 +9,9 @@ object Builtins { ) { val stackFrame = lispExecutionContext.genBindings() stackFrame.setValueLocal("export", LispData.externalRawCall { context, callsite, stackFrame, args -> - val (name) = args - consumer((name as LispAst.Reference).label, context.resolveValue(stackFrame, name)) + args.forEach { name -> + consumer((name as LispAst.Reference).label, context.resolveValue(stackFrame, name)) + } return@externalRawCall LispData.LispNil }) lispExecutionContext.executeProgram(stackFrame, builtinProgram) diff --git a/src/CoreBindings.kt b/src/CoreBindings.kt index cf4fc50..f139e2e 100644 --- a/src/CoreBindings.kt +++ b/src/CoreBindings.kt @@ -1,7 +1,6 @@ package moe.nea.lisp object CoreBindings { - val nil = LispData.LispNil val def = LispData.externalRawCall { context, callsite, stackFrame, args -> if (args.size != 2) { return@externalRawCall context.reportError("Function define expects exactly two arguments", callsite) @@ -182,10 +181,8 @@ object CoreBindings { } fun offerAllTo(bindings: StackFrame) { - bindings.setValueLocal("true", trueValue) - bindings.setValueLocal("false", falseValue) bindings.setValueLocal("if", ifFun) - bindings.setValueLocal("nil", nil) + bindings.setValueLocal("nil", LispData.LispNil) bindings.setValueLocal("def", def) bindings.setValueLocal("pure", pure) bindings.setValueLocal("lambda", lambda) |