diff options
author | Araq <rumpf_a@web.de> | 2011-09-26 00:24:06 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-09-26 00:24:06 +0200 |
commit | 14968fba46a0c1128f38859b339c7384f9f96cd4 (patch) | |
tree | 5fcd6a68f54c4df629ae0545f34e974b2a8f5907 /compiler | |
parent | 0f37d0e1f2aeee466b3c6179886963354eaa6222 (diff) | |
download | Nim-14968fba46a0c1128f38859b339c7384f9f96cd4.tar.gz |
bugfix: internal error in evalFieldAccess; parseutils.interpolatedFragments optimized; tstringinterp.nim now works
Diffstat (limited to 'compiler')
-rwxr-xr-x | compiler/evals.nim | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/compiler/evals.nim b/compiler/evals.nim index 65c64f4d3..a61d687ef 100755 --- a/compiler/evals.nim +++ b/compiler/evals.nim @@ -346,8 +346,13 @@ proc evalFieldAccess(c: PEvalContext, n: PNode, flags: TEvalFlags): PNode = var field = n.sons[1].sym for i in countup(0, sonsLen(x) - 1): var it = x.sons[i] - if it.kind != nkExprColonExpr: - InternalError(it.info, "evalFieldAccess") + if it.kind != nkExprColonExpr: + # lookup per index: + result = x.sons[field.position] + if result.kind == nkExprColonExpr: result = result.sons[1] + if not aliasNeeded(result, flags): result = copyTree(result) + return + #InternalError(it.info, "evalFieldAccess") if it.sons[0].sym.name.id == field.name.id: result = x.sons[i].sons[1] if not aliasNeeded(result, flags): result = copyTree(result) @@ -752,29 +757,28 @@ proc evalRepr(c: PEvalContext, n: PNode): PNode = proc isEmpty(n: PNode): bool = result = (n != nil) and (n.kind == nkEmpty) -# The lexer marks multi-line strings as residing at the line where they are closed -# This function returns the line where the string begins -# Maybe the lexer should mark both the beginning and the end of expressions, then -# this function could be removed +# The lexer marks multi-line strings as residing at the line where they +# are closed. This function returns the line where the string begins +# Maybe the lexer should mark both the beginning and the end of expressions, +# then this function could be removed. proc stringStartingLine(s: PNode): int = var totalLines = 0 for ln in splitLines(s.strVal): inc totalLines - result = s.info.line - totalLines proc evalParseExpr(c: PEvalContext, n: Pnode): Pnode = var code = evalAux(c, n.sons[1], {}) - var ast = parseString(code.getStrValue, code.info.toFilename, code.stringStartingLine) - + var ast = parseString(code.getStrValue, code.info.toFilename, + code.stringStartingLine) if sonsLen(ast) != 1: GlobalError(code.info, errExprExpected, "multiple statements") - result = ast.sons[0] result.typ = newType(tyExpr, c.module) proc evalParseStmt(c: PEvalContext, n: Pnode): Pnode = var code = evalAux(c, n.sons[1], {}) - result = parseString(code.getStrValue, code.info.toFilename, code.stringStartingLine) + result = parseString(code.getStrValue, code.info.toFilename, + code.stringStartingLine) result.typ = newType(tyStmt, c.module) proc evalMagicOrCall(c: PEvalContext, n: PNode): PNode = @@ -1086,7 +1090,7 @@ proc evalAux(c: PEvalContext, n: PNode, flags: TEvalFlags): PNode = var a = copyTree(n) for i in countup(0, sonsLen(n) - 1): var it = n.sons[i] - if it.kind == nkExprEqExpr: + if it.kind == nkExprColonExpr: result = evalAux(c, it.sons[1], flags) if isSpecial(result): return a.sons[i].sons[1] = result |