added #903 to the test suite
This commit is contained in:
parent
9e66d988e7
commit
d15788d00a
5 changed files with 32 additions and 6 deletions
|
|
@ -448,7 +448,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
let n = src.sons[rc]
|
let n = src.sons[rc]
|
||||||
regs[ra].node = n
|
regs[ra].node = n
|
||||||
else:
|
else:
|
||||||
stackTrace(c, tos, pc, errIndexOutOfBounds)
|
stackTrace(c, tos, pc, errNilAccess)
|
||||||
of opcWrObj:
|
of opcWrObj:
|
||||||
# a.b = c
|
# a.b = c
|
||||||
decodeBC(rkNode)
|
decodeBC(rkNode)
|
||||||
|
|
@ -902,6 +902,10 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
let rb = instr.regBx - wordExcess - 1
|
let rb = instr.regBx - wordExcess - 1
|
||||||
ensureKind(rkNode)
|
ensureKind(rkNode)
|
||||||
regs[ra].node = c.globals.sons[rb]
|
regs[ra].node = c.globals.sons[rb]
|
||||||
|
of opcLdGlobalAddr:
|
||||||
|
let rb = instr.regBx - wordExcess - 1
|
||||||
|
ensureKind(rkNodeAddr)
|
||||||
|
regs[ra].nodeAddr = addr(c.globals.sons[rb])
|
||||||
of opcRepr:
|
of opcRepr:
|
||||||
decodeB(rkNode)
|
decodeB(rkNode)
|
||||||
createStr regs[ra]
|
createStr regs[ra]
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,7 @@ type
|
||||||
opcLdConst, # dest = constants[Bx]
|
opcLdConst, # dest = constants[Bx]
|
||||||
opcAsgnConst, # dest = copy(constants[Bx])
|
opcAsgnConst, # dest = copy(constants[Bx])
|
||||||
opcLdGlobal, # dest = globals[Bx]
|
opcLdGlobal, # dest = globals[Bx]
|
||||||
|
opcLdGlobalAddr, # dest = addr(globals[Bx])
|
||||||
|
|
||||||
opcLdImmInt, # dest = immediate value
|
opcLdImmInt, # dest = immediate value
|
||||||
opcNBindSym,
|
opcNBindSym,
|
||||||
|
|
|
||||||
|
|
@ -1614,7 +1614,7 @@ proc genProc(c: PCtx; s: PSym): int =
|
||||||
c.gABC(body, opcEof, eofInstr.regA)
|
c.gABC(body, opcEof, eofInstr.regA)
|
||||||
c.optimizeJumps(result)
|
c.optimizeJumps(result)
|
||||||
s.offset = c.prc.maxSlots
|
s.offset = c.prc.maxSlots
|
||||||
#if s.name.s == "tupleUnpack":
|
#if s.name.s == "addStuff":
|
||||||
# echo renderTree(body)
|
# echo renderTree(body)
|
||||||
# c.echoCode(result)
|
# c.echoCode(result)
|
||||||
c.prc = oldPrc
|
c.prc = oldPrc
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,13 @@ import macros, tables
|
||||||
var ZOOT{.compileTime.} = initTable[int, int](2)
|
var ZOOT{.compileTime.} = initTable[int, int](2)
|
||||||
var iii {.compiletime.} = 1
|
var iii {.compiletime.} = 1
|
||||||
|
|
||||||
macro x:stmt=
|
macro zoo:stmt=
|
||||||
zoot[iii] = iii*2
|
zoot[iii] = iii*2
|
||||||
inc iii
|
inc iii
|
||||||
echo iii
|
echo iii
|
||||||
|
|
||||||
x
|
zoo
|
||||||
x
|
zoo
|
||||||
|
|
||||||
|
|
||||||
macro tupleUnpack: stmt =
|
macro tupleUnpack: stmt =
|
||||||
|
|
@ -27,3 +27,24 @@ macro tupleUnpack: stmt =
|
||||||
|
|
||||||
tupleUnpack
|
tupleUnpack
|
||||||
|
|
||||||
|
# bug #903
|
||||||
|
|
||||||
|
import strtabs
|
||||||
|
|
||||||
|
var x {.compileTime.}: PStringTable
|
||||||
|
|
||||||
|
macro addStuff(stuff, body: expr): stmt {.immediate.} =
|
||||||
|
result = newNimNode(nnkStmtList)
|
||||||
|
|
||||||
|
if x.isNil:
|
||||||
|
x = newStringTable(modeStyleInsensitive)
|
||||||
|
x[$stuff] = ""
|
||||||
|
|
||||||
|
macro dump(): stmt =
|
||||||
|
result = newNimNode(nnkStmtList)
|
||||||
|
for y in x.keys: echo "Got ", y
|
||||||
|
|
||||||
|
addStuff("Hey"): echo "Hey"
|
||||||
|
addStuff("Hi"): echo "Hi"
|
||||||
|
dump()
|
||||||
|
|
||||||
|
|
|
||||||
2
todo.txt
2
todo.txt
|
|
@ -154,7 +154,7 @@ Optimizations
|
||||||
=============
|
=============
|
||||||
|
|
||||||
- optimize 'if' with a constant condition --> necessary in frontend for better
|
- optimize 'if' with a constant condition --> necessary in frontend for better
|
||||||
dead code elimination
|
dead code elimination; also necessary to prevent ``if c > 0: 1 div c``
|
||||||
- escape analysis for string/seq seems to be easy to do too;
|
- escape analysis for string/seq seems to be easy to do too;
|
||||||
even further write barrier specialization
|
even further write barrier specialization
|
||||||
- inlining of first class functions
|
- inlining of first class functions
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue