Refactoring: removing unnecessary overloaded methods.
h3rald h3rald@h3rald.com
Sun, 19 Feb 2017 14:33:35 +0100
2 files changed,
17 insertions(+),
20 deletions(-)
M
core/interpreter.nim
→
core/interpreter.nim
@@ -39,11 +39,6 @@ body
res = i.scope i.scope = origScope -template withScope*(i: In, q: MinValue, body: untyped): untyped = - var scope = newScopeRef(i.scope, "with") - i.withScope(q, scope): - body - proc newMinInterpreter*(filename = "input", pwd = ""): MinInterpreter = var stack:MinStack = newSeq[MinValue](0) var trace:MinStack = newSeq[MinValue](0)@@ -103,7 +98,9 @@ i.parser.close();
proc push*(i: In, val: MinValue) {.gcsafe.} -proc apply*(i: In, op: MinOperator, s: var ref MinScope, name="apply") = +#proc apply*(i: In, op: MinOperator, s: var ref MinScope, name="apply") = +proc apply*(i: In, op: MinOperator) = + var s = newScopeRef(i.scope, "apply") case op.kind of minProcOp: op.prc(i)@@ -116,9 +113,18 @@ i.push e
else: i.push(op.val) -proc apply*(i: In, op: MinOperator, name="apply") = - var scope = newScopeRef(i.scope, name) - i.apply(op, scope) +#proc apply*(i: In, op: MinOperator, name="apply") = +# var scope = newScopeRef(i.scope, name) +# i.apply(op, scope) + +proc unquote*(i: In, name: string, q: var MinValue, scope: var ref MinScope) = + i.withScope(q, scope): + for v in q.qVal: + i.push v + +proc unquote*(i: In, name: string, q: var MinValue) = + var scope = newScopeRef(i.scope, "unquote") + i.unquote(name, q, scope) proc push*(i: In, val: MinValue) = if val.kind == minSymbol:@@ -182,15 +188,6 @@ raise MinTrappedException(msg: msg)
if i.stack.len > 0: return i.stack[i.stack.len - 1] -proc unquote*(i: In, name: string, q: var MinValue, scope: var ref MinScope) = - i.withScope(q, scope): - for v in q.qVal: - i.push v - -proc unquote*(i: In, name: string, q: var MinValue) = - var scope = newScopeRef(i.scope, "unquote") - i.unquote(name, q, scope) - proc eval*(i: In, s: string, name="<eval>") = var i2 = i.copy(name) i2.open(newStringStream(s), name)@@ -209,4 +206,4 @@ i2.interpret()
i.trace = i2.trace i.stackcopy = i2.stackcopy i.stack = i2.stack - i.scope = i2.scope+ i.scope = i2.scope
M
lib/min_lang.nim
→
lib/min_lang.nim
@@ -257,7 +257,7 @@ i.reqTwoQuotations qscope, qprog
if qscope.qVal.len > 0: # System modules are empty quotes and don't need to be unquoted i.unquote("<with-scope>", qscope, qscope.scope) - i.withScope(qscope): + i.withScope(qscope, qscope.scope): for v in qprog.qVal: i.push v