diff options
author | Dominik Picheta <dominikpicheta@gmail.com> | 2016-01-18 13:20:13 +0000 |
---|---|---|
committer | Dominik Picheta <dominikpicheta@gmail.com> | 2016-01-18 13:20:13 +0000 |
commit | faf5fb8467d5b841c840e255ccd19db6bfd08d2b (patch) | |
tree | 9f5c2693c050a7c6f9a9953f8c9624eb9372ca29 | |
parent | a34206fe84a3f02c0ee89fe32611ac4496ea9677 (diff) | |
parent | 7211462a04f7759126145a878b98f598494322ea (diff) | |
download | Nim-faf5fb8467d5b841c840e255ccd19db6bfd08d2b.tar.gz |
Merge branch 'devel' of github.com:nim-lang/Nim into devel
-rw-r--r-- | compiler/ccgexprs.nim | 2 | ||||
-rw-r--r-- | compiler/lambdalifting.nim | 8 | ||||
-rw-r--r-- | compiler/transf.nim | 4 | ||||
-rw-r--r-- | tools/nimgrep.nim | 14 |
4 files changed, 22 insertions, 6 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 6f513c165..3607f347e 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -1847,6 +1847,8 @@ proc genClosure(p: BProc, n: PNode, d: var TLoc) = var tmp, a, b: TLoc initLocExpr(p, n.sons[0], a) initLocExpr(p, n.sons[1], b) + if n.sons[0].skipConv.kind == nkClosure: + internalError(n.info, "closure to closure created") getTemp(p, n.typ, tmp) linefmt(p, cpsStmts, "$1.ClPrc = $2; $1.ClEnv = $3;$n", tmp.rdLoc, a.rdLoc, b.rdLoc) diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim index 9265d09e3..1c0c2494a 100644 --- a/compiler/lambdalifting.nim +++ b/compiler/lambdalifting.nim @@ -213,7 +213,7 @@ proc makeClosure*(prc: PSym; env: PNode; info: TLineInfo): PNode = if env == nil: result.add(newNodeIT(nkNilLit, info, getSysType(tyNil))) else: - if env.kind == nkClosure: + if env.skipConv.kind == nkClosure: localError(info, "internal error: taking closure of closure") result.add(env) @@ -711,7 +711,11 @@ proc liftCapturedVars(n: PNode; owner: PSym; d: DetectionPass; of nkClosure: if n[1].kind == nkNilLit: n.sons[0] = liftCapturedVars(n[0], owner, d, c) - #if n.sons[0].kind == nkClosure: result = n.sons[0] + let x = n.sons[0].skipConv + if x.kind == nkClosure: + #localError(n.info, "internal error: closure to closure created") + # now we know better, so patch it: + n.sons[0] = x.sons[0] of nkLambdaKinds, nkIteratorDef: if n.typ != nil and n[namePos].kind == nkSym: let m = newSymNode(n[namePos].sym) diff --git a/compiler/transf.nim b/compiler/transf.nim index 3e074841e..b2bbdcec3 100644 --- a/compiler/transf.nim +++ b/compiler/transf.nim @@ -383,9 +383,11 @@ proc generateThunk(prc: PNode, dest: PType): PNode = # (see internal documentation): if gCmd == cmdCompileToJS: return prc result = newNodeIT(nkClosure, prc.info, dest) - var conv = newNodeIT(nkHiddenStdConv, prc.info, dest) + var conv = newNodeIT(nkHiddenSubConv, prc.info, dest) conv.add(emptyNode) conv.add(prc) + if prc.kind == nkClosure: + internalError(prc.info, "closure to closure created") result.add(conv) result.add(newNodeIT(nkNilLit, prc.info, getSysType(tyNil))) diff --git a/tools/nimgrep.nim b/tools/nimgrep.nim index 221181f66..e93168847 100644 --- a/tools/nimgrep.nim +++ b/tools/nimgrep.nim @@ -11,7 +11,7 @@ import os, strutils, parseopt, pegs, re, terminal const - Version = "0.9" + Version = "1.0" Usage = "nimgrep - Nim Grep Utility Version " & Version & """ (c) 2012 Andreas Rumpf @@ -56,6 +56,7 @@ var proc ask(msg: string): string = stdout.write(msg) + stdout.flushFile() result = stdin.readLine() proc confirm: TConfirmEnum = @@ -108,18 +109,21 @@ proc highlight(s, match, repl: string, t: tuple[first, last: int], writeColored(match) for i in t.last+1 .. y: stdout.write(s[i]) stdout.write("\n") + stdout.flushFile() if showRepl: stdout.write(spaces(alignment-1), "-> ") for i in x .. t.first-1: stdout.write(s[i]) writeColored(repl) for i in t.last+1 .. y: stdout.write(s[i]) stdout.write("\n") + stdout.flushFile() proc processFile(filename: string) = var filenameShown = false template beforeHighlight = if not filenameShown and optVerbose notin options: stdout.writeLine(filename) + stdout.flushFile() filenameShown = true var buffer: string @@ -128,7 +132,9 @@ proc processFile(filename: string) = except IOError: echo "cannot open file: ", filename return - if optVerbose in options: stdout.writeLine(filename) + if optVerbose in options: + stdout.writeLine(filename) + stdout.flushFile() var pegp: TPeg var rep: Regex var result: string @@ -254,10 +260,12 @@ proc walker(dir: string) = proc writeHelp() = stdout.write(Usage) + stdout.flushFile() quit(0) proc writeVersion() = stdout.write(Version & "\n") + stdout.flushFile() quit(0) proc checkOptions(subset: TOptions, a, b: string) = @@ -291,7 +299,7 @@ for kind, key, val in getopt(): of "word", "w": incl(options, optWord) of "ignorecase", "i": incl(options, optIgnoreCase) of "ignorestyle", "y": incl(options, optIgnoreStyle) - of "ext": extensions = val.split('|') + of "ext": extensions.add val.split('|') of "nocolor": useWriteStyled = false of "verbose": incl(options, optVerbose) of "help", "h": writeHelp() |