fixes #293
This commit is contained in:
parent
e6fc044107
commit
3af5c99336
10 changed files with 38 additions and 22 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# The Nimrod Compiler
|
# The Nimrod Compiler
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2013 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# The Nimrod Compiler
|
# The Nimrod Compiler
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2013 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
|
|
@ -319,7 +319,7 @@ proc evalVar(c: PEvalContext, n: PNode): PNode =
|
||||||
else:
|
else:
|
||||||
if x.kind notin {nkEmpty..nkNilLit}:
|
if x.kind notin {nkEmpty..nkNilLit}:
|
||||||
discardSons(x)
|
discardSons(x)
|
||||||
for i in countup(0, sonsLen(result) - 1): addSon(x, result.sons[i])
|
for j in countup(0, sonsLen(result) - 1): addSon(x, result.sons[j])
|
||||||
result = emptyNode
|
result = emptyNode
|
||||||
|
|
||||||
proc aliasNeeded(n: PNode, flags: TEvalFlags): bool =
|
proc aliasNeeded(n: PNode, flags: TEvalFlags): bool =
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# The Nimrod Compiler
|
# The Nimrod Compiler
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2013 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# The Nimrod Compiler
|
# The Nimrod Compiler
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2013 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
|
|
@ -754,7 +754,6 @@ proc doParamsAux(g: var TSrcGen, params: PNode) =
|
||||||
proc gsub(g: var TSrcGen, n: PNode, c: TContext) =
|
proc gsub(g: var TSrcGen, n: PNode, c: TContext) =
|
||||||
if isNil(n): return
|
if isNil(n): return
|
||||||
var
|
var
|
||||||
L: int
|
|
||||||
a: TContext
|
a: TContext
|
||||||
if n.comment != nil: pushCom(g, n)
|
if n.comment != nil: pushCom(g, n)
|
||||||
case n.kind # atoms:
|
case n.kind # atoms:
|
||||||
|
|
@ -1096,7 +1095,7 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) =
|
||||||
incl(a.flags, rfInConstExpr)
|
incl(a.flags, rfInConstExpr)
|
||||||
gsection(g, n, a, tkConst, "const")
|
gsection(g, n, a, tkConst, "const")
|
||||||
of nkVarSection, nkLetSection:
|
of nkVarSection, nkLetSection:
|
||||||
L = sonsLen(n)
|
var L = sonsLen(n)
|
||||||
if L == 0: return
|
if L == 0: return
|
||||||
if n.kind == nkVarSection: putWithSpace(g, tkVar, "var")
|
if n.kind == nkVarSection: putWithSpace(g, tkVar, "var")
|
||||||
else: putWithSpace(g, tkLet, "let")
|
else: putWithSpace(g, tkLet, "let")
|
||||||
|
|
|
||||||
|
|
@ -172,11 +172,16 @@ proc fitRemoveHiddenConv(c: PContext, typ: Ptype, n: PNode): PNode =
|
||||||
changeType(result, typ)
|
changeType(result, typ)
|
||||||
|
|
||||||
proc findShadowedVar(c: PContext, v: PSym): PSym =
|
proc findShadowedVar(c: PContext, v: PSym): PSym =
|
||||||
for i in countdown(c.tab.tos - 2, 0):
|
for i in countdown(c.tab.tos - 2, ModuleTablePos+1):
|
||||||
let shadowed = StrTableGet(c.tab.stack[i], v.name)
|
let shadowed = StrTableGet(c.tab.stack[i], v.name)
|
||||||
if shadowed != nil and shadowed.kind in skLocalVars:
|
if shadowed != nil and shadowed.kind in skLocalVars:
|
||||||
return shadowed
|
return shadowed
|
||||||
|
|
||||||
|
proc identWithin(n: PNode, s: PIdent): bool =
|
||||||
|
for i in 0 .. n.safeLen-1:
|
||||||
|
if identWithin(n.sons[i], s): return true
|
||||||
|
result = n.kind == nkSym and n.sym.name.id == s.id
|
||||||
|
|
||||||
proc semIdentDef(c: PContext, n: PNode, kind: TSymKind): PSym =
|
proc semIdentDef(c: PContext, n: PNode, kind: TSymKind): PSym =
|
||||||
if isTopLevel(c):
|
if isTopLevel(c):
|
||||||
result = semIdentWithPragma(c, kind, n, {sfExported})
|
result = semIdentWithPragma(c, kind, n, {sfExported})
|
||||||
|
|
@ -239,6 +244,9 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
|
||||||
let shadowed = findShadowedVar(c, v)
|
let shadowed = findShadowedVar(c, v)
|
||||||
if shadowed != nil:
|
if shadowed != nil:
|
||||||
shadowed.flags.incl(sfShadowed)
|
shadowed.flags.incl(sfShadowed)
|
||||||
|
# a shadowed variable is an error unless it appears on the right
|
||||||
|
# side of the '=':
|
||||||
|
if warnShadowIdent in gNotes and not identWithin(def, v.name):
|
||||||
Message(a.info, warnShadowIdent, v.name.s)
|
Message(a.info, warnShadowIdent, v.name.s)
|
||||||
if def != nil and def.kind != nkEmpty:
|
if def != nil and def.kind != nkEmpty:
|
||||||
# this is only needed for the evaluation pass:
|
# this is only needed for the evaluation pass:
|
||||||
|
|
@ -368,6 +376,15 @@ proc semForFields(c: PContext, n: PNode, m: TMagic): PNode =
|
||||||
b.add(ast.emptyNode)
|
b.add(ast.emptyNode)
|
||||||
stmts.add(b)
|
stmts.add(b)
|
||||||
|
|
||||||
|
proc addForVarDecl(c: PContext, v: PSym) =
|
||||||
|
if warnShadowIdent in gNotes:
|
||||||
|
let shadowed = findShadowedVar(c, v)
|
||||||
|
if shadowed != nil:
|
||||||
|
# XXX should we do this here?
|
||||||
|
#shadowed.flags.incl(sfShadowed)
|
||||||
|
Message(v.info, warnShadowIdent, v.name.s)
|
||||||
|
addDecl(c, v)
|
||||||
|
|
||||||
proc semForVars(c: PContext, n: PNode): PNode =
|
proc semForVars(c: PContext, n: PNode): PNode =
|
||||||
result = n
|
result = n
|
||||||
var length = sonsLen(n)
|
var length = sonsLen(n)
|
||||||
|
|
@ -383,7 +400,7 @@ proc semForVars(c: PContext, n: PNode): PNode =
|
||||||
# for an example:
|
# for an example:
|
||||||
v.typ = n.sons[length-2].typ
|
v.typ = n.sons[length-2].typ
|
||||||
n.sons[0] = newSymNode(v)
|
n.sons[0] = newSymNode(v)
|
||||||
if sfGenSym notin v.flags: addDecl(c, v)
|
if sfGenSym notin v.flags: addForVarDecl(c, v)
|
||||||
else:
|
else:
|
||||||
LocalError(n.info, errWrongNumberOfVariables)
|
LocalError(n.info, errWrongNumberOfVariables)
|
||||||
elif length-2 != sonsLen(iter):
|
elif length-2 != sonsLen(iter):
|
||||||
|
|
@ -394,7 +411,7 @@ proc semForVars(c: PContext, n: PNode): PNode =
|
||||||
if getCurrOwner().kind == skModule: incl(v.flags, sfGlobal)
|
if getCurrOwner().kind == skModule: incl(v.flags, sfGlobal)
|
||||||
v.typ = iter.sons[i]
|
v.typ = iter.sons[i]
|
||||||
n.sons[i] = newSymNode(v)
|
n.sons[i] = newSymNode(v)
|
||||||
if sfGenSym notin v.flags: addDecl(c, v)
|
if sfGenSym notin v.flags: addForVarDecl(c, v)
|
||||||
Inc(c.p.nestedLoopCounter)
|
Inc(c.p.nestedLoopCounter)
|
||||||
n.sons[length-1] = SemStmt(c, n.sons[length-1])
|
n.sons[length-1] = SemStmt(c, n.sons[length-1])
|
||||||
Dec(c.p.nestedLoopCounter)
|
Dec(c.p.nestedLoopCounter)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# The Nimrod Compiler
|
# The Nimrod Compiler
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2013 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nimrod's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2013 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nimrod's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2013 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
|
|
@ -201,9 +201,9 @@ proc execProcesses*(cmds: openArray[string],
|
||||||
q[r] = startCmd(cmds[i], options=options)
|
q[r] = startCmd(cmds[i], options=options)
|
||||||
inc(i)
|
inc(i)
|
||||||
if i > high(cmds): break
|
if i > high(cmds): break
|
||||||
for i in 0..m-1:
|
for j in 0..m-1:
|
||||||
if q[i] != nil: close(q[i])
|
if q[j] != nil: close(q[j])
|
||||||
result = max(waitForExit(q[i]), result)
|
result = max(waitForExit(q[j]), result)
|
||||||
else:
|
else:
|
||||||
for i in 0..high(cmds):
|
for i in 0..high(cmds):
|
||||||
var p = startCmd(cmds[i], options=options)
|
var p = startCmd(cmds[i], options=options)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nimrod's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2013 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
|
|
|
||||||
6
todo.txt
6
todo.txt
|
|
@ -1,9 +1,6 @@
|
||||||
version 0.9.2
|
version 0.9.2
|
||||||
=============
|
=============
|
||||||
|
|
||||||
- FFI:
|
|
||||||
* test libffi on windows
|
|
||||||
* test: times.format with the FFI
|
|
||||||
- fix closure bug finally
|
- fix closure bug finally
|
||||||
- fix marshal bug
|
- fix marshal bug
|
||||||
- investigate nimgame bug
|
- investigate nimgame bug
|
||||||
|
|
@ -12,6 +9,9 @@ version 0.9.2
|
||||||
version 0.9.X
|
version 0.9.X
|
||||||
=============
|
=============
|
||||||
|
|
||||||
|
- FFI:
|
||||||
|
* test libffi on windows
|
||||||
|
* test: times.format with the FFI
|
||||||
- test&finish first class iterators:
|
- test&finish first class iterators:
|
||||||
* nested iterators
|
* nested iterators
|
||||||
- implement the missing features wrt inheritance
|
- implement the missing features wrt inheritance
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue