Merge branch 'devel' into faster-nimsuggest

This commit is contained in:
Andreas Rumpf 2017-02-24 01:28:50 +01:00
commit 46f33515d7
33 changed files with 190 additions and 240 deletions

View file

@ -10,7 +10,7 @@
# abstract syntax tree + symbol table # abstract syntax tree + symbol table
import import
msgs, hashes, nversion, options, strutils, securehash, ropes, idents, lists, msgs, hashes, nversion, options, strutils, securehash, ropes, idents,
intsets, idgen intsets, idgen
type type
@ -736,13 +736,15 @@ type
TLibKind* = enum TLibKind* = enum
libHeader, libDynamic libHeader, libDynamic
TLib* = object of lists.TListEntry # also misused for headers!
TLib* = object # also misused for headers!
kind*: TLibKind kind*: TLibKind
generated*: bool # needed for the backends: generated*: bool # needed for the backends:
isOverriden*: bool isOverriden*: bool
name*: Rope name*: Rope
path*: PNode # can be a string literal! path*: PNode # can be a string literal!
CompilesId* = int ## id that is used for the caching logic within CompilesId* = int ## id that is used for the caching logic within
## ``system.compiles``. See the seminst module. ## ``system.compiles``. See the seminst module.
TInstantiation* = object TInstantiation* = object

View file

@ -944,7 +944,7 @@ proc genEcho(p: BProc, n: PNode) =
# this unusal way of implementing it ensures that e.g. ``echo("hallo", 45)`` # this unusal way of implementing it ensures that e.g. ``echo("hallo", 45)``
# is threadsafe. # is threadsafe.
internalAssert n.kind == nkBracket internalAssert n.kind == nkBracket
discard lists.includeStr(p.module.headerFiles, "<stdio.h>") p.module.includeHeader("<stdio.h>")
var args: Rope = nil var args: Rope = nil
var a: TLoc var a: TLoc
for i in countup(0, n.len-1): for i in countup(0, n.len-1):

View file

@ -540,7 +540,7 @@ proc genBreakStmt(p: BProc, t: PNode) =
# named break? # named break?
assert(t.sons[0].kind == nkSym) assert(t.sons[0].kind == nkSym)
var sym = t.sons[0].sym var sym = t.sons[0].sym
assert(sym.loc.k == locOther) doAssert(sym.loc.k == locOther)
idx = sym.position-1 idx = sym.position-1
else: else:
# an unnamed 'break' can only break a loop after 'transf' pass: # an unnamed 'break' can only break a loop after 'transf' pass:
@ -884,7 +884,7 @@ proc genTry(p: BProc, t: PNode, d: var TLoc) =
# #
if not isEmptyType(t.typ) and d.k == locNone: if not isEmptyType(t.typ) and d.k == locNone:
getTemp(p, t.typ, d) getTemp(p, t.typ, d)
discard lists.includeStr(p.module.headerFiles, "<setjmp.h>") p.module.includeHeader("<setjmp.h>")
genLineDir(p, t) genLineDir(p, t)
var safePoint = getTempName(p.module) var safePoint = getTempName(p.module)
if getCompilerProc("Exception") != nil: if getCompilerProc("Exception") != nil:

View file

@ -10,7 +10,7 @@
# This module declares some helpers for the C code generator. # This module declares some helpers for the C code generator.
import import
ast, astalgo, ropes, lists, hashes, strutils, types, msgs, wordrecg, ast, astalgo, ropes, hashes, strutils, types, msgs, wordrecg,
platform, trees platform, trees
proc getPragmaStmt*(n: PNode, w: TSpecialWord): PNode = proc getPragmaStmt*(n: PNode, w: TSpecialWord): PNode =

View file

@ -11,7 +11,7 @@
import import
ast, astalgo, hashes, trees, platform, magicsys, extccomp, options, intsets, ast, astalgo, hashes, trees, platform, magicsys, extccomp, options, intsets,
nversion, nimsets, msgs, securehash, bitsets, idents, lists, types, nversion, nimsets, msgs, securehash, bitsets, idents, types,
ccgutils, os, ropes, math, passes, rodread, wordrecg, treetab, cgmeth, ccgutils, os, ropes, math, passes, rodread, wordrecg, treetab, cgmeth,
condsyms, rodutils, renderer, idgen, cgendata, ccgmerge, semfold, aliases, condsyms, rodutils, renderer, idgen, cgendata, ccgmerge, semfold, aliases,
lowerings, semparallel, tables, sets, ndi lowerings, semparallel, tables, sets, ndi
@ -75,12 +75,13 @@ proc isSimpleConst(typ: PType): bool =
proc useStringh(m: BModule) = proc useStringh(m: BModule) =
if includesStringh notin m.flags: if includesStringh notin m.flags:
incl m.flags, includesStringh incl m.flags, includesStringh
discard lists.includeStr(m.headerFiles, "<string.h>") m.includeHeader("<string.h>")
proc useHeader(m: BModule, sym: PSym) = proc useHeader(m: BModule, sym: PSym) =
if lfHeader in sym.loc.flags: if lfHeader in sym.loc.flags:
assert(sym.annex != nil) assert(sym.annex != nil)
discard lists.includeStr(m.headerFiles, getStr(sym.annex.path)) let str = getStr(sym.annex.path)
m.includeHeader(str)
proc cgsym(m: BModule, name: string): Rope proc cgsym(m: BModule, name: string): Rope
@ -594,15 +595,14 @@ proc cgsym(m: BModule, name: string): Rope =
proc generateHeaders(m: BModule) = proc generateHeaders(m: BModule) =
add(m.s[cfsHeaders], tnl & "#include \"nimbase.h\"" & tnl) add(m.s[cfsHeaders], tnl & "#include \"nimbase.h\"" & tnl)
var it = PStrEntry(m.headerFiles.head)
while it != nil: for it in m.headerFiles:
if it.data[0] == '#': if it[0] == '#':
add(m.s[cfsHeaders], rope(it.data.replace('`', '"') & tnl)) add(m.s[cfsHeaders], rope(it.replace('`', '"') & tnl))
elif it.data[0] notin {'\"', '<'}: elif it[0] notin {'\"', '<'}:
addf(m.s[cfsHeaders], "#include \"$1\"$N", [rope(it.data)]) addf(m.s[cfsHeaders], "#include \"$1\"$N", [rope(it)])
else: else:
addf(m.s[cfsHeaders], "#include $1$N", [rope(it.data)]) addf(m.s[cfsHeaders], "#include $1$N", [rope(it)])
it = PStrEntry(it.next)
add(m.s[cfsHeaders], "#undef linux" & tnl) add(m.s[cfsHeaders], "#undef linux" & tnl)
proc initFrame(p: BProc, procname, filename: Rope): Rope = proc initFrame(p: BProc, procname, filename: Rope): Rope =
@ -974,7 +974,7 @@ proc genMainProc(m: BModule) =
else: else:
nimMain = WinNimDllMain nimMain = WinNimDllMain
otherMain = WinCDllMain otherMain = WinCDllMain
discard lists.includeStr(m.headerFiles, "<windows.h>") m.includeHeader("<windows.h>")
elif optGenDynLib in gGlobalOptions: elif optGenDynLib in gGlobalOptions:
nimMain = PosixNimDllMain nimMain = PosixNimDllMain
otherMain = PosixCDllMain otherMain = PosixCDllMain
@ -1129,7 +1129,7 @@ proc initProcOptions(m: BModule): TOptions =
proc rawNewModule(g: BModuleList; module: PSym, filename: string): BModule = proc rawNewModule(g: BModuleList; module: PSym, filename: string): BModule =
new(result) new(result)
result.tmpBase = rope("TM" & $hashOwner(module) & "_") result.tmpBase = rope("TM" & $hashOwner(module) & "_")
initLinkedList(result.headerFiles) result.headerFiles = @[]
result.declaredThings = initIntSet() result.declaredThings = initIntSet()
result.declaredProtos = initIntSet() result.declaredProtos = initIntSet()
result.cfilename = filename result.cfilename = filename
@ -1166,7 +1166,7 @@ proc nullify[T](arr: var T) =
proc resetModule*(m: BModule) = proc resetModule*(m: BModule) =
# between two compilations in CAAS mode, we can throw # between two compilations in CAAS mode, we can throw
# away all the data that was written to disk # away all the data that was written to disk
initLinkedList(m.headerFiles) m.headerFiles = @[]
m.declaredProtos = initIntSet() m.declaredProtos = initIntSet()
m.forwTypeCache = initTable[SigHash, Rope]() m.forwTypeCache = initTable[SigHash, Rope]()
m.initProc = newProc(nil, m) m.initProc = newProc(nil, m)

