code cleanup: remove newScopeForIf switch
This commit is contained in:
parent
86a7054c88
commit
db35ac435b
5 changed files with 4 additions and 78 deletions
|
|
@ -340,13 +340,12 @@ proc genIf(p: BProc, n: PNode, d: var TLoc) =
|
||||||
# bug #4230: avoid false sharing between branches:
|
# bug #4230: avoid false sharing between branches:
|
||||||
if d.k == locTemp and isEmptyType(n.typ): d.k = locNone
|
if d.k == locTemp and isEmptyType(n.typ): d.k = locNone
|
||||||
if it.len == 2:
|
if it.len == 2:
|
||||||
when newScopeForIf: startBlock(p)
|
startBlock(p)
|
||||||
initLocExprSingleUse(p, it.sons[0], a)
|
initLocExprSingleUse(p, it.sons[0], a)
|
||||||
lelse = getLabel(p)
|
lelse = getLabel(p)
|
||||||
inc(p.labels)
|
inc(p.labels)
|
||||||
lineF(p, cpsStmts, "if (!$1) goto $2;$n",
|
lineF(p, cpsStmts, "if (!$1) goto $2;$n",
|
||||||
[rdLoc(a), lelse])
|
[rdLoc(a), lelse])
|
||||||
when not newScopeForIf: startBlock(p)
|
|
||||||
if p.module.compileToCpp:
|
if p.module.compileToCpp:
|
||||||
# avoid "jump to label crosses initialization" error:
|
# avoid "jump to label crosses initialization" error:
|
||||||
add(p.s(cpsStmts), "{")
|
add(p.s(cpsStmts), "{")
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,6 @@ const
|
||||||
useEffectSystem* = true
|
useEffectSystem* = true
|
||||||
useWriteTracking* = false
|
useWriteTracking* = false
|
||||||
hasFFI* = defined(useFFI)
|
hasFFI* = defined(useFFI)
|
||||||
newScopeForIf* = true
|
|
||||||
useCaas* = not defined(noCaas)
|
|
||||||
copyrightYear* = "2018"
|
copyrightYear* = "2018"
|
||||||
|
|
||||||
type # please make sure we have under 32 options
|
type # please make sure we have under 32 options
|
||||||
|
|
|
||||||
|
|
@ -155,9 +155,8 @@ proc semIf(c: PContext, n: PNode): PNode =
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in countup(0, sonsLen(n) - 1):
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
if it.len == 2:
|
if it.len == 2:
|
||||||
when newScopeForIf: openScope(c)
|
openScope(c)
|
||||||
it.sons[0] = forceBool(c, semExprWithType(c, it.sons[0]))
|
it.sons[0] = forceBool(c, semExprWithType(c, it.sons[0]))
|
||||||
when not newScopeForIf: openScope(c)
|
|
||||||
it.sons[1] = semExprBranch(c, it.sons[1])
|
it.sons[1] = semExprBranch(c, it.sons[1])
|
||||||
typ = commonType(typ, it.sons[1])
|
typ = commonType(typ, it.sons[1])
|
||||||
closeScope(c)
|
closeScope(c)
|
||||||
|
|
@ -212,9 +211,8 @@ proc semCase(c: PContext, n: PNode): PNode =
|
||||||
of nkElifBranch:
|
of nkElifBranch:
|
||||||
chckCovered = false
|
chckCovered = false
|
||||||
checkSonsLen(x, 2, c.config)
|
checkSonsLen(x, 2, c.config)
|
||||||
when newScopeForIf: openScope(c)
|
openScope(c)
|
||||||
x.sons[0] = forceBool(c, semExprWithType(c, x.sons[0]))
|
x.sons[0] = forceBool(c, semExprWithType(c, x.sons[0]))
|
||||||
when not newScopeForIf: openScope(c)
|
|
||||||
x.sons[1] = semExprBranch(c, x.sons[1])
|
x.sons[1] = semExprBranch(c, x.sons[1])
|
||||||
typ = commonType(typ, x.sons[1])
|
typ = commonType(typ, x.sons[1])
|
||||||
closeScope(c)
|
closeScope(c)
|
||||||
|
|
|
||||||
|
|
@ -340,9 +340,8 @@ proc semTemplBody(c: var TemplCtx, n: PNode): PNode =
|
||||||
for i in countup(0, sonsLen(n)-1):
|
for i in countup(0, sonsLen(n)-1):
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
if it.len == 2:
|
if it.len == 2:
|
||||||
when newScopeForIf: openScope(c)
|
openScope(c)
|
||||||
it.sons[0] = semTemplBody(c, it.sons[0])
|
it.sons[0] = semTemplBody(c, it.sons[0])
|
||||||
when not newScopeForIf: openScope(c)
|
|
||||||
it.sons[1] = semTemplBody(c, it.sons[1])
|
it.sons[1] = semTemplBody(c, it.sons[1])
|
||||||
closeScope(c)
|
closeScope(c)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
#
|
|
||||||
#
|
|
||||||
# The Nim Compiler
|
|
||||||
# (c) Copyright 2015 Andreas Rumpf
|
|
||||||
#
|
|
||||||
# See the file "copying.txt", included in this
|
|
||||||
# distribution, for details about the copyright.
|
|
||||||
#
|
|
||||||
|
|
||||||
## Implements the "compiler as a service" feature.
|
|
||||||
|
|
||||||
import
|
|
||||||
times, commands, options, msgs, nimconf,
|
|
||||||
extccomp, strutils, os, platform, parseopt, idents, lineinfos
|
|
||||||
|
|
||||||
when useCaas:
|
|
||||||
import net
|
|
||||||
|
|
||||||
# We cache modules and the dependency graph. However, we don't check for
|
|
||||||
# file changes but expect the client to tell us about them, otherwise the
|
|
||||||
# repeated hash calculations may turn out to be too slow.
|
|
||||||
|
|
||||||
var
|
|
||||||
curCaasCmd* = ""
|
|
||||||
lastCaasCmd* = ""
|
|
||||||
# in caas mode, the list of defines and options will be given at start-up?
|
|
||||||
# it's enough to check that the previous compilation command is the same?
|
|
||||||
|
|
||||||
proc serve*(cache: IdentCache; action: proc (cache: IdentCache){.nimcall.}; config: ConfigRef) =
|
|
||||||
template execute(cmd) =
|
|
||||||
curCaasCmd = cmd
|
|
||||||
processCmdLine(passCmd2, cmd, config)
|
|
||||||
action(cache)
|
|
||||||
config.errorCounter = 0
|
|
||||||
|
|
||||||
let typ = getConfigVar(config, "server.type")
|
|
||||||
case typ
|
|
||||||
of "stdin":
|
|
||||||
while true:
|
|
||||||
var line = stdin.readLine.string
|
|
||||||
if line == "quit": quit()
|
|
||||||
execute line
|
|
||||||
echo ""
|
|
||||||
flushFile(stdout)
|
|
||||||
|
|
||||||
of "tcp", "":
|
|
||||||
when useCaas:
|
|
||||||
var server = newSocket()
|
|
||||||
let p = getConfigVar(config, "server.port")
|
|
||||||
let port = if p.len > 0: parseInt(p).Port else: 6000.Port
|
|
||||||
server.bindAddr(port, getConfigVar(config, "server.address"))
|
|
||||||
var inp = "".TaintedString
|
|
||||||
server.listen()
|
|
||||||
var stdoutSocket = newSocket()
|
|
||||||
config.writelnHook = proc (line: string) =
|
|
||||||
stdoutSocket.send(line & "\c\L")
|
|
||||||
|
|
||||||
while true:
|
|
||||||
accept(server, stdoutSocket)
|
|
||||||
stdoutSocket.readLine(inp)
|
|
||||||
execute inp.string
|
|
||||||
stdoutSocket.send("\c\L")
|
|
||||||
stdoutSocket.close()
|
|
||||||
else:
|
|
||||||
msgQuit "server.type not supported; compiler built without caas support"
|
|
||||||
else:
|
|
||||||
echo "Invalid server.type:", typ
|
|
||||||
msgQuit 1
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue