add macros to KissInterp2
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
(prop &mut :ReadTable endOfFileReadTable (new Map))
|
||||
(prop &mut :Map<String,ReaderExpDef> identAliases (new Map))
|
||||
(prop &mut :Map<String,ReaderExpDef> callAliases (new Map))
|
||||
(prop &mut :Map<String,kiss.PortableMacros.PortableMacroFunction> macros (kiss.PortableMacros.builtins))
|
||||
|
||||
(prop :Map<String,Dynamic> globals [
|
||||
=>"false" false
|
||||
@@ -256,6 +257,9 @@
|
||||
// Special form call
|
||||
((when (specialForms.exists form) (CallExp (object def (Symbol form)) args))
|
||||
((dictGet specialForms form) args cc))
|
||||
// Macro call
|
||||
((when (macros.exists form) (CallExp (object def (Symbol form)) args))
|
||||
(evalCC ((dictGet macros form) (makeExp def) args) cc))
|
||||
// Method/function call with call alias
|
||||
((when (callAliases.exists name) (CallExp (object def (Symbol name)) args))
|
||||
(evalCC (dictGet callAliases name) ->f
|
||||
|
||||
@@ -46,5 +46,8 @@ class KissInterp2TestCase extends Test {
|
||||
function testFor() {
|
||||
_testFor();
|
||||
}
|
||||
function testDestructive() {
|
||||
_testDestructive();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -58,4 +58,8 @@
|
||||
|
||||
(function _testFor []
|
||||
(let [interp (new Interp)]
|
||||
(assertEval [1 2 3] "(for i (range 3) (+ i 1))")))
|
||||
(assertEval [1 2 3] "(for i (range 3) (+ i 1))")))
|
||||
|
||||
(function _testDestructive []
|
||||
(let [interp (new Interp)]
|
||||
(assertEval 5 "(let [i 2] (+= i 3) i)")))
|
||||
|
||||
Reference in New Issue
Block a user