diff options
author | Araq <rumpf_a@web.de> | 2011-06-05 13:59:41 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-06-05 13:59:41 +0200 |
commit | 958961bd8d0bc699c6301984a706c5d182079c71 (patch) | |
tree | aafcf4fdf3d479f334146094f6240dac7e288dc8 /compiler | |
parent | e5eb36e4722dd333dd48cfcf5c54fb6549fe4a46 (diff) | |
download | Nim-958961bd8d0bc699c6301984a706c5d182079c71.tar.gz |
overloading of [] for derefence operation should be possible now
Diffstat (limited to 'compiler')
-rwxr-xr-x | compiler/ccgexprs.nim | 4 | ||||
-rwxr-xr-x | compiler/semexprs.nim | 8 |
2 files changed, 7 insertions, 5 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 3f3a60b7a..2cb99d3a9 100755 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -772,8 +772,8 @@ proc genEcho(p: BProc, n: PNode) = for i in countup(1, n.len-1): initLocExpr(p, n.sons[i], a) appf(args, ", ($1)->data", [rdLoc(a)]) - appcg(p, cpsStmts, "printf(\"" & repeatStr(n.len-1, "%s") & - "\\n\"$1);$n", [args]) + appcg(p, cpsStmts, "printf($1$2);$n", [ + makeCString(repeatStr(n.len-1, "%s") & tnl), args]) proc genCall(p: BProc, t: PNode, d: var TLoc) = var op, a: TLoc diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 38db93988..17c4b7427 100755 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -726,13 +726,15 @@ proc semDeref(c: PContext, n: PNode): PNode = var t = skipTypes(n.sons[0].typ, {tyGenericInst, tyVar}) case t.kind of tyRef, tyPtr: n.typ = t.sons[0] - else: GlobalError(n.sons[0].info, errCircumNeedsPointer) - result = n + else: result = nil + #GlobalError(n.sons[0].info, errCircumNeedsPointer) proc semSubscript(c: PContext, n: PNode, flags: TExprFlags): PNode = - ## returns nil if not a built-in subscript operator; + ## returns nil if not a built-in subscript operator; also called for the + ## checking of assignments if sonsLen(n) == 1: var x = semDeref(c, n) + if x == nil: return nil result = newNodeIT(nkDerefExpr, x.info, x.typ) result.add(x[0]) return |