View file

@ -10,7 +10,7 @@
## This module contains the data structures for the C code generation phase. ## This module contains the data structures for the C code generation phase.
import import
ast, astalgo, ropes, passes, options, intsets, lists, platform, sighashes, ast, astalgo, ropes, passes, options, intsets, platform, sighashes,
tables, ndi tables, ndi
from msgs import TLineInfo from msgs import TLineInfo
@ -130,7 +130,7 @@ type
forwTypeCache*: TypeCache # cache for forward declarations of types forwTypeCache*: TypeCache # cache for forward declarations of types
declaredThings*: IntSet # things we have declared in this .c file declaredThings*: IntSet # things we have declared in this .c file
declaredProtos*: IntSet # prototypes we have declared in this .c file declaredProtos*: IntSet # prototypes we have declared in this .c file
headerFiles*: TLinkedList # needed headers to include headerFiles*: seq[string] # needed headers to include
typeInfoMarker*: TypeCache # needed for generating type information typeInfoMarker*: TypeCache # needed for generating type information
initProc*: BProc # code for init procedure initProc*: BProc # code for init procedure
postInitProc*: BProc # code to be executed after the init proc postInitProc*: BProc # code to be executed after the init proc
@ -148,9 +148,13 @@ type
g*: BModuleList g*: BModuleList
ndi*: NdiFile ndi*: NdiFile
proc includeHeader*(this: BModule; header: string) =
if not this.headerFiles.contains header:
this.headerFiles.add header
proc s*(p: BProc, s: TCProcSection): var Rope {.inline.} = proc s*(p: BProc, s: TCProcSection): var Rope {.inline.} =
# section in the current block # section in the current block
result = p.blocks[p.blocks.len - 1].sections[s] result = p.blocks[^1].sections[s]
proc procSec*(p: BProc, s: TCProcSection): var Rope {.inline.} = proc procSec*(p: BProc, s: TCProcSection): var Rope {.inline.} =
# top level proc sections # top level proc sections

View file

@ -26,8 +26,8 @@ bootSwitch(usedGoGC, defined(gogc), "--gc:go")
bootSwitch(usedNoGC, defined(nogc), "--gc:none") bootSwitch(usedNoGC, defined(nogc), "--gc:none")
import import
os, msgs, options, nversion, condsyms, strutils, extccomp, platform, lists, os, msgs, options, nversion, condsyms, strutils, extccomp, platform,
wordrecg, parseutils, nimblecmd, idents, parseopt wordrecg, parseutils, nimblecmd, idents, parseopt, sequtils
# but some have deps to imported modules. Yay. # but some have deps to imported modules. Yay.
bootSwitch(usedTinyC, hasTinyCBackend, "-d:tinyc") bootSwitch(usedTinyC, hasTinyCBackend, "-d:tinyc")
@ -335,12 +335,14 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
of "excludepath": of "excludepath":
expectArg(switch, arg, pass, info) expectArg(switch, arg, pass, info)
let path = processPath(arg, info) let path = processPath(arg, info)
lists.excludePath(options.searchPaths, path)
lists.excludePath(options.lazyPaths, path) options.searchPaths.keepItIf( cmpPaths(it, path) != 0 )
options.lazyPaths.keepItIf( cmpPaths(it, path) != 0 )
if (len(path) > 0) and (path[len(path) - 1] == DirSep): if (len(path) > 0) and (path[len(path) - 1] == DirSep):
let strippedPath = path[0 .. (len(path) - 2)] let strippedPath = path[0 .. (len(path) - 2)]
lists.excludePath(options.searchPaths, strippedPath) options.searchPaths.keepItIf( cmpPaths(it, strippedPath) != 0 )
lists.excludePath(options.lazyPaths, strippedPath) options.lazyPaths.keepItIf( cmpPaths(it, strippedPath) != 0 )
of "nimcache": of "nimcache":
expectArg(switch, arg, pass, info) expectArg(switch, arg, pass, info)
options.nimcacheDir = processPath(arg, info, true) options.nimcacheDir = processPath(arg, info, true)

View file

@ -13,7 +13,7 @@
# nim files. # nim files.
import import
lists, ropes, os, strutils, osproc, platform, condsyms, options, msgs, ropes, os, strutils, osproc, platform, condsyms, options, msgs,
securehash, streams securehash, streams
#from debuginfo import writeDebugInfo #from debuginfo import writeDebugInfo
@ -390,7 +390,7 @@ type
CfileList = seq[Cfile] CfileList = seq[Cfile]
var var
externalToLink: TLinkedList # files to link in addition to the file externalToLink: seq[string] = @[] # files to link in addition to the file
# we compiled # we compiled
linkOptionsCmd: string = "" linkOptionsCmd: string = ""
compileOptionsCmd: seq[string] = @[] compileOptionsCmd: seq[string] = @[]
@ -486,11 +486,10 @@ proc resetCompilationLists* =
# when the module is loaded/unloaded it adds/removes its items # when the module is loaded/unloaded it adds/removes its items
# That's because we still need to hash check the external files # That's because we still need to hash check the external files
# Maybe we can do that in checkDep on the other hand? # Maybe we can do that in checkDep on the other hand?
initLinkedList(externalToLink) externalToLink.setLen 0
proc addExternalFileToLink*(filename: string) = proc addExternalFileToLink*(filename: string) =
prependStr(externalToLink, filename) externalToLink.insert(filename, 0)
# BUGFIX: was ``appendStr``
proc execWithEcho(cmd: string, msg = hintExecuting): int = proc execWithEcho(cmd: string, msg = hintExecuting): int =
rawMessage(msg, cmd) rawMessage(msg, cmd)
@ -527,9 +526,6 @@ proc noAbsolutePaths: bool {.inline.} =
# `optGenMapping` is included here for niminst. # `optGenMapping` is included here for niminst.
result = gGlobalOptions * {optGenScript, optGenMapping} != {} result = gGlobalOptions * {optGenScript, optGenMapping} != {}
proc add(s: var string, many: openArray[string]) =
s.add many.join
proc cFileSpecificOptions(cfilename: string): string = proc cFileSpecificOptions(cfilename: string): string =
result = compileOptions result = compileOptions
for option in compileOptionsCmd: for option in compileOptionsCmd:
@ -560,7 +556,7 @@ proc getLinkOptions: string =
for linkedLib in items(cLinkedLibs): for linkedLib in items(cLinkedLibs):
result.add(CC[cCompiler].linkLibCmd % linkedLib.quoteShell) result.add(CC[cCompiler].linkLibCmd % linkedLib.quoteShell)
for libDir in items(cLibs): for libDir in items(cLibs):
result.add([CC[cCompiler].linkDirCmd, libDir.quoteShell]) result.add(join([CC[cCompiler].linkDirCmd, libDir.quoteShell]))
proc needsExeExt(): bool {.inline.} = proc needsExeExt(): bool {.inline.} =
result = (optGenScript in gGlobalOptions and targetOS == osWindows) or result = (optGenScript in gGlobalOptions and targetOS == osWindows) or
@ -611,7 +607,7 @@ proc getCompileCFileCmd*(cfile: Cfile): string =
includeCmd = CC[c].includeCmd & quoteShell(libpath) includeCmd = CC[c].includeCmd & quoteShell(libpath)
for includeDir in items(cIncludes): for includeDir in items(cIncludes):
includeCmd.add([CC[c].includeCmd, includeDir.quoteShell]) includeCmd.add(join([CC[c].includeCmd, includeDir.quoteShell]))
compilePattern = joinPath(ccompilerpath, exe) compilePattern = joinPath(ccompilerpath, exe)
else: else:
@ -786,14 +782,12 @@ proc callCCompiler*(projectfile: string) =
rawMessage(errExecutionOfProgramFailed, cmds.join()) rawMessage(errExecutionOfProgramFailed, cmds.join())
if optNoLinking notin gGlobalOptions: if optNoLinking notin gGlobalOptions:
# call the linker: # call the linker:
var it = PStrEntry(externalToLink.head)
var objfiles = "" var objfiles = ""
while it != nil: for it in externalToLink:
let objFile = if noAbsolutePaths(): it.data.extractFilename else: it.data let objFile = if noAbsolutePaths(): it.extractFilename else: it
add(objfiles, ' ') add(objfiles, ' ')
add(objfiles, quoteShell( add(objfiles, quoteShell(
addFileExt(objFile, CC[cCompiler].objExt))) addFileExt(objFile, CC[cCompiler].objExt)))
it = PStrEntry(it.next)
for x in toCompile: for x in toCompile:
add(objfiles, ' ') add(objfiles, ' ')
add(objfiles, quoteShell(x.obj)) add(objfiles, quoteShell(x.obj))
@ -836,15 +830,14 @@ proc writeJsonBuildInstructions*(projectfile: string) =
else: else:
lit "],\L" lit "],\L"
proc linkfiles(f: File; buf, objfiles: var string; toLink: TLinkedList) = proc linkfiles(f: File; buf, objfiles: var string; toLink: seq[string]) =
var it = PStrEntry(toLink.head) for i, it in toLink:
while it != nil: let objfile = addFileExt(it, CC[cCompiler].objExt)
let objfile = addFileExt(it.data, CC[cCompiler].objExt) str(objfile)
str objfile
add(objfiles, ' ') add(objfiles, ' ')
add(objfiles, quoteShell(objfile)) add(objfiles, quoteShell(objfile))
it = PStrEntry(it.next)
if it == nil: if i == toLink.high:
lit "\L" lit "\L"
else: else:
lit ",\L" lit ",\L"

View file

@ -31,7 +31,7 @@ implements the required case distinction.
import import
ast, astalgo, strutils, hashes, trees, platform, magicsys, extccomp, options, ast, astalgo, strutils, hashes, trees, platform, magicsys, extccomp, options,
nversion, nimsets, msgs, securehash, bitsets, idents, lists, types, os, nversion, nimsets, msgs, securehash, bitsets, idents, types, os,
times, ropes, math, passes, ccgutils, wordrecg, renderer, rodread, rodutils, times, ropes, math, passes, ccgutils, wordrecg, renderer, rodread, rodutils,
intsets, cgmeth, lowerings intsets, cgmeth, lowerings

View file

@ -10,7 +10,7 @@
# This include file implements lambda lifting for the transformator. # This include file implements lambda lifting for the transformator.
import import
intsets, strutils, lists, options, ast, astalgo, trees, treetab, msgs, os, intsets, strutils, options, ast, astalgo, trees, treetab, msgs, os,
idents, renderer, types, magicsys, rodread, lowerings, tables idents, renderer, types, magicsys, rodread, lowerings, tables
discard """ discard """

View file

@ -7,113 +7,22 @@
# distribution, for details about the copyright. # distribution, for details about the copyright.
# #
# This module implements a generic doubled linked list. # This module is deprecated, don't use it.
# TODO Remove this and replace it with something sensible # TODO Remove this
import os import os
type
PListEntry* = ref TListEntry
TListEntry* = object of RootObj
prev*, next*: PListEntry
TStrEntry* = object of TListEntry static:
data*: string echo "WARNING: imported deprecated module compiler/lists.nim, use seq ore lists from the standard library"
PStrEntry* = ref TStrEntry proc appendStr*(list: var seq[string]; data: string) {.deprecated.} =
TLinkedList* = object # for the "find" operation: # just use system.add
head*, tail*: PListEntry list.add(data)
counter*: int
TCompareProc* = proc (entry: PListEntry, closure: pointer): bool {.nimcall.} proc includeStr(list: var seq[string]; data: string): bool {.deprecated.} =
if list.contains(data):
proc initLinkedList*(list: var TLinkedList) = result = true
list.counter = 0
list.head = nil
list.tail = nil
proc append*(list: var TLinkedList, entry: PListEntry) =
inc(list.counter)
entry.next = nil
entry.prev = list.tail
if list.tail != nil:
assert(list.tail.next == nil)
list.tail.next = entry
list.tail = entry
if list.head == nil: list.head = entry
proc contains*(list: TLinkedList, data: string): bool =
var it = list.head
while it != nil:
if PStrEntry(it).data == data:
return true
it = it.next
proc newStrEntry(data: string): PStrEntry =
new(result)
result.data = data
proc appendStr*(list: var TLinkedList, data: string) =
append(list, newStrEntry(data))
proc includeStr*(list: var TLinkedList, data: string): bool =
if contains(list, data): return true
appendStr(list, data) # else: add to list
proc prepend*(list: var TLinkedList, entry: PListEntry) =
inc(list.counter)
entry.prev = nil
entry.next = list.head
if list.head != nil:
assert(list.head.prev == nil)
list.head.prev = entry
list.head = entry
if list.tail == nil: list.tail = entry
proc prependStr*(list: var TLinkedList, data: string) =
prepend(list, newStrEntry(data))
proc insertBefore*(list: var TLinkedList, pos, entry: PListEntry) =
assert(pos != nil)
if pos == list.head:
prepend(list, entry)
else: else:
inc(list.counter) result = false
entry.next = pos list.add data
entry.prev = pos.prev
if pos.prev != nil: pos.prev.next = entry
pos.prev = entry
proc remove*(list: var TLinkedList, entry: PListEntry) =
dec(list.counter)
if entry == list.tail:
list.tail = entry.prev
if entry == list.head:
list.head = entry.next
if entry.next != nil: entry.next.prev = entry.prev
if entry.prev != nil: entry.prev.next = entry.next
proc bringToFront*(list: var TLinkedList, entry: PListEntry) =
when true:
list.remove entry
list.prepend entry
else:
if entry == list.head: return
if entry == list.tail: list.tail = entry.prev
if entry.next != nil: entry.next.prev = entry.prev
if entry.prev != nil: entry.prev.next = entry.next
entry.prev = nil
entry.next = list.head
list.head = entry
proc excludePath*(list: var TLinkedList, data: string) =
var it = list.head
while it != nil:
let nxt = it.next
if cmpPaths(PStrEntry(it).data, data) == 0:
remove(list, it)
it = nxt
proc find*(list: TLinkedList, fn: TCompareProc, closure: pointer): PListEntry =
result = list.head
while result != nil:
if fn(result, closure): return
result = result.next

View file

