cooler quote for c2nim

This commit is contained in:
Araq 2013-10-10 00:45:15 +02:00
commit f9861e1fab
3 changed files with 16 additions and 24 deletions

View file

@ -842,9 +842,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame) =
inc pc inc pc
proc execute(c: PCtx, start: int) = proc execute(c: PCtx, start: int) =
var pc = start var tos = PStackFrame(prc: nil, comesFrom: 0, next: nil)
var regs: TNodeSeq # alias to tos.slots for performance
var tos: PStackFrame
newSeq(tos.slots, c.prc.maxSlots) newSeq(tos.slots, c.prc.maxSlots)
rawExecute(c, start, tos) rawExecute(c, start, tos)
@ -899,9 +897,6 @@ proc setupMacroParam(x: PNode): PNode =
result = x result = x
if result.kind in {nkHiddenSubConv, nkHiddenStdConv}: result = result.sons[1] if result.kind in {nkHiddenSubConv, nkHiddenStdConv}: result = result.sons[1]
type
PEvalContext* = PCtx
proc evalMacroCall(c: PEvalContext, n, nOrig: PNode, sym: PSym): PNode = proc evalMacroCall(c: PEvalContext, n, nOrig: PNode, sym: PSym): PNode =
# XXX GlobalError() is ugly here, but I don't know a better solution for now # XXX GlobalError() is ugly here, but I don't know a better solution for now
inc(evalTemplateCounter) inc(evalTemplateCounter)
@ -909,21 +904,21 @@ proc evalMacroCall(c: PEvalContext, n, nOrig: PNode, sym: PSym): PNode =
GlobalError(n.info, errTemplateInstantiationTooNested) GlobalError(n.info, errTemplateInstantiationTooNested)
c.callsite = nOrig c.callsite = nOrig
var s = newStackFrame() let body = optBody(c, sym)
s.call = n let start = genStmt(c, body)
s.prc = sym
var tos = PStackFrame(prc: sym, comesFrom: 0, next: nil)
newSeq(tos.slots, c.prc.maxSlots)
# setup arguments:
var L = n.safeLen var L = n.safeLen
if L == 0: L = 1 if L == 0: L = 1
setlen(s.slots, L) InternalAssert tos.slots.len >= L
# return value: # return value:
s.slots[0] = newNodeIT(nkNilLit, n.info, sym.typ.sons[0]) tos.slots[0] = newNodeIT(nkNilLit, n.info, sym.typ.sons[0])
# setup parameters: # setup parameters:
for i in 1 .. < L: s.slots[i] = setupMacroParam(n.sons[i]) for i in 1 .. < L: tos.slots[i] = setupMacroParam(n.sons[i])
pushStackFrame(c, s) rawExecute(c, start, tos)
discard eval(c, optBody(c, sym)) result = tos.slots[0]
result = s.slots[0]
popStackFrame(c)
if cyclicTree(result): GlobalError(n.info, errCyclicTree) if cyclicTree(result): GlobalError(n.info, errCyclicTree)
dec(evalTemplateCounter) dec(evalTemplateCounter)
c.callsite = nil c.callsite = nil

View file

@ -162,6 +162,9 @@ type
callsite*: PNode callsite*: PNode
TPosition* = distinct int TPosition* = distinct int
PEvalContext* = PCtx
proc newCtx*(module: PSym): PCtx = proc newCtx*(module: PSym): PCtx =
PCtx(code: @[], debug: @[], PCtx(code: @[], debug: @[],

View file

@ -10,13 +10,7 @@
Introduction Introduction
============ ============
.. raw:: html "We all make choices. But in the end our choices make us."
<blockquote><p>
"Ich bin der K&ouml;nig aller Blinden.
Glaubt ihr wirklich ihr selbst k&ouml;nnt sehen?
Kniet euch alle nieder in den Dreck,
bis ich befehle aufzustehen."
</p></blockquote>
c2nim is a tool to translate Ansi C code to Nimrod. The output is c2nim is a tool to translate Ansi C code to Nimrod. The output is