From 6dd2c2d7670b11aa2155f41e1309dad011456140 Mon Sep 17 00:00:00 2001 From: Araq Date: Sun, 4 Nov 2012 18:09:15 +0100 Subject: exception tracking should work --- compiler/sempass2.nim | 57 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 10 deletions(-) (limited to 'compiler/sempass2.nim') diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index 4199aa5f7..1811beb2d 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -9,7 +9,7 @@ import intsets, ast, astalgo, msgs, renderer, magicsys, types, idents, trees, - wordrecg + wordrecg, strutils # Second semantic checking pass over the AST. Necessary because the old # way had some inherent problems. Performs: @@ -158,7 +158,7 @@ proc trackPragmaStmt(tracked: PEffects, n: PNode) = # list the computed effects up to here: listEffects(tracked) -proc raisesSpec(n: PNode): PNode = +proc raisesSpec*(n: PNode): PNode = for i in countup(0, sonsLen(n) - 1): var it = n.sons[i] if it.kind == nkExprColonExpr and whichPragma(it) == wRaises: @@ -168,26 +168,62 @@ proc raisesSpec(n: PNode): PNode = result.add(it.sons[1]) return +proc documentRaises*(n: PNode) = + if n.sons[namePos].kind != nkSym: return + + var x = n.sons[pragmasPos] + let spec = raisesSpec(x) + if isNil(spec): + let s = n.sons[namePos].sym + + let actual = s.typ.n.sons[0] + if actual.len != effectListLen: return + let real = actual.sons[exceptionEffects] + + # warning: hack ahead: + var effects = newNodeI(nkBracket, n.info, real.len) + for i in 0 ..