@ -15,7 +15,7 @@ import
wordrecg, sem, semdata, idents, passes, docgen, extccomp, wordrecg, sem, semdata, idents, passes, docgen, extccomp,
cgen, jsgen, json, nversion, cgen, jsgen, json, nversion,
platform, nimconf, importer, passaux, depends, vm, vmdef, types, idgen, platform, nimconf, importer, passaux, depends, vm, vmdef, types, idgen,
docgen2, service, parser, modules, ccgutils, sigmatch, ropes, lists, docgen2, service, parser, modules, ccgutils, sigmatch, ropes,
modulegraphs modulegraphs
from magicsys import systemModule, resetSysTypes from magicsys import systemModule, resetSysTypes
@ -151,7 +151,7 @@ proc mainCommand*(graph: ModuleGraph; cache: IdentCache) =
# In "nim serve" scenario, each command must reset the registered passes # In "nim serve" scenario, each command must reset the registered passes
clearPasses() clearPasses()
gLastCmdTime = epochTime() gLastCmdTime = epochTime()
appendStr(searchPaths, options.libpath) searchPaths.add(options.libpath)
when false: # gProjectFull.len != 0: when false: # gProjectFull.len != 0:
# current path is always looked first for modules # current path is always looked first for modules
prependStr(searchPaths, gProjectPath) prependStr(searchPaths, gProjectPath)
@ -229,7 +229,7 @@ proc mainCommand*(graph: ModuleGraph; cache: IdentCache) =
for s in definedSymbolNames(): definedSymbols.elems.add(%s) for s in definedSymbolNames(): definedSymbols.elems.add(%s)
var libpaths = newJArray() var libpaths = newJArray()
for dir in iterSearchPath(searchPaths): libpaths.elems.add(%dir) for dir in searchPaths: libpaths.elems.add(%dir)
var dumpdata = % [ var dumpdata = % [
(key: "version", val: %VersionAsString), (key: "version", val: %VersionAsString),
@ -245,7 +245,7 @@ proc mainCommand*(graph: ModuleGraph; cache: IdentCache) =
for s in definedSymbolNames(): msgWriteln(s, {msgStdout, msgSkipHook}) for s in definedSymbolNames(): msgWriteln(s, {msgStdout, msgSkipHook})
msgWriteln("-- end of list --", {msgStdout, msgSkipHook}) msgWriteln("-- end of list --", {msgStdout, msgSkipHook})
for it in iterSearchPath(searchPaths): msgWriteln(it) for it in searchPaths: msgWriteln(it)
of "check": of "check":
gCmd = cmdCheck gCmd = cmdCheck
commandCheck(graph, cache) commandCheck(graph, cache)

View file

@ -9,11 +9,11 @@
## Implements some helper procs for Nimble (Nim's package manager) support. ## Implements some helper procs for Nimble (Nim's package manager) support.
import parseutils, strutils, strtabs, os, options, msgs, lists import parseutils, strutils, strtabs, os, options, msgs
proc addPath*(path: string, info: TLineInfo) = proc addPath*(path: string, info: TLineInfo) =
if not contains(options.searchPaths, path): if not options.searchPaths.contains(path):
lists.prependStr(options.searchPaths, path) options.searchPaths.insert(path, 0)
proc versionSplitPos(s: string): int = proc versionSplitPos(s: string): int =
result = s.len-2 result = s.len-2
@ -61,7 +61,7 @@ iterator chosen(packages: StringTableRef): string =
proc addNimblePath(p: string, info: TLineInfo) = proc addNimblePath(p: string, info: TLineInfo) =
if not contains(options.searchPaths, p): if not contains(options.searchPaths, p):
message(info, hintPath, p) message(info, hintPath, p)
lists.prependStr(options.lazyPaths, p) options.lazyPaths.insert(p, 0)
proc addPathRec(dir: string, info: TLineInfo) = proc addPathRec(dir: string, info: TLineInfo) =
var packages = newStringTable(modeStyleInsensitive) var packages = newStringTable(modeStyleInsensitive)

View file

@ -10,7 +10,7 @@
## exposes the Nim VM to clients. ## exposes the Nim VM to clients.
import import
ast, modules, passes, passaux, condsyms, ast, modules, passes, passaux, condsyms,
options, nimconf, lists, sem, semdata, llstream, vm, modulegraphs, idents options, nimconf, sem, semdata, llstream, vm, modulegraphs, idents
proc execute*(program: string) = proc execute*(program: string) =
passes.gIncludeFile = includeModule passes.gIncludeFile = includeModule
@ -25,7 +25,7 @@ proc execute*(program: string) =
registerPass(semPass) registerPass(semPass)
registerPass(evalPass) registerPass(evalPass)
appendStr(searchPaths, options.libpath) searchPaths.add options.libpath
var graph = newModuleGraph() var graph = newModuleGraph()
var cache = newIdentCache() var cache = newIdentCache()
var m = makeStdinModule(graph) var m = makeStdinModule(graph)

View file

@ -13,7 +13,7 @@ import strutils, os, parseopt
import compiler/[options, commands, modules, sem, import compiler/[options, commands, modules, sem,
passes, passaux, nimfix/pretty, passes, passaux, nimfix/pretty,
msgs, nimconf, msgs, nimconf,
extccomp, condsyms, lists, extccomp, condsyms,
modulegraphs, idents] modulegraphs, idents]
const Usage = """ const Usage = """
@ -39,10 +39,10 @@ proc mainCommand =
registerPass verbosePass registerPass verbosePass
registerPass semPass registerPass semPass
gCmd = cmdPretty gCmd = cmdPretty
appendStr(searchPaths, options.libpath) searchPaths.add options.libpath
if gProjectFull.len != 0: if gProjectFull.len != 0:
# current path is always looked first for modules # current path is always looked first for modules
prependStr(searchPaths, gProjectPath) searchPaths.insert(gProjectPath, 0)
compileProject(newModuleGraph(), newIdentCache()) compileProject(newModuleGraph(), newIdentCache())
pretty.overwriteFiles() pretty.overwriteFiles()

View file

@ -8,7 +8,7 @@
# #
import import
os, lists, strutils, strtabs, osproc, sets os, strutils, strtabs, osproc, sets
const const
hasTinyCBackend* = defined(tinyc) hasTinyCBackend* = defined(tinyc)
@ -129,7 +129,8 @@ var
gExitcode*: int8 gExitcode*: int8
gCmd*: TCommands = cmdNone # the command gCmd*: TCommands = cmdNone # the command
gSelectedGC* = gcRefc # the selected GC gSelectedGC* = gcRefc # the selected GC
searchPaths*, lazyPaths*: TLinkedList searchPaths*: seq[string] = @[]
lazyPaths*: seq[string] = @[]
outFile*: string = "" outFile*: string = ""
docSeeSrcUrl*: string = "" # if empty, no seeSrc will be generated. \ docSeeSrcUrl*: string = "" # if empty, no seeSrc will be generated. \
# The string uses the formatting variables `path` and `line`. # The string uses the formatting variables `path` and `line`.
@ -267,9 +268,7 @@ proc removeTrailingDirSep*(path: string): string =
proc disableNimblePath*() = proc disableNimblePath*() =
gNoNimblePath = true gNoNimblePath = true
lazyPaths.head = nil lazyPaths.setLen(0)
lazyPaths.tail = nil
lazyPaths.counter = 0
include packagehandling include packagehandling
@ -336,27 +335,22 @@ proc completeGeneratedFilePath*(f: string, createSubDir: bool = true): string =
result = joinPath(subdir, tail) result = joinPath(subdir, tail)
#echo "completeGeneratedFilePath(", f, ") = ", result #echo "completeGeneratedFilePath(", f, ") = ", result
iterator iterSearchPath*(searchPaths: TLinkedList): string =
var it = PStrEntry(searchPaths.head)
while it != nil:
yield it.data
it = PStrEntry(it.next)
proc rawFindFile(f: string): string = proc rawFindFile(f: string): string =
for it in iterSearchPath(searchPaths): for it in searchPaths:
result = joinPath(it, f) result = joinPath(it, f)
if existsFile(result): if existsFile(result):
return result.canonicalizePath return result.canonicalizePath
result = "" result = ""
proc rawFindFile2(f: string): string = proc rawFindFile2(f: string): string =
var it = PStrEntry(lazyPaths.head) for i, it in lazyPaths:
while it != nil: result = joinPath(it, f)
result = joinPath(it.data, f)
if existsFile(result): if existsFile(result):
bringToFront(lazyPaths, it) # bring to front
for j in countDown(i,1):
swap(lazyPaths[j], lazyPaths[j-1])
return result.canonicalizePath return result.canonicalizePath
it = PStrEntry(it.next)
result = "" result = ""
template patchModule() {.dirty.} = template patchModule() {.dirty.} =

View file

@ -11,7 +11,7 @@
# `TPass` interface. # `TPass` interface.
import import
strutils, lists, options, ast, astalgo, llstream, msgs, platform, os, strutils, options, ast, astalgo, llstream, msgs, platform, os,
condsyms, idents, renderer, types, extccomp, math, magicsys, nversion, condsyms, idents, renderer, types, extccomp, math, magicsys, nversion,
nimsets, syntaxes, times, rodread, idgen, modulegraphs nimsets, syntaxes, times, rodread, idgen, modulegraphs

View file

@ -11,7 +11,7 @@
import import
os, platform, condsyms, ast, astalgo, idents, semdata, msgs, renderer, os, platform, condsyms, ast, astalgo, idents, semdata, msgs, renderer,
wordrecg, ropes, options, strutils, lists, extccomp, math, magicsys, trees, wordrecg, ropes, options, strutils, extccomp, math, magicsys, trees,
rodread, types, lookups rodread, types, lookups
const const
@ -218,20 +218,19 @@ proc processCallConv(c: PContext, n: PNode) =
var sw = whichKeyword(n.sons[1].ident) var sw = whichKeyword(n.sons[1].ident)
case sw case sw
of FirstCallConv..LastCallConv: of FirstCallConv..LastCallConv:
POptionEntry(c.optionStack.tail).defaultCC = wordToCallConv(sw) c.optionStack[^1].defaultCC = wordToCallConv(sw)
else: localError(n.info, errCallConvExpected) else: localError(n.info, errCallConvExpected)
else: else:
localError(n.info, errCallConvExpected) localError(n.info, errCallConvExpected)
proc getLib(c: PContext, kind: TLibKind, path: PNode): PLib = proc getLib(c: PContext, kind: TLibKind, path: PNode): PLib =
var it = PLib(c.libs.head) for it in c.libs:
while it != nil: if it.kind == kind and trees.exprStructuralEquivalent(it.path, path):
if it.kind == kind: return it
if trees.exprStructuralEquivalent(it.path, path): return it
it = PLib(it.next)
result = newLib(kind) result = newLib(kind)
result.path = path result.path = path
append(c.libs, result) c.libs.add result
if path.kind in {nkStrLit..nkTripleStrLit}: if path.kind in {nkStrLit..nkTripleStrLit}:
result.isOverriden = options.isDynlibOverride(path.strVal) result.isOverriden = options.isDynlibOverride(path.strVal)
@ -254,7 +253,7 @@ proc processDynLib(c: PContext, n: PNode, sym: PSym) =
if (sym == nil) or (sym.kind == skModule): if (sym == nil) or (sym.kind == skModule):
let lib = getLib(c, libDynamic, expectDynlibNode(c, n)) let lib = getLib(c, libDynamic, expectDynlibNode(c, n))
if not lib.isOverriden: if not lib.isOverriden:
POptionEntry(c.optionStack.tail).dynlib = lib c.optionStack[^1].dynlib = lib
else: else:
if n.kind == nkExprColonExpr: if n.kind == nkExprColonExpr:
var lib = getLib(c, libDynamic, expectDynlibNode(c, n)) var lib = getLib(c, libDynamic, expectDynlibNode(c, n))
@ -350,12 +349,12 @@ proc processPush(c: PContext, n: PNode, start: int) =
if n.sons[start-1].kind == nkExprColonExpr: if n.sons[start-1].kind == nkExprColonExpr:
localError(n.info, errGenerated, "':' after 'push' not supported") localError(n.info, errGenerated, "':' after 'push' not supported")
var x = newOptionEntry() var x = newOptionEntry()
var y = POptionEntry(c.optionStack.tail) var y = c.optionStack[^1]
x.options = gOptions x.options = gOptions
x.defaultCC = y.defaultCC x.defaultCC = y.defaultCC
x.dynlib = y.dynlib x.dynlib = y.dynlib
x.notes = gNotes x.notes = gNotes
append(c.optionStack, x) c.optionStack.add(x)
for i in countup(start, sonsLen(n) - 1): for i in countup(start, sonsLen(n) - 1):
if processOption(c, n.sons[i]): if processOption(c, n.sons[i]):
# simply store it somewhere: # simply store it somewhere:
@ -365,12 +364,12 @@ proc processPush(c: PContext, n: PNode, start: int) =
#localError(n.info, errOptionExpected) #localError(n.info, errOptionExpected)
proc processPop(c: PContext, n: PNode) = proc processPop(c: PContext, n: PNode) =
if c.optionStack.counter <= 1: if c.optionStack.len <= 1:
localError(n.info, errAtPopWithoutPush) localError(n.info, errAtPopWithoutPush)
else: else:
gOptions = POptionEntry(c.optionStack.tail).options gOptions = c.optionStack[^1].options
gNotes = POptionEntry(c.optionStack.tail).notes gNotes = c.optionStack[^1].notes
remove(c.optionStack, c.optionStack.tail) c.optionStack.setLen(c.optionStack.len - 1)
proc processDefine(c: PContext, n: PNode) = proc processDefine(c: PContext, n: PNode) =
if (n.kind == nkExprColonExpr) and (n.sons[1].kind == nkIdent): if (n.kind == nkExprColonExpr) and (n.sons[1].kind == nkIdent):
@ -977,8 +976,7 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: int,
proc implicitPragmas*(c: PContext, sym: PSym, n: PNode, proc implicitPragmas*(c: PContext, sym: PSym, n: PNode,
validPragmas: TSpecialWords) = validPragmas: TSpecialWords) =
if sym != nil and sym.kind != skModule: if sym != nil and sym.kind != skModule:
var it = POptionEntry(c.optionStack.head) for it in c.optionStack:
while it != nil:
let o = it.otherPragmas let o = it.otherPragmas
if not o.isNil: if not o.isNil:
pushInfoContext(n.info) pushInfoContext(n.info)
@ -986,11 +984,10 @@ proc implicitPragmas*(c: PContext, sym: PSym, n: PNode,
if singlePragma(c, sym, o, i, validPragmas): if singlePragma(c, sym, o, i, validPragmas):
internalError(n.info, "implicitPragmas") internalError(n.info, "implicitPragmas")
popInfoContext() popInfoContext()
it = it.next.POptionEntry
if lfExportLib in sym.loc.flags and sfExportc notin sym.flags: if lfExportLib in sym.loc.flags and sfExportc notin sym.flags:
localError(n.info, errDynlibRequiresExportc) localError(n.info, errDynlibRequiresExportc)
var lib = POptionEntry(c.optionStack.tail).dynlib var lib = c.optionStack[^1].dynlib
if {lfDynamicLib, lfHeader} * sym.loc.flags == {} and if {lfDynamicLib, lfHeader} * sym.loc.flags == {} and
sfImportc in sym.flags and lib != nil: sfImportc in sym.flags and lib != nil:
incl(sym.loc.flags, lfDynamicLib) incl(sym.loc.flags, lfDynamicLib)

View file

@ -10,7 +10,7 @@
# This module implements the renderer of the standard Nim representation. # This module implements the renderer of the standard Nim representation.
import import
lexer, options, idents, strutils, ast, msgs, lists lexer, options, idents, strutils, ast, msgs
type type
TRenderFlag* = enum TRenderFlag* = enum

View file

@ -12,7 +12,7 @@
import import
ast, modules, idents, passes, passaux, condsyms, ast, modules, idents, passes, passaux, condsyms,
options, nimconf, lists, sem, semdata, llstream, vm, vmdef, commands, msgs, options, nimconf, sem, semdata, llstream, vm, vmdef, commands, msgs,
os, times, osproc, wordrecg, strtabs, modulegraphs os, times, osproc, wordrecg, strtabs, modulegraphs
# we support 'cmpIgnoreStyle' natively for efficiency: # we support 'cmpIgnoreStyle' natively for efficiency:
@ -153,7 +153,7 @@ proc runNimScript*(cache: IdentCache; scriptName: string;
registerPass(semPass) registerPass(semPass)
registerPass(evalPass) registerPass(evalPass)
appendStr(searchPaths, options.libpath) searchPaths.add(options.libpath)
var m = graph.makeModule(scriptName) var m = graph.makeModule(scriptName)
incl(m.flags, sfMainModule) incl(m.flags, sfMainModule)

View file

@ -10,7 +10,7 @@
# This module implements the semantic checking pass. # This module implements the semantic checking pass.
import import
ast, strutils, hashes, lists, options, lexer, astalgo, trees, treetab, ast, strutils, hashes, options, lexer, astalgo, trees, treetab,
wordrecg, ropes, msgs, os, condsyms, idents, renderer, types, platform, math, wordrecg, ropes, msgs, os, condsyms, idents, renderer, types, platform, math,
magicsys, parser, nversion, nimsets, semfold, importer, magicsys, parser, nversion, nimsets, semfold, importer,
procfind, lookups, rodread, pragmas, passes, semdata, semtypinst, sigmatch, procfind, lookups, rodread, pragmas, passes, semdata, semtypinst, sigmatch,

View file

@ -10,15 +10,14 @@
## This module contains the data structures for the semantic checking phase. ## This module contains the data structures for the semantic checking phase.
import import
strutils, lists, intsets, options, lexer, ast, astalgo, trees, treetab, strutils, intsets, options, lexer, ast, astalgo, trees, treetab,
wordrecg, wordrecg,
ropes, msgs, platform, os, condsyms, idents, renderer, types, extccomp, math, ropes, msgs, platform, os, condsyms, idents, renderer, types, extccomp, math,
magicsys, nversion, nimsets, parser, times, passes, rodread, vmdef, magicsys, nversion, nimsets, parser, times, passes, rodread, vmdef,
modulegraphs modulegraphs
type type
TOptionEntry* = object of lists.TListEntry # entries to put on a TOptionEntry* = object # entries to put on a stack for pragma parsing
# stack for pragma parsing
options*: TOptions options*: TOptions
defaultCC*: TCallingConvention defaultCC*: TCallingConvention
dynlib*: PLib dynlib*: PLib
@ -79,10 +78,10 @@ type
inGenericInst*: int # > 0 if we are instantiating a generic inGenericInst*: int # > 0 if we are instantiating a generic
converters*: TSymSeq # sequence of converters converters*: TSymSeq # sequence of converters
patterns*: TSymSeq # sequence of pattern matchers patterns*: TSymSeq # sequence of pattern matchers
optionStack*: TLinkedList optionStack*: seq[POptionEntry]
symMapping*: TIdTable # every gensym'ed symbol needs to be mapped symMapping*: TIdTable # every gensym'ed symbol needs to be mapped
# to some new symbol in a generic instantiation # to some new symbol in a generic instantiation
libs*: TLinkedList # all libs used by this module libs*: seq[PLib] # all libs used by this module
semConstExpr*: proc (c: PContext, n: PNode): PNode {.nimcall.} # for the pragmas semConstExpr*: proc (c: PContext, n: PNode): PNode {.nimcall.} # for the pragmas
semExpr*: proc (c: PContext, n: PNode, flags: TExprFlags = {}): PNode {.nimcall.} semExpr*: proc (c: PContext, n: PNode, flags: TExprFlags = {}): PNode {.nimcall.}
semTryExpr*: proc (c: PContext, n: PNode,flags: TExprFlags = {}): PNode {.nimcall.} semTryExpr*: proc (c: PContext, n: PNode,flags: TExprFlags = {}): PNode {.nimcall.}
@ -130,7 +129,6 @@ proc getCurrOwner*(c: PContext): PSym =
# owner field of syms) # owner field of syms)
# the documentation comment always gets # the documentation comment always gets
# assigned to the current owner # assigned to the current owner
# BUGFIX: global array is needed!
result = c.graph.owners[^1] result = c.graph.owners[^1]
proc pushOwner*(c: PContext; owner: PSym) = proc pushOwner*(c: PContext; owner: PSym) =
@ -142,7 +140,7 @@ proc popOwner*(c: PContext) =
else: internalError("popOwner") else: internalError("popOwner")
proc lastOptionEntry*(c: PContext): POptionEntry = proc lastOptionEntry*(c: PContext): POptionEntry =
result = POptionEntry(c.optionStack.tail) result = c.optionStack[^1]
proc popProcCon*(c: PContext) {.inline.} = c.p = c.p.next proc popProcCon*(c: PContext) {.inline.} = c.p = c.p.next
@ -185,9 +183,9 @@ proc newOptionEntry*(): POptionEntry =
proc newContext*(graph: ModuleGraph; module: PSym; cache: IdentCache): PContext = proc newContext*(graph: ModuleGraph; module: PSym; cache: IdentCache): PContext =
new(result) new(result)
result.ambiguousSymbols = initIntSet() result.ambiguousSymbols = initIntSet()
initLinkedList(result.optionStack) result.optionStack = @[]
initLinkedList(result.libs) result.libs = @[]
append(result.optionStack, newOptionEntry()) result.optionStack.add(newOptionEntry())
result.module = module result.module = module
result.friendModules = @[module] result.friendModules = @[module]
result.converters = @[] result.converters = @[]

View file

@ -11,7 +11,7 @@
# and evaluation phase # and evaluation phase
import import
strutils, lists, options, ast, astalgo, trees, treetab, nimsets, times, strutils, options, ast, astalgo, trees, treetab, nimsets, times,
nversion, platform, math, msgs, os, condsyms, idents, renderer, types, nversion, platform, math, msgs, os, condsyms, idents, renderer, types,
commands, magicsys, saturate commands, magicsys, saturate

View file

@ -174,7 +174,11 @@ proc semGenericStmt(c: PContext, n: PNode,
# XXX for example: ``result.add`` -- ``add`` needs to be looked up here... # XXX for example: ``result.add`` -- ``add`` needs to be looked up here...
var dummy: bool var dummy: bool
result = fuzzyLookup(c, n, flags, ctx, dummy) result = fuzzyLookup(c, n, flags, ctx, dummy)
of nkEmpty, nkSym..nkNilLit: of nkSym:
let a = n.sym
let b = getGenSym(c, a)
if b != a: n.sym = b
of nkEmpty, succ(nkSym)..nkNilLit:
# see tests/compile/tgensymgeneric.nim: # see tests/compile/tgensymgeneric.nim:
# We need to open the gensym'ed symbol again so that the instantiation # We need to open the gensym'ed symbol again so that the instantiation
# creates a fresh copy; but this is wrong the very first reason for gensym # creates a fresh copy; but this is wrong the very first reason for gensym

View file

@ -30,6 +30,7 @@ proc semBreakOrContinue(c: PContext, n: PNode): PNode =
of nkIdent: s = lookUp(c, n.sons[0]) of nkIdent: s = lookUp(c, n.sons[0])
of nkSym: s = n.sons[0].sym of nkSym: s = n.sons[0].sym
else: illFormedAst(n) else: illFormedAst(n)
s = getGenSym(c, s)
if s.kind == skLabel and s.owner.id == c.p.owner.id: if s.kind == skLabel and s.owner.id == c.p.owner.id:
var x = newSymNode(s) var x = newSymNode(s)
x.info = n.info x.info = n.info

View file

@ -384,6 +384,8 @@ proc semTemplBody(c: var TemplCtx, n: PNode): PNode =
checkSonsLen(n, 2) checkSonsLen(n, 2)
openScope(c) openScope(c)
if n.sons[0].kind != nkEmpty: if n.sons[0].kind != nkEmpty:
addLocalDecl(c, n.sons[0], skLabel)
when false:
# labels are always 'gensym'ed: # labels are always 'gensym'ed:
let s = newGenSym(skLabel, n.sons[0], c) let s = newGenSym(skLabel, n.sons[0], c)
addPrelimDecl(c.c, s) addPrelimDecl(c.c, s)

View file

@ -19,7 +19,7 @@
# * transforms 'defer' into a 'try finally' statement # * transforms 'defer' into a 'try finally' statement
import import
intsets, strutils, lists, options, ast, astalgo, trees, treetab, msgs, os, intsets, strutils, options, ast, astalgo, trees, treetab, msgs, os,
idents, renderer, types, passes, semfold, magicsys, cgmeth, rodread, idents, renderer, types, passes, semfold, magicsys, cgmeth, rodread,
lambdalifting, sempass2, lowerings, lookups lambdalifting, sempass2, lowerings, lookups

View file

@ -742,6 +742,8 @@ proc `$`*(node: NimNode): string {.compileTime.} =
result = $node.symbol result = $node.symbol
of nnkOpenSymChoice, nnkClosedSymChoice: of nnkOpenSymChoice, nnkClosedSymChoice:
result = $node[0] result = $node[0]
of nnkAccQuoted:
result = $node[0]
else: else:
badNodeKind node.kind, "$" badNodeKind node.kind, "$"

View file

@ -0,0 +1,14 @@
template makeDomElement(x: untyped, name: string = nil) =
const tag {.gensym.} = if name == nil: astToStr(x) else: name
proc x*(p: int|float) =
echo tag, p
proc x*(p: string|cstring) =
echo tag, p
#proc wrappedUp[T](x: T) =
# mixin foo, bar
makeDomElement(foo, "foo")
makeDomElement(bar)

View file

@ -0,0 +1,14 @@
discard """
output: '''foo55
foo8.0
fooaha
bar7'''
"""
# bug #5419
import mgensym_generic_cross_module
foo(55)
foo 8.0
foo "aha"
bar 7

View file

@ -0,0 +1,18 @@
# bug #5417
import macros
macro genBody: untyped =
let sbx = genSym(nskLabel, "test")
when true:
result = quote do:
block `sbx`:
break `sbx`
else:
template foo(s1, s2) =
block s1:
break s2
result = getAst foo(sbx, sbx)
proc test() =
genBody()

View file

@ -15,7 +15,7 @@ import strutils, os, parseopt, parseutils, sequtils, net, rdstdin, sexp
# So we import that one instead. # So we import that one instead.
import compiler / [options, commands, modules, sem, import compiler / [options, commands, modules, sem,
passes, passaux, msgs, nimconf, passes, passaux, msgs, nimconf,
extccomp, condsyms, lists, extccomp, condsyms,
sigmatch, ast, scriptconfig, sigmatch, ast, scriptconfig,
idents, modulegraphs, compilerlog, vm] idents, modulegraphs, compilerlog, vm]
@ -427,10 +427,8 @@ proc recompileFullProject(graph: ModuleGraph; cache: IdentCache) =
proc mainThread(graph: ModuleGraph; cache: IdentCache) = proc mainThread(graph: ModuleGraph; cache: IdentCache) =
if gLogging: if gLogging:
var it = searchPaths.head for it in searchPaths:
while it != nil: logStr(it)
logStr(PStrEntry(it).data)
it = it.next
proc wrHook(line: string) {.closure.} = proc wrHook(line: string) {.closure.} =
if gMode == mepc: if gMode == mepc:
@ -503,10 +501,8 @@ proc serveEpc(server: Socket; graph: ModuleGraph; cache: IdentCache) {.deprecate
# Wait for connection # Wait for connection
accept(server, client) accept(server, client)
if gLogging: if gLogging:
var it = searchPaths.head for it in searchPaths:
while it != nil: logStr(it)
logStr(PStrEntry(it).data)
it = it.next
msgs.writelnHook = proc (line: string) = logStr(line) msgs.writelnHook = proc (line: string) = logStr(line)
while true: while true:
@ -559,7 +555,7 @@ proc mainCommand(graph: ModuleGraph; cache: IdentCache) =
incl gGlobalOptions, optCaasEnabled incl gGlobalOptions, optCaasEnabled
isServing = true isServing = true
wantMainModule() wantMainModule()
appendStr(searchPaths, options.libpath) add(searchPaths, options.libpath)
#if gProjectFull.len != 0: #if gProjectFull.len != 0:
# current path is always looked first for modules # current path is always looked first for modules
# prependStr(searchPaths, gProjectPath) # prependStr(searchPaths, gProjectPath)