refactor(tidying up) Removed unused code.
h3rald h3rald@h3rald.com
Fri, 03 Jun 2016 10:53:06 +0200
2 files changed,
0 insertions(+),
66 deletions(-)
M
core/interpreter.nim
→
core/interpreter.nim
@@ -27,14 +27,12 @@ if not scope.parent.isNil:
result = scope.parent.fullname & ":" & result proc getSymbol*(scope: ref MinScope, key: string): MinOperator = - #echo key, " - ", scope.symbols.hasKey(key) if scope.symbols.hasKey(key): return scope.symbols[key] elif not scope.parent.isNil: return scope.parent.getSymbol(key) proc delSymbol*(scope: ref MinScope, key: string): bool {.discardable.}= - #echo key, " - ", scope.symbols.hasKey(key) if scope.symbols.hasKey(key): scope.symbols.excl(key) return true@@ -45,7 +43,6 @@ result = false
# check if a symbol already exists in current scope if not scope.isNil and scope.symbols.hasKey(key): scope.symbols[key] = value - #echo "($1) SET EXISTING SYMBOL: $2" % [scope.fullname, key] result = true else: # Go up the scope chain and attempt to find the symbol@@ -129,27 +126,19 @@ let symbol = val.symVal
let sigil = "" & symbol[0] let symbolProc = i.scope.getSymbol(symbol) if not symbolProc.isNil: - #let filename = i.filename try: - #i.newDisposableScope("<" & symbol & ">"): - #i.debug "SCOPE: " & i.scope.fullname symbolProc(i) except: i.error(errSystem, getCurrentExceptionMsg()) - #finally: - # i.filename = filename # filename may change when evaluating quotations else: let sigilProc = i.scope.getSigil(sigil) if symbol.len > 1 and not sigilProc.isNil: let sym = symbol[1..symbol.len-1] - #let filename = i.filename try: i.stack.add(MinValue(kind: minString, strVal: sym)) sigilProc(i) except: i.error(errSystem, getCurrentExceptionMsg()) - #finally: - # i.filename = filename # Filename may change when evaluating quotations else: i.error(errUndefined, "Undefined symbol: '"&val.symVal&"'") return
M
lib/lang.nim
→
lib/lang.nim
@@ -52,10 +52,7 @@ i.error errIncorrect, "The top quotation must contain only one symbol value"
return i.debug "[define] " & symbol & " = " & $q1 i.scope.symbols[symbol] = proc(i: var MinInterpreter) = - #i.evaluating = true - #i.filename = q1.filename # filename will be reset automatically by interpreter i.push q1.qVal - #i.evaluating = false .symbol("bind") do (i: In): var q2 = i.pop # new (can be a quoted symbol or a string)@@ -71,17 +68,8 @@ else:
i.error errIncorrect, "The top quotation must contain only one symbol value" return i.debug "[bind] " & symbol & " = " & $q1 - #if not i.filename.isNil and i.filename != "eval": - # echo "BIND $1 - fn: $2" % [symbol, i.filename] - # q1.filename = i.filename # Save filename for diagnostic purposes let res = i.scope.setSymbol(symbol) do (i: In): - #i.evaluating = true - #if not q1.filename.isNil: - # i.filename = q1.filename - #echo "BIND '$1' FN: $2" % [symbol, i.filename] i.push q1.qVal - #i.filename = fn - #i.evaluating = false if not res: i.error errRuntime, "Attempting to bind undefined symbol: " & symbol@@ -190,49 +178,6 @@ i.error(errIncorrect, "Unable to evaluate symbol '$1'" % [symbol])
return i.scope = q.scope i.scope = origScope - - - - -# .symbol("call") do (i: In): -# let fqn = i.pop -# if fqn.isQuotation: -# let vals = fqn.qVal -# var q: MinValue -# if vals.len == 0: -# i.error(errIncorrect, "No symbol to call") -# return -# var symScope = i.scope -# var symFilename = i.filename -# for c in 0..vals.len-1: -# if not vals[c].isStringLike: -# i.error(errIncorrect, "Quotation must contain only symbols or strings") -# return -# let qProc = i.scope.getSymbol(vals[c].getString) -# if qProc.isNil: -# i.error(errUndefined, "Symbol '$1' not found in scope '$2'" % [vals[c].getString, i.scope.fullname]) -# return -# let currScope = i.scope -# let currFilename = i.filename -# # Execute operator in "parent" symbol scope -# #echo "CALL - executing '$1' fn: $2" % [vals[c].getString, "-"] -# i.scope = symScope -# #i.filename = symFilename -# #echo ">>> CALL: ", vals[c].getString, " - ", symFilename -# qProc(i) -# i.scope = currScope -# #echo "<<< CALL: ", currFilename -# #i.filename = currFilename -# if vals.len > 1 and c < vals.len-1: -# q = i.pop -# if not q.isQuotation: -# i.error(errIncorrect, "Unable to evaluate symbol '$1'" % [vals[c-1].getString]) -# return -# symScope = q.scope -# symFilename = q.filename -# else: -# i.error(errIncorrect, "A quotation is required on the stack") - # Operations on the whole stack