anonymous procs implemented; however no closure support yet
This commit is contained in:
parent
00a4e19e8f
commit
f0145ba7c5
5 changed files with 27 additions and 6 deletions
|
|
@ -1716,6 +1716,12 @@ proc expr(p: BProc, e: PNode, d: var TLoc) =
|
|||
of nkStringToCString: convStrToCStr(p, e, d)
|
||||
of nkCStringToString: convCStrToStr(p, e, d)
|
||||
of nkPassAsOpenArray: passToOpenArray(p, e, d)
|
||||
of nkLambda:
|
||||
var sym = e.sons[namePos].sym
|
||||
genProc(p.module, sym)
|
||||
if sym.loc.r == nil or sym.loc.t == nil:
|
||||
InternalError(e.info, "expr: proc not init " & sym.name.s)
|
||||
putLocIntoDest(p, d, sym.loc)
|
||||
else: InternalError(e.info, "expr(" & $e.kind & "); unknown node kind")
|
||||
|
||||
proc genNamedConstExpr(p: BProc, n: PNode): PRope =
|
||||
|
|
|
|||
|
|
@ -593,7 +593,8 @@ proc semLambda(c: PContext, n: PNode): PNode =
|
|||
else:
|
||||
s.typ = newTypeS(tyProc, c)
|
||||
addSon(s.typ, nil)
|
||||
s.typ.callConv = ccClosure
|
||||
# no! do a proper analysis to determine calling convention
|
||||
when false: s.typ.callConv = ccClosure
|
||||
if n.sons[pragmasPos].kind != nkEmpty:
|
||||
pragma(c, s, n.sons[pragmasPos], lambdaPragmas)
|
||||
s.options = gOptions
|
||||
|
|
@ -644,10 +645,10 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
|
|||
var proto = SearchForProc(c, s, c.tab.tos-2) # -2 because we have a scope
|
||||
# open for parameters
|
||||
if proto == nil:
|
||||
if c.p.owner.kind != skModule:
|
||||
s.typ.callConv = ccClosure
|
||||
else:
|
||||
s.typ.callConv = lastOptionEntry(c).defaultCC
|
||||
s.typ.callConv = lastOptionEntry(c).defaultCC
|
||||
when false:
|
||||
# do a proper analysis here:
|
||||
if c.p.owner.kind != skModule: s.typ.callConv = ccClosure
|
||||
# add it here, so that recursive procs are possible:
|
||||
# -2 because we have a scope open for parameters
|
||||
if kind in OverloadableSyms:
|
||||
|
|
|
|||
|
|
@ -684,6 +684,8 @@ proc transform(c: PTransf, n: PNode): PTransNode =
|
|||
of nkBracketExpr:
|
||||
result = transformArrayAccess(c, n)
|
||||
of nkLambda:
|
||||
n.sons[codePos] = PNode(transform(c, n.sons[codePos]))
|
||||
result = PTransNode(n)
|
||||
when false: result = transformLambda(c, n)
|
||||
of nkForStmt:
|
||||
result = transformFor(c, n)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue