revert new scope for 'if'
This commit is contained in:
parent
c75aa98706
commit
1dd01e5891
8 changed files with 182 additions and 6 deletions
|
|
@ -232,13 +232,14 @@ proc genIfStmt(p: BProc, n: PNode) =
|
|||
for i in countup(0, sonsLen(n) - 1):
|
||||
var it = n.sons[i]
|
||||
if it.len == 2:
|
||||
startBlock(p)
|
||||
when newScopeForIf: startBlock(p)
|
||||
initLocExpr(p, it.sons[0], a)
|
||||
Lelse = getLabel(p)
|
||||
inc(p.labels)
|
||||
lineFF(p, cpsStmts, "if (!$1) goto $2;$n",
|
||||
"br i1 $1, label %LOC$3, label %$2$n" & "LOC$3: $n",
|
||||
[rdLoc(a), Lelse, toRope(p.labels)])
|
||||
when not newScopeForIf: startBlock(p)
|
||||
genStmts(p, it.sons[1])
|
||||
endBlock(p)
|
||||
if sonsLen(n) > 1:
|
||||
|
|
|
|||
|
|
@ -7,13 +7,14 @@
|
|||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
import
|
||||
import
|
||||
os, lists, strutils, strtabs
|
||||
|
||||
const
|
||||
hasTinyCBackend* = defined(tinyc)
|
||||
useEffectSystem* = true
|
||||
hasFFI* = defined(useFFI)
|
||||
newScopeForIf* = false # XXX activate for 0.9.4
|
||||
|
||||
type # please make sure we have under 32 options
|
||||
# (improves code efficiency a lot!)
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ proc newSymS(kind: TSymKind, n: PNode, c: PContext): PSym =
|
|||
|
||||
proc newSymG*(kind: TSymKind, n: PNode, c: PContext): PSym =
|
||||
# like newSymS, but considers gensym'ed symbols
|
||||
if n.kind == nkSym:
|
||||
if n.kind == nkSym:
|
||||
result = n.sym
|
||||
InternalAssert sfGenSym in result.flags
|
||||
InternalAssert result.kind == kind
|
||||
|
|
|
|||
|
|
@ -1504,8 +1504,9 @@ proc semIf(c: PContext, n: PNode): PNode =
|
|||
for i in countup(0, sonsLen(n) - 1):
|
||||
var it = n.sons[i]
|
||||
if it.len == 2:
|
||||
openScope(c.tab)
|
||||
when newScopeForIf: openScope(c.tab)
|
||||
it.sons[0] = forceBool(c, semExprWithType(c, it.sons[0]))
|
||||
when not newScopeForIf: openScope(c.tab)
|
||||
it.sons[1] = semExprBranch(c, it.sons[1])
|
||||
typ = commonType(typ, it.sons[1].typ)
|
||||
closeScope(c.tab)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue