blob: 484ea3a2e0cf1bb7bb85c9dfa5c9dba0cbc05c1b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
package moe.nea.lisp
object Builtins {
val builtinSource = Builtins::class.java.getResourceAsStream("/builtins.lisp")!!.bufferedReader().readText()
val builtinProgram = LispParser.parse("builtins.lisp", builtinSource)
fun loadBuiltins(
lispExecutionContext: LispExecutionContext,
consumer: (String, LispData) -> Unit,
) {
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))
return@externalRawCall LispData.LispNil
})
lispExecutionContext.executeProgram(stackFrame, builtinProgram)
}
}
|