Merge branch 'master' of github.com:Araq/Nimrod
This commit is contained in:
commit
635ad3b336
31 changed files with 460 additions and 331 deletions
|
|
@ -36,9 +36,9 @@ proc semGenericStmt(c: PContext, n: PNode, flags: TSemGenericFlags,
|
|||
proc semGenericStmtScope(c: PContext, n: PNode,
|
||||
flags: TSemGenericFlags,
|
||||
ctx: var TIntSet): PNode =
|
||||
openScope(c.tab)
|
||||
openScope(c)
|
||||
result = semGenericStmt(c, n, flags, ctx)
|
||||
closeScope(c.tab)
|
||||
closeScope(c)
|
||||
|
||||
template macroToExpand(s: expr): expr =
|
||||
s.kind in {skMacro, skTemplate} and (s.typ.len == 1 or sfImmediate in s.flags)
|
||||
|
|
@ -77,7 +77,7 @@ proc Lookup(c: PContext, n: PNode, flags: TSemGenericFlags,
|
|||
ctx: var TIntSet): PNode =
|
||||
result = n
|
||||
let ident = considerAcc(n)
|
||||
var s = SymtabGet(c.Tab, ident)
|
||||
var s = searchInScopes(c, ident)
|
||||
if s == nil:
|
||||
if ident.id notin ctx and withinMixin notin flags:
|
||||
localError(n.info, errUndeclaredIdentifier, ident.s)
|
||||
|
|
@ -175,12 +175,12 @@ proc semGenericStmt(c: PContext, n: PNode,
|
|||
for i in countup(0, sonsLen(n)-1):
|
||||
n.sons[i] = semGenericStmt(c, n.sons[i], flags+{withinMixin}, ctx)
|
||||
of nkWhileStmt:
|
||||
openScope(c.tab)
|
||||
openScope(c)
|
||||
for i in countup(0, sonsLen(n)-1):
|
||||
n.sons[i] = semGenericStmt(c, n.sons[i], flags, ctx)
|
||||
closeScope(c.tab)
|
||||
closeScope(c)
|
||||
of nkCaseStmt:
|
||||
openScope(c.tab)
|
||||
openScope(c)
|
||||
n.sons[0] = semGenericStmt(c, n.sons[0], flags, ctx)
|
||||
for i in countup(1, sonsLen(n)-1):
|
||||
var a = n.sons[i]
|
||||
|
|
@ -189,22 +189,22 @@ proc semGenericStmt(c: PContext, n: PNode,
|
|||
for j in countup(0, L-2):
|
||||
a.sons[j] = semGenericStmt(c, a.sons[j], flags, ctx)
|
||||
a.sons[L - 1] = semGenericStmtScope(c, a.sons[L-1], flags, ctx)
|
||||
closeScope(c.tab)
|
||||
closeScope(c)
|
||||
of nkForStmt, nkParForStmt:
|
||||
var L = sonsLen(n)
|
||||
openScope(c.tab)
|
||||
openScope(c)
|
||||
n.sons[L - 2] = semGenericStmt(c, n.sons[L-2], flags, ctx)
|
||||
for i in countup(0, L - 3):
|
||||
addPrelimDecl(c, newSymS(skUnknown, n.sons[i], c))
|
||||
n.sons[L - 1] = semGenericStmt(c, n.sons[L-1], flags, ctx)
|
||||
closeScope(c.tab)
|
||||
closeScope(c)
|
||||
of nkBlockStmt, nkBlockExpr, nkBlockType:
|
||||
checkSonsLen(n, 2)
|
||||
openScope(c.tab)
|
||||
openScope(c)
|
||||
if n.sons[0].kind != nkEmpty:
|
||||
addPrelimDecl(c, newSymS(skUnknown, n.sons[0], c))
|
||||
n.sons[1] = semGenericStmt(c, n.sons[1], flags, ctx)
|
||||
closeScope(c.tab)
|
||||
closeScope(c)
|
||||
of nkTryStmt:
|
||||
checkMinSonsLen(n, 2)
|
||||
n.sons[0] = semGenericStmtScope(c, n.sons[0], flags, ctx)
|
||||
|
|
@ -260,10 +260,10 @@ proc semGenericStmt(c: PContext, n: PNode,
|
|||
if (a.kind != nkTypeDef): IllFormedAst(a)
|
||||
checkSonsLen(a, 3)
|
||||
if a.sons[1].kind != nkEmpty:
|
||||
openScope(c.tab)
|
||||
openScope(c)
|
||||
a.sons[1] = semGenericStmt(c, a.sons[1], flags, ctx)
|
||||
a.sons[2] = semGenericStmt(c, a.sons[2], flags+{withinTypeDesc}, ctx)
|
||||
closeScope(c.tab)
|
||||
closeScope(c)
|
||||
else:
|
||||
a.sons[2] = semGenericStmt(c, a.sons[2], flags+{withinTypeDesc}, ctx)
|
||||
of nkEnumTy:
|
||||
|
|
@ -276,7 +276,7 @@ proc semGenericStmt(c: PContext, n: PNode,
|
|||
of nkEnumFieldDef: a = n.sons[i].sons[0]
|
||||
of nkIdent: a = n.sons[i]
|
||||
else: illFormedAst(n)
|
||||
addDeclAt(c, newSymS(skUnknown, getIdentNode(a.sons[i]), c), c.tab.tos-1)
|
||||
addDecl(c, newSymS(skUnknown, getIdentNode(a.sons[i]), c))
|
||||
of nkObjectTy, nkTupleTy:
|
||||
nil
|
||||
of nkFormalParams:
|
||||
|
|
@ -298,7 +298,7 @@ proc semGenericStmt(c: PContext, n: PNode,
|
|||
checkSonsLen(n, bodyPos + 1)
|
||||
if n.kind notin nkLambdaKinds:
|
||||
addPrelimDecl(c, newSymS(skUnknown, getIdentNode(n.sons[0]), c))
|
||||
openScope(c.tab)
|
||||
openScope(c)
|
||||
n.sons[genericParamsPos] = semGenericStmt(c, n.sons[genericParamsPos],
|
||||
flags, ctx)
|
||||
if n.sons[paramsPos].kind != nkEmpty:
|
||||
|
|
@ -310,7 +310,7 @@ proc semGenericStmt(c: PContext, n: PNode,
|
|||
if n.sons[namePos].kind == nkSym: body = n.sons[namePos].sym.getBody
|
||||
else: body = n.sons[bodyPos]
|
||||
n.sons[bodyPos] = semGenericStmtScope(c, body, flags, ctx)
|
||||
closeScope(c.tab)
|
||||
closeScope(c)
|
||||
of nkPragma, nkPragmaExpr: nil
|
||||
of nkExprColonExpr:
|
||||
checkMinSonsLen(n, 2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue