mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-07 21:43:33 +00:00
made some tests green; htmlgen still broken
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user