diff options
author | Araq <rumpf_a@web.de> | 2016-12-01 10:06:41 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2016-12-01 10:06:41 +0100 |
commit | 2eee15d7f36bc06187d347900fdd0bf78f461f5c (patch) | |
tree | fdd3b0f4d659589323db7fe787123d9ab6780b80 /compiler | |
parent | a1737030156283e64c6cf0d7ef7468762aaee203 (diff) | |
parent | de844c7767fa341c96c38e279f064a0e7f4db641 (diff) | |
download | Nim-2eee15d7f36bc06187d347900fdd0bf78f461f5c.tar.gz |
Merge branch 'devel' into sighashes
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/ccgexprs.nim | 7 | ||||
-rw-r--r-- | compiler/ccgmerge.nim | 2 | ||||
-rw-r--r-- | compiler/ccgtypes.nim | 3 | ||||
-rw-r--r-- | compiler/cgen.nim | 1 | ||||
-rw-r--r-- | compiler/cgendata.nim | 2 | ||||
-rw-r--r-- | compiler/commands.nim | 2 | ||||
-rw-r--r-- | compiler/docgen.nim | 6 | ||||
-rw-r--r-- | compiler/extccomp.nim | 2 | ||||
-rw-r--r-- | compiler/lambdalifting.nim | 33 | ||||
-rw-r--r-- | compiler/lowerings.nim | 4 | ||||
-rw-r--r-- | compiler/nim.cfg | 2 | ||||
-rw-r--r-- | compiler/options.nim | 23 | ||||
-rw-r--r-- | compiler/pragmas.nim | 1 | ||||
-rw-r--r-- | compiler/semexprs.nim | 3 |
14 files changed, 52 insertions, 39 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index fc6b33e4b..4fef41228 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -1147,8 +1147,8 @@ proc handleConstExpr(p: BProc, n: PNode, d: var TLoc): bool = result = false proc genObjConstr(p: BProc, e: PNode, d: var TLoc) = - if handleConstExpr(p, e, d): return #echo rendertree e, " ", e.isDeepConstExpr + if handleConstExpr(p, e, d): return var tmp: TLoc var t = e.typ.skipTypes(abstractInst) getTemp(p, t, tmp) @@ -2148,6 +2148,11 @@ proc genNamedConstExpr(p: BProc, n: PNode): Rope = proc genConstSimpleList(p: BProc, n: PNode): Rope = var length = sonsLen(n) result = rope("{") + let t = n.typ.skipTypes(abstractInst) + if n.kind == nkObjConstr and not isObjLackingTypeField(t) and + not p.module.compileToCpp: + addf(result, "{$1}", [genTypeInfo(p.module, t)]) + if n.len > 1: add(result, ",") for i in countup(ord(n.kind == nkObjConstr), length - 2): addf(result, "$1,$n", [genNamedConstExpr(p, n.sons[i])]) if length > ord(n.kind == nkObjConstr): diff --git a/compiler/ccgmerge.nim b/compiler/ccgmerge.nim index 46982d0a2..58a03ecd2 100644 --- a/compiler/ccgmerge.nim +++ b/compiler/ccgmerge.nim @@ -27,8 +27,8 @@ const cfsFieldInfo: "NIM_merge_FIELD_INFO", cfsTypeInfo: "NIM_merge_TYPE_INFO", cfsProcHeaders: "NIM_merge_PROC_HEADERS", - cfsData: "NIM_merge_DATA", cfsVars: "NIM_merge_VARS", + cfsData: "NIM_merge_DATA", cfsProcs: "NIM_merge_PROCS", cfsInitProc: "NIM_merge_INIT_PROC", cfsTypeInit1: "NIM_merge_TYPE_INIT1", diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 0ed1ee847..cf1a96bf2 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -857,7 +857,8 @@ proc genTypeInfoAuxBase(m: BModule; typ, origType: PType; name, base: Rope) = if flags != 0: addf(m.s[cfsTypeInit3], "$1.flags = $2;$n", [name, rope(flags)]) if isDefined("nimTypeNames"): - addf(m.s[cfsTypeInit3], "$1.name = $2;$n", [name, makeCstring typeToString origType]) + addf(m.s[cfsTypeInit3], "$1.name = $2;$n", + [name, makeCstring typeToString(origType, preferName)]) discard cgsym(m, "TNimType") addf(m.s[cfsVars], "TNimType $1; /* $2 */$n", [name, rope(typeToString(typ))]) diff --git a/compiler/cgen.nim b/compiler/cgen.nim index db7070941..259bfc9c7 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -17,6 +17,7 @@ import lowerings, semparallel, tables from modulegraphs import ModuleGraph +from dynlib import libCandidates import strutils except `%` # collides with ropes.`%` diff --git a/compiler/cgendata.nim b/compiler/cgendata.nim index c8146fc5f..230ab7b48 100644 --- a/compiler/cgendata.nim +++ b/compiler/cgendata.nim @@ -28,8 +28,8 @@ type cfsFieldInfo, # section for field information cfsTypeInfo, # section for type information cfsProcHeaders, # section for C procs prototypes - cfsData, # section for C constant data cfsVars, # section for C variable declarations + cfsData, # section for C constant data cfsProcs, # section for C procs that are not inline cfsInitProc, # section for the C init proc cfsTypeInit1, # section 1 for declarations of type information diff --git a/compiler/commands.nim b/compiler/commands.nim index 590c4871d..f85e53511 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -226,6 +226,8 @@ proc testCompileOptionArg*(switch, arg: string, info: TLineInfo): bool = of "staticlib": result = contains(gGlobalOptions, optGenStaticLib) and not contains(gGlobalOptions, optGenGuiApp) else: localError(info, errGuiConsoleOrLibExpectedButXFound, arg) + of "dynliboverride": + result = isDynlibOverride(arg) else: invalidCmdLineOption(passCmd1, switch, info) proc testCompileOption*(switch: string, info: TLineInfo): bool = diff --git a/compiler/docgen.nim b/compiler/docgen.nim index 76b36d796..211544924 100644 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -13,8 +13,10 @@ import ast, strutils, strtabs, options, msgs, os, ropes, idents, - wordrecg, syntaxes, renderer, lexer, rstast, rst, rstgen, times, highlite, - importer, sempass2, json, xmltree, cgi, typesrenderer, astalgo + wordrecg, syntaxes, renderer, lexer, packages/docutils/rstast, + packages/docutils/rst, packages/docutils/rstgen, times, + packages/docutils/highlite, importer, sempass2, json, xmltree, cgi, + typesrenderer, astalgo type TSections = array[TSymKind, Rope] diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index 4eb68a771..7707cd31d 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -34,7 +34,7 @@ type TInfoCCProps* = set[TInfoCCProp] TInfoCC* = tuple[ name: string, # the short name of the compiler - objExt: string, # the compiler's object file extenstion + objExt: string, # the compiler's object file extension optSpeed: string, # the options for optimization for speed optSize: string, # the options for optimization for size compilerExe: string, # the compiler's executable diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim index 36ad2e0a6..692d9265b 100644 --- a/compiler/lambdalifting.nim +++ b/compiler/lambdalifting.nim @@ -139,10 +139,10 @@ proc createStateField(iter: PSym): PSym = result = newSym(skField, getIdent(":state"), iter, iter.info) result.typ = createStateType(iter) -proc createEnvObj(owner: PSym): PType = +proc createEnvObj(owner: PSym; info: TLineInfo): PType = # YYY meh, just add the state field for every closure for now, it's too # hard to figure out if it comes from a closure iterator: - result = createObj(owner, owner.info) + result = createObj(owner, info) rawAddField(result, createStateField(owner)) proc getIterResult(iter: PSym): PSym = @@ -296,18 +296,19 @@ This is why need to store the 'ownerToType' table and use it during .closure'fication. """ -proc getEnvTypeForOwner(c: var DetectionPass; owner: PSym): PType = +proc getEnvTypeForOwner(c: var DetectionPass; owner: PSym; + info: TLineInfo): PType = result = c.ownerToType.getOrDefault(owner.id) if result.isNil: result = newType(tyRef, owner) - let obj = createEnvObj(owner) + let obj = createEnvObj(owner, info) rawAddSon(result, obj) c.ownerToType[owner.id] = result -proc createUpField(c: var DetectionPass; dest, dep: PSym) = - let refObj = c.getEnvTypeForOwner(dest) # getHiddenParam(dest).typ +proc createUpField(c: var DetectionPass; dest, dep: PSym; info: TLineInfo) = + let refObj = c.getEnvTypeForOwner(dest, info) # getHiddenParam(dest).typ let obj = refObj.lastSon - let fieldType = c.getEnvTypeForOwner(dep) #getHiddenParam(dep).typ + let fieldType = c.getEnvTypeForOwner(dep, info) #getHiddenParam(dep).typ if refObj == fieldType: localError(dep.info, "internal error: invalid up reference computed") @@ -347,10 +348,10 @@ Consider: """ -proc addClosureParam(c: var DetectionPass; fn: PSym) = +proc addClosureParam(c: var DetectionPass; fn: PSym; info: TLineInfo) = var cp = getEnvParam(fn) let owner = if fn.kind == skIterator: fn else: fn.skipGenericOwner - let t = c.getEnvTypeForOwner(owner) + let t = c.getEnvTypeForOwner(owner, info) if cp == nil: cp = newSym(skParam, getIdent(paramName), fn, fn.info) incl(cp.flags, sfFromGeneric) @@ -367,7 +368,7 @@ proc detectCapturedVars(n: PNode; owner: PSym; c: var DetectionPass) = if s.kind in {skProc, skMethod, skConverter, skIterator} and s.typ != nil and s.typ.callConv == ccClosure: # this handles the case that the inner proc was declared as # .closure but does not actually capture anything: - addClosureParam(c, s) + addClosureParam(c, s, n.info) c.somethingToDo = true let innerProc = isInnerProc(s) @@ -379,7 +380,7 @@ proc detectCapturedVars(n: PNode; owner: PSym; c: var DetectionPass) = if ow == owner: if owner.isIterator: c.somethingToDo = true - addClosureParam(c, owner) + addClosureParam(c, owner, n.info) if interestingIterVar(s): if not c.capturedVars.containsOrIncl(s.id): let obj = getHiddenParam(owner).typ.lastSon @@ -403,11 +404,11 @@ proc detectCapturedVars(n: PNode; owner: PSym; c: var DetectionPass) = # mark 'owner' as taking a closure: c.somethingToDo = true markAsClosure(owner, n) - addClosureParam(c, owner) + addClosureParam(c, owner, n.info) #echo "capturing ", n.info # variable 's' is actually captured: if interestingVar(s) and not c.capturedVars.containsOrIncl(s.id): - let obj = c.getEnvTypeForOwner(ow).lastSon + let obj = c.getEnvTypeForOwner(ow, n.info).lastSon #getHiddenParam(owner).typ.lastSon addField(obj, s) # create required upFields: @@ -428,8 +429,8 @@ proc detectCapturedVars(n: PNode; owner: PSym; c: var DetectionPass) = let up = w.skipGenericOwner #echo "up for ", w.name.s, " up ", up.name.s markAsClosure(w, n) - addClosureParam(c, w) # , ow - createUpField(c, w, up) + addClosureParam(c, w, n.info) # , ow + createUpField(c, w, up, n.info) w = up of nkEmpty..pred(nkSym), succ(nkSym)..nkNilLit, nkTemplateDef, nkTypeSection: @@ -793,7 +794,7 @@ proc liftLambdas*(fn: PSym, body: PNode; tooEarly: var bool): PNode = var d = initDetectionPass(fn) detectCapturedVars(body, fn, d) if not d.somethingToDo and fn.isIterator: - addClosureParam(d, fn) + addClosureParam(d, fn, body.info) d.somethingToDo = true if d.somethingToDo: var c = initLiftingPass(fn) diff --git a/compiler/lowerings.nim b/compiler/lowerings.nim index 7da332335..1cc857bb0 100644 --- a/compiler/lowerings.nim +++ b/compiler/lowerings.nim @@ -114,6 +114,10 @@ proc createObj*(owner: PSym, info: TLineInfo): PType = rawAddSon(result, nil) incl result.flags, tfFinal result.n = newNodeI(nkRecList, info) + let s = newSym(skType, getIdent("Env_" & info.toFilename & "_" & $info.line), + owner, info) + s.typ = result + result.sym = s proc rawAddField*(obj: PType; field: PSym) = assert field.kind == skField diff --git a/compiler/nim.cfg b/compiler/nim.cfg index 0ff128ba3..853ae7e00 100644 --- a/compiler/nim.cfg +++ b/compiler/nim.cfg @@ -4,8 +4,6 @@ hint[XDeclaredButNotUsed]:off path:"llvm" path:"$projectPath/.." -path:"$lib/packages/docutils" - define:booting #import:"$projectpath/testability" diff --git a/compiler/options.nim b/compiler/options.nim index 9edafb17a..50f12d843 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -227,8 +227,16 @@ proc setDefaultLibpath*() = libpath = parentNimLibPath proc canonicalizePath*(path: string): string = - when not FileSystemCaseSensitive: result = path.expandFilename.toLowerAscii - else: result = path.expandFilename + # on Windows, 'expandFilename' calls getFullPathName which doesn't do + # case corrections, so we have to use this convoluted way of retrieving + # the true filename (see tests/modules and Nimble uses 'import Uri' instead + # of 'import uri'): + when defined(windows): + result = path.expandFilename + for x in walkFiles(result): + return x + else: + result = path.expandFilename proc shortenDir*(dir: string): string = ## returns the interesting part of a dir @@ -373,17 +381,6 @@ proc findModule*(modulename, currentModule: string): string = result = findFile(m) patchModule() -proc libCandidates*(s: string, dest: var seq[string]) = - var le = strutils.find(s, '(') - var ri = strutils.find(s, ')', le+1) - if le >= 0 and ri > le: - var prefix = substr(s, 0, le - 1) - var suffix = substr(s, ri + 1) - for middle in split(substr(s, le + 1, ri - 1), '|'): - libCandidates(prefix & middle & suffix, dest) - else: - add(dest, s) - proc canonDynlibName(s: string): string = let start = if s.startsWith("lib"): 3 else: 0 let ende = strutils.find(s, {'(', ')', '.'}) diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index e11a8d08b..ffb2aa812 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -490,6 +490,7 @@ proc pragmaLine(c: PContext, n: PNode) = elif y.kind != nkIntLit: localError(n.info, errIntLiteralExpected) else: + # XXX this produces weird paths which are not properly resolved: n.info.fileIndex = msgs.fileInfoIdx(x.strVal) n.info.line = int16(y.intVal) else: diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 60435202b..96ba4a8f3 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -1276,7 +1276,8 @@ proc propertyWriteAccess(c: PContext, n, nOrig, a: PNode): PNode = # this is ugly. XXX Semantic checking should use the ``nfSem`` flag for # nodes? let aOrig = nOrig[0] - result = newNode(nkCall, n.info, sons = @[setterId, a[0], semExpr(c, n[1])]) + result = newNode(nkCall, n.info, sons = @[setterId, a[0], + semExprWithType(c, n[1])]) result.flags.incl nfDotSetter let orig = newNode(nkCall, n.info, sons = @[setterId, aOrig[0], nOrig[1]]) result = semOverloadedCallAnalyseEffects(c, result, orig, {}) |