mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
code cleanup: remove newScopeForIf switch
This commit is contained in:
@@ -340,13 +340,12 @@ proc genIf(p: BProc, n: PNode, d: var TLoc) =
|
||||
# bug #4230: avoid false sharing between branches:
|
||||
if d.k == locTemp and isEmptyType(n.typ): d.k = locNone
|
||||
if it.len == 2:
|
||||
when newScopeForIf: startBlock(p)
|
||||
startBlock(p)
|
||||
initLocExprSingleUse(p, it.sons[0], a)
|
||||
lelse = getLabel(p)
|
||||
inc(p.labels)
|
||||
lineF(p, cpsStmts, "if (!$1) goto $2;$n",
|
||||
[rdLoc(a), lelse])
|
||||
when not newScopeForIf: startBlock(p)
|
||||
if p.module.compileToCpp:
|
||||
# avoid "jump to label crosses initialization" error:
|
||||
add(p.s(cpsStmts), "{")
|
||||
|
||||
@@ -18,8 +18,6 @@ const
|
||||
useEffectSystem* = true
|
||||
useWriteTracking* = false
|
||||
hasFFI* = defined(useFFI)
|
||||
newScopeForIf* = true
|
||||
useCaas* = not defined(noCaas)
|
||||
copyrightYear* = "2018"
|
||||
|
||||
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):
|
||||
var it = n.sons[i]
|
||||
if it.len == 2:
|
||||
when newScopeForIf: openScope(c)
|
||||
openScope(c)
|
||||
it.sons[0] = forceBool(c, semExprWithType(c, it.sons[0]))
|
||||
when not newScopeForIf: openScope(c)
|
||||
it.sons[1] = semExprBranch(c, it.sons[1])
|
||||
typ = commonType(typ, it.sons[1])
|
||||
closeScope(c)
|
||||
@@ -212,9 +211,8 @@ proc semCase(c: PContext, n: PNode): PNode =
|
||||
of nkElifBranch:
|
||||
chckCovered = false
|
||||
checkSonsLen(x, 2, c.config)
|
||||
when newScopeForIf: openScope(c)
|
||||
openScope(c)
|
||||
x.sons[0] = forceBool(c, semExprWithType(c, x.sons[0]))
|
||||
when not newScopeForIf: openScope(c)
|
||||
x.sons[1] = semExprBranch(c, x.sons[1])
|
||||
typ = commonType(typ, x.sons[1])
|
||||
closeScope(c)
|
||||
|
||||
@@ -340,9 +340,8 @@ proc semTemplBody(c: var TemplCtx, n: PNode): PNode =
|
||||
for i in countup(0, sonsLen(n)-1):
|
||||
var it = n.sons[i]
|
||||
if it.len == 2:
|
||||
when newScopeForIf: openScope(c)
|
||||
openScope(c)
|
||||
it.sons[0] = semTemplBody(c, it.sons[0])
|
||||
when not newScopeForIf: openScope(c)
|
||||
it.sons[1] = semTemplBody(c, it.sons[1])
|
||||
closeScope(c)
|
||||
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
|
||||
Reference in New Issue
Block a user