diff options
author | Araq <rumpf_a@web.de> | 2014-11-19 23:38:35 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-11-19 23:38:35 +0100 |
commit | 32ec5af60a5d89fca314c3b432d225f1e248953f (patch) | |
tree | 327f2bc0226a96a6de60a6732821245d93e501da /compiler | |
parent | 08a954f7eeb1d0d2d703f07ce30ad597dbabd17d (diff) | |
download | Nim-32ec5af60a5d89fca314c3b432d225f1e248953f.tar.gz |
fixes #1053, fixes #924
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/ccgexprs.nim | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index bced6d50f..0bf2359c5 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -20,7 +20,7 @@ proc int64Literal(i: BiggestInt): PRope = proc uint64Literal(i: uint64): PRope = toRope($i & "ULL") proc intLiteral(i: BiggestInt): PRope = - if (i > low(int32)) and (i <= high(int32)): + if i > low(int32) and i <= high(int32): result = toRope(i) elif i == low(int32): # Nim has the same bug for the same reasons :-) @@ -39,7 +39,7 @@ proc int32Literal(i: int): PRope = proc genHexLiteral(v: PNode): PRope = # hex literals are unsigned in C # so we don't generate hex literals any longer. - if not (v.kind in {nkIntLit..nkUInt64Lit}): + if v.kind notin {nkIntLit..nkUInt64Lit}: internalError(v.info, "genHexLiteral") result = intLiteral(v.intVal) @@ -224,9 +224,9 @@ proc optAsgnLoc(a: TLoc, t: PType, field: PRope): TLoc = proc genOptAsgnTuple(p: BProc, dest, src: TLoc, flags: TAssignmentFlags) = let newflags = if src.k == locData: - flags + { needToCopy } + flags + {needToCopy} elif tfShallow in dest.t.flags: - flags - { needToCopy } + flags - {needToCopy} else: flags for i in 0 .. <dest.t.len: @@ -240,9 +240,9 @@ proc genOptAsgnObject(p: BProc, dest, src: TLoc, flags: TAssignmentFlags, if t == nil: return let newflags = if src.k == locData: - flags + { needToCopy } + flags + {needToCopy} elif tfShallow in dest.t.flags: - flags - { needToCopy } + flags - {needToCopy} else: flags case t.kind @@ -328,7 +328,9 @@ proc genAssignment(p: BProc, dest, src: TLoc, flags: TAssignmentFlags) = linefmt(p, cpsStmts, "$1 = $2;$n", rdLoc(dest), rdLoc(src)) of tyObject: # XXX: check for subtyping? - if needsComplexAssignment(ty): + if not isObjLackingTypeField(ty): + genGenericAsgn(p, dest, src, flags) + elif needsComplexAssignment(ty): if ty.sons[0].isNil and asgnComplexity(ty.n) <= 4: discard getTypeDesc(p.module, ty) internalAssert ty.n != nil |