bugfixes for thread analysis

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

View File

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