|
|
|
|
@@ -34,6 +34,10 @@
|
|
|
|
|
(let [name (symbolNameValue (first args))]
|
|
|
|
|
(evalCC (second args) ->val {(dictSet scope name val) (cc val)})))
|
|
|
|
|
|
|
|
|
|
(function callSymbol [:String symbolName :Array<ReaderExp> args]
|
|
|
|
|
(ReaderExpDef.CallExp
|
|
|
|
|
(object pos null def (ReaderExpDef.Symbol symbolName)) args))
|
|
|
|
|
|
|
|
|
|
(method makeFunction [:Array<ReaderExp> argExps :Array<ReaderExp> bodyExps]
|
|
|
|
|
(let [capture (localScopes.copy)
|
|
|
|
|
argNames []
|
|
|
|
|
@@ -65,7 +69,7 @@
|
|
|
|
|
(if hasOpt
|
|
|
|
|
null
|
|
|
|
|
(throw "not enough arguments! need $argName")))))
|
|
|
|
|
(evalCC (ReaderExpDef.CallExp (object pos null def (ReaderExpDef.Symbol "begin")) bodyExps)
|
|
|
|
|
(evalCC (callSymbol "begin" bodyExps)
|
|
|
|
|
->v
|
|
|
|
|
{
|
|
|
|
|
(set localScopes currentLocals)
|
|
|
|
|
@@ -110,7 +114,7 @@
|
|
|
|
|
(dictSet scope vName val)
|
|
|
|
|
(nextVar)
|
|
|
|
|
}))
|
|
|
|
|
(evalCC (ReaderExpDef.CallExp (makeExp (Symbol "begin")) body) ->result {
|
|
|
|
|
(evalCC (callSymbol "begin" body) ->result {
|
|
|
|
|
(localScopes.pop)
|
|
|
|
|
(cc result)
|
|
|
|
|
})))
|
|
|
|
|
@@ -151,6 +155,22 @@
|
|
|
|
|
func (makeFunction argExps bodyExps)]
|
|
|
|
|
(dictSet globals name func)
|
|
|
|
|
(cc func))
|
|
|
|
|
/*
|
|
|
|
|
=>"for"
|
|
|
|
|
(forLoop true)
|
|
|
|
|
=>"doFor"
|
|
|
|
|
(forLoop false)
|
|
|
|
|
*/
|
|
|
|
|
=>"while"
|
|
|
|
|
->[args cc]
|
|
|
|
|
(let [condition (first args) body (rest args)]
|
|
|
|
|
(localFunction run []
|
|
|
|
|
(evalCC condition
|
|
|
|
|
->v
|
|
|
|
|
(if v
|
|
|
|
|
(evalCC (callSymbol "begin" body) ->_ (run))
|
|
|
|
|
(cc null))))
|
|
|
|
|
(run))
|
|
|
|
|
=>"set"
|
|
|
|
|
->[args cc]
|
|
|
|
|
(evalCC (second args)
|
|
|
|
|
@@ -272,7 +292,7 @@
|
|
|
|
|
(cc f)
|
|
|
|
|
(return)))
|
|
|
|
|
// Check for field access
|
|
|
|
|
(whenLet [exp (transformToFieldExp exp)]
|
|
|
|
|
(whenLet [exp (transformToFieldExp exp true)]
|
|
|
|
|
(evalCC exp cc)
|
|
|
|
|
(return))
|
|
|
|
|
// Check for ident aliases
|
|
|
|
|
@@ -301,11 +321,12 @@
|
|
|
|
|
(cc outputs)))
|
|
|
|
|
|
|
|
|
|
// Check if an identifier has field access in it, return true if transform it to FieldExp
|
|
|
|
|
(method transformToFieldExp [:ReaderExp exp]
|
|
|
|
|
(method transformToFieldExp [:ReaderExp exp &opt :Bool nullIfNot]
|
|
|
|
|
(case exp.def
|
|
|
|
|
((Symbol ident)
|
|
|
|
|
(let [idx (ident.indexOf ".")]
|
|
|
|
|
(unless (= -1 idx)
|
|
|
|
|
(if (= -1 idx)
|
|
|
|
|
(return (if nullIfNot null exp))
|
|
|
|
|
(let [parts (ident.split ".")
|
|
|
|
|
&mut newExp (makeExp (Symbol (first parts)))]
|
|
|
|
|
(doFor part (parts.slice 1)
|
|
|
|
|
@@ -313,4 +334,4 @@
|
|
|
|
|
(when safe (set part (part.substr 1)))
|
|
|
|
|
(set newExp (makeExp (FieldExp part newExp safe)))))
|
|
|
|
|
(return newExp)))))
|
|
|
|
|
(otherwise (return null))))
|
|
|
|
|
(otherwise (return (if nullIfNot null exp)))))
|