summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-08-21 19:41:29 +0200
committernea <nea@nea.moe>2023-08-21 19:41:29 +0200
commit39f1849edcaa9005814525cd13f76a5daaa15ae0 (patch)
tree4d3a34f96f53443a92823079563a2c9bbdeba7e7 /src
parentad9429d1cae70baf9b561090bb33ab2941d2a3a5 (diff)
downloadnealisp-39f1849edcaa9005814525cd13f76a5daaa15ae0.tar.gz
nealisp-39f1849edcaa9005814525cd13f76a5daaa15ae0.tar.bz2
nealisp-39f1849edcaa9005814525cd13f76a5daaa15ae0.zip
Foreign objects
Diffstat (limited to 'src')
-rw-r--r--src/CoreBindings.kt2
-rw-r--r--src/LispData.kt2
-rw-r--r--src/LispExecutionContext.kt1
3 files changed, 3 insertions, 2 deletions
diff --git a/src/CoreBindings.kt b/src/CoreBindings.kt
index b90072e..2208b8c 100644
--- a/src/CoreBindings.kt
+++ b/src/CoreBindings.kt
@@ -118,6 +118,7 @@ object CoreBindings {
is LispData.LispString -> thing.string
is LispData.LispHash -> thing.map.asIterable().joinToString(", ", "{", "}") { it.key + ": " + it.value }
is LispData.LispNumber -> thing.value.toString()
+ is LispData.ForeignObject<*> -> "<foreign ${thing.obj}>"
is LispData.LispInterpretedCallable -> "<function ${thing.name ?: "<anonymous>"} ${thing.argNames} ${thing.body.toSource()}>"
}
}
@@ -225,6 +226,7 @@ object CoreBindings {
LispData.LispNil -> LispData.Atom("nil")
is LispData.LispHash -> LispData.Atom("hash")
is LispData.LispNode -> LispData.Atom("ast")
+ is LispData.ForeignObject<*> -> LispData.Atom("foreign")
is LispData.LispNumber -> LispData.Atom("number")
is LispData.LispString -> LispData.Atom("string")
}
diff --git a/src/LispData.kt b/src/LispData.kt
index ea3af32..61c2b76 100644
--- a/src/LispData.kt
+++ b/src/LispData.kt
@@ -8,6 +8,7 @@ sealed class LispData {
data class LispNumber(val value: Double) : LispData()
data class LispNode(val node: LispAst.LispNode) : LispData()
data class LispHash(val map: Map<String, LispData>) : LispData()
+ data class ForeignObject<T : Any?>(val obj: T) : LispData()
class LispList(val elements: List<LispData>) : LispData()
sealed class LispExecutable() : LispData() {
abstract fun execute(
@@ -56,7 +57,6 @@ sealed class LispData {
}
}
-
companion object {
fun externalRawCall(
name: String,
diff --git a/src/LispExecutionContext.kt b/src/LispExecutionContext.kt
index 306e111..0a1dc41 100644
--- a/src/LispExecutionContext.kt
+++ b/src/LispExecutionContext.kt
@@ -36,7 +36,6 @@ class LispExecutionContext() {
return testSuite
}
-
fun registerModule(moduleName: String, program: LispAst.Program) {
if (moduleName in unloadedModules || moduleName in modules) {
error("Cannot register already registered module $moduleName")