made some tests green; htmlgen still broken

This commit is contained in:
Araq
2014-02-25 08:41:29 +01:00
parent 3a2e1ce538
commit b7bb56bdca
4 changed files with 16 additions and 10 deletions

View File

@@ -109,14 +109,18 @@ template decodeBx(k: expr) {.immediate, dirty.} =
template move(a, b: expr) {.immediate, dirty.} = system.shallowCopy(a, b)
# XXX fix minor 'shallowCopy' overloading bug in compiler
template createStrKeepNode(x) =
proc createStrKeepNode(x: var TRegister) =
if x.node.isNil:
x.node = newNode(nkStrLit)
elif x.node.kind == nkNilLit:
system.reset(x.node[])
x.node.kind = nkStrLit
else:
assert x.node.kind in {nkStrLit..nkTripleStrLit}
# XXX this is hacky; tests/txmlgen triggers it:
x.node = newNode(nkStrLit)
#if x.node.kind notin {nkStrLit..nkTripleStrLit}:
# debug x.node
#assert x.node.kind in {nkStrLit..nkTripleStrLit}
template createStr(x) =
x.node = newNode(nkStrLit)

View File

@@ -924,7 +924,7 @@ proc genAddrDeref(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode;
flags: TGenFlags) =
# a nop for certain types
let isAddr = opc in {opcAddrNode, opcAddrReg}
let flags = if isAddr: flags+{gfAddrOf} else: flags
let newflags = if isAddr: flags+{gfAddrOf} else: flags
# consider:
# proc foo(f: var ref int) =
# f = new(int)
@@ -935,12 +935,14 @@ proc genAddrDeref(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode;
# The type of 'f' is 'var ref int' and of 'x' is 'ref int'. Hence for
# nkAddr we must not use 'unneededIndirection', but for deref we use it.
if not isAddr and unneededIndirection(n.sons[0]):
gen(c, n.sons[0], dest, flags)
gen(c, n.sons[0], dest, newflags)
else:
let tmp = c.genx(n.sons[0], flags)
let tmp = c.genx(n.sons[0], newflags)
if dest < 0: dest = c.getTemp(n.typ)
if not isAddr:
gABC(c, n, opc, dest, tmp)
if gfAddrOf notin flags and fitsRegister(n.typ):
c.gABC(n, opcNodeToReg, dest, dest)
elif c.prc.slots[tmp].kind >= slotTempUnknown:
gABC(c, n, opcAddrReg, dest, tmp)
else:
@@ -1541,8 +1543,8 @@ proc genProc(c: PCtx; s: PSym): int =
c.optimizeJumps(result)
s.offset = c.prc.maxSlots
#if s.name.s == "importImpl_forward" or s.name.s == "importImpl":
# c.echoCode(result)
# echo renderTree(body)
#c.echoCode(result)
#echo renderTree(body)
c.prc = oldPrc
else:
c.prc.maxSlots = s.offset

View File

@@ -1,6 +1,6 @@
discard """
line: 10
errormsg: "value returned by statement has to be discarded"
errormsg: "value of type 'bool' has to be discarded"
"""
proc p =

View File

@@ -1,9 +1,9 @@
discard """
file: "tstmtexp.nim"
line: 8
errormsg: "value returned by statement has to be discarded"
errormsg: "value of type 'int literal(5)' has to be discarded"
"""
# Test 3
1+4 #ERROR_MSG value returned by statement has to be discarded
1+4