Making sure dictionaries are processed properly; modules are now dictionaries.
h3rald h3rald@h3rald.com
Sat, 02 Jun 2018 12:05:18 +0200
5 files changed,
24 insertions(+),
17 deletions(-)
M
core/interpreter.nim
→
core/interpreter.nim
@@ -196,10 +196,10 @@ else:
raiseUndefined("Undefined symbol '$1'" % [val.symVal]) discard i.trace.pop else: - var v = val - if (v.kind == minDictionary): - i.dequote(v) - i.stack.add(v) + #var v = val + #if (v.kind == minDictionary): + # i.dequote(v) + i.stack.add(val) proc pop*(i: In): MinValue {.extern:"min_exported_symbol_$1".}= if i.stack.len > 0:
M
core/parser.nim
→
core/parser.nim
@@ -598,9 +598,13 @@ return q
of minDictionary: var d = "{" for i in a.dVal.pairs: - var v = $i.val.val - if (not i.val.quotation): - v = v[1 .. v.len-2] + var v = "" + if i.val.kind == minProcOp: + v = "<compiled>" + else: + v = $i.val.val + if (not i.val.quotation): + v = v[1 .. v.len-2] d = d & v & " :" & $i.key & " " if not a.objType.isNil: d = d & ";" & a.objType
M
core/utils.nim
→
core/utils.nim
@@ -36,7 +36,7 @@ proc sigil*(scope: ref MinScope, sym: string, v: MinValue) {.extern:"min_exported_symbol_$1_2".}=
scope.sigils[sym] = MinOperator(val: v, kind: minValOp, sealed: true) proc finalize*(scope: ref MinScope, name: string = "") {.extern:"min_exported_symbol_$1".}= - var mdl = newSeq[MinValue](0).newVal(nil) + var mdl = newDict(scope) mdl.scope = scope let op = proc(i: In) {.closure.} = i.evaluating = true
M
lib/min_lang.nim
→
lib/min_lang.nim
@@ -131,11 +131,10 @@ if not res:
raiseUndefined("Attempting to delete undefined symbol: " & sym.getString) def.symbol("module") do (i: In): - let vals = i.expect("'sym", "quot") + let vals = i.expect("'sym", "dict") let name = vals[0] var code = vals[1] code.filename = i.filename - i.dequote(code) info("[module] $1 ($2 symbols)" % [name.getString, $code.scope.symbols.len]) i.scope.symbols[name.getString] = MinOperator(kind: minValOp, val: @[code].newVal(i.scope), quotation: true)@@ -146,7 +145,7 @@ var name: string
name = rawName.getString var op = i.scope.getSymbol(name) i.apply(op) - vals = i.expect("quot") + vals = i.expect("dict") let mdl = vals[0] info("[import] Importing: $1 ($2 symbols, $3 sigils)" % [name, $mdl.scope.symbols.len, $mdl.scope.sigils.len]) for sym, val in mdl.scope.symbols.pairs:@@ -194,12 +193,12 @@ raiseInvalid("File '$1' does not exist." % file)
i.push i.read file def.symbol("with") do (i: In): - let vals = i.expect("quot", "quot") + let vals = i.expect("dict", "quot") var qscope = vals[0] let qprog = vals[1] - if qscope.qVal.len > 0: + #if qscope.qVal.len > 0: # System modules are empty quotes and don't need to be dequoted - i.dequote(qscope) + # i.dequote(qscope) i.withScope(qscope): for v in qprog.qVal: i.push v
M
min.nim
→
min.nim
@@ -223,9 +223,13 @@ echo " ".repeat(n.len) & " )"
elif res.isDictionary and res.dVal.len > 1: echo "{$1} -> {" % n for item in res.dVal.pairs: - var v = $item.val.val - if (not item.val.quotation): - v = v[1 .. v.len-2] + var v = "" + if item.val.kind == minProcOp: + v = "<compiled>" + else: + v = $item.val.val + if (not item.val.quotation): + v = v[1 .. v.len-2] echo " " & v & " :" & $item.key if res.objType.isNil: echo " ".repeat(n.len) & " }"