bugfixes for thread analysis

This commit is contained in:
Araq 2012-11-22 01:36:57 +01:00
commit 338683a198

View file

@ -184,8 +184,9 @@ proc analyseCall(c: PProcCtx, n: PNode): TThreadOwner =
call.args[i-1] = analyse(c, n[i]) call.args[i-1] = analyse(c, n[i])
if not computed.hasKey(call): if not computed.hasKey(call):
computed[call] = toUndefined # we are computing it computed[call] = toUndefined # we are computing it
for i in 1..n.len-1: let prctyp = skipTypes(prc.typ, abstractInst).n
var formal = skipTypes(prc.typ, abstractInst).n.sons[i].sym for i in 1.. prctyp.len-1:
var formal = prctyp.sons[i].sym
newCtx.mapping[formal.id] = call.args[i-1] newCtx.mapping[formal.id] = call.args[i-1]
pushInfoContext(n.info) pushInfoContext(n.info)
result = analyse(newCtx, prc.getBody) result = analyse(newCtx, prc.getBody)
@ -226,7 +227,8 @@ proc analyseVarSection(c: PProcCtx, n: PNode): TThreadOwner =
var a = n.sons[i] var a = n.sons[i]
if a.kind == nkCommentStmt: continue if a.kind == nkCommentStmt: continue
if a.kind == nkIdentDefs: if a.kind == nkIdentDefs:
assert(a.sons[0].kind == nkSym) #assert(a.sons[0].kind == nkSym); also valid for after
# closure transformation:
analyseSingleVar(c, a) analyseSingleVar(c, a)
else: else:
analyseVarTuple(c, a) analyseVarTuple(c, a)
@ -359,9 +361,11 @@ proc analyse(c: PProcCtx, n: PNode): TThreadOwner =
of nkReturnStmt, nkDiscardStmt: of nkReturnStmt, nkDiscardStmt:
if n.sons[0].kind != nkEmpty: result = analyse(c, n.sons[0]) if n.sons[0].kind != nkEmpty: result = analyse(c, n.sons[0])
else: result = toVoid else: result = toVoid
of nkLambdaKinds, nkClosure:
result = toMine
of nkAsmStmt, nkPragma, nkIteratorDef, nkProcDef, nkMethodDef, of nkAsmStmt, nkPragma, nkIteratorDef, nkProcDef, nkMethodDef,
nkConverterDef, nkMacroDef, nkTemplateDef, nkLambdaKinds, nkClosure, nkConverterDef, nkMacroDef, nkTemplateDef,
nkGotoState, nkState: nkGotoState, nkState, nkBreakState, nkType:
result = toVoid result = toVoid
of nkExprColonExpr: of nkExprColonExpr:
result = analyse(c, n.sons[1]) result = analyse(c, n.sons[1])