diff options
author | Araq <rumpf_a@web.de> | 2013-03-16 20:40:26 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2013-03-16 20:40:26 +0100 |
commit | d9149635393d6c2de589d645b541793da2f5cc9b (patch) | |
tree | fc8e0fd99c9beaf0a2bb6d3341c01552b0f5af29 /compiler | |
parent | 7d05356df64c99a72f6caeeec5e98ca7482b2e14 (diff) | |
parent | 7304ca061159db8345ae245309274310bbfd0ab1 (diff) | |
download | Nim-d9149635393d6c2de589d645b541793da2f5cc9b.tar.gz |
Merge branch 'master' of github.com:Araq/Nimrod
Diffstat (limited to 'compiler')
-rwxr-xr-x | compiler/c2nim/cparse.nim | 11 | ||||
-rwxr-xr-x | compiler/c2nim/tests/systest.c | 14 | ||||
-rwxr-xr-x | compiler/cgen.nim | 8 | ||||
-rwxr-xr-x | compiler/jsgen.nim | 13 | ||||
-rwxr-xr-x | compiler/nimrod.ini | 3 | ||||
-rwxr-xr-x | compiler/semfold.nim | 11 | ||||
-rwxr-xr-x | compiler/semgnrc.nim | 5 |
7 files changed, 41 insertions, 24 deletions
diff --git a/compiler/c2nim/cparse.nim b/compiler/c2nim/cparse.nim index 9f7a7bf36..b964ed976 100755 --- a/compiler/c2nim/cparse.nim +++ b/compiler/c2nim/cparse.nim @@ -955,15 +955,22 @@ proc enumSpecifier(p: var TParser): PNode = result = newNodeP(nkConstSection, p) getTok(p, result) var i = 0 + var hasUnknown = false while true: var name = skipIdentExport(p) var val: PNode if p.tok.xkind == pxAsgn: getTok(p, name) val = constantExpression(p) - if val.kind == nkIntLit: i = int(val.intVal)+1 - else: parMessage(p, errXExpected, "int literal") + if val.kind == nkIntLit: + i = int(val.intVal)+1 + hasUnknown = false + else: + hasUnknown = true else: + if hasUnknown: + parMessage(p, warnUser, "computed const value may be wrong: " & + name.renderTree) val = newIntNodeP(nkIntLit, i, p) inc(i) var c = createConst(name, ast.emptyNode, val, p) diff --git a/compiler/c2nim/tests/systest.c b/compiler/c2nim/tests/systest.c index 2a9dd6c28..b73eb5bee 100755 --- a/compiler/c2nim/tests/systest.c +++ b/compiler/c2nim/tests/systest.c @@ -9,6 +9,20 @@ extern "C" { # endif #endif +enum +{ +/* 8bit, color or not */ + CV_LOAD_IMAGE_UNCHANGED =-1, +/* 8bit, gray */ + CV_LOAD_IMAGE_GRAYSCALE =0, +/* ?, color */ + CV_LOAD_IMAGE_COLOR =1, +/* any depth, ? */ + CV_LOAD_IMAGE_ANYDEPTH =2, +/* ?, any color */ + CV_LOAD_IMAGE_ANYCOLOR =4 +}; + typedef void (*callback_t) (int rc); typedef const char* (*callback2)(int rc, long L, const char* buffer); diff --git a/compiler/cgen.nim b/compiler/cgen.nim index d06a6cb6f..b7849f074 100755 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -892,6 +892,12 @@ proc getFileHeader(cfilenoext: string): PRope = result = getCopyright(cfilenoext) addIntTypes(result) +proc genFilenames(m: BModule): PRope = + discard cgsym(m, "dbgRegisterFilename") + result = nil + for i in 0.. <fileInfos.len: + result.appf("dbgRegisterFilename($1);$n", fileInfos[i].projPath.makeCString) + proc genMainProc(m: BModule) = const CommonMainBody = @@ -950,6 +956,8 @@ proc genMainProc(m: BModule) = nimMain = PosixNimMain otherMain = PosixCMain if gBreakpoints != nil: discard cgsym(m, "dbgRegisterBreakpoint") + if optEndb in gOptions: + gBreakpoints.app(m.genFilenames) let initStackBottomCall = if emulatedThreadVars() or platform.targetOS == osStandalone: "".toRope diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 64175dc93..1f95f7955 100755 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -44,7 +44,6 @@ type TBlock{.final.} = object id: int # the ID of the label; positive means that it # has been used (i.e. the label should be emitted) - nestedTryStmts: int # how many try statements is it nested into isLoop: bool # whether it's a 'block' or 'while' TGlobals{.final.} = object @@ -62,7 +61,6 @@ type module: BModule g: PGlobals BeforeRetNeeded: bool - nestedTryStmts: int unique: int blocks: seq[TBlock] @@ -485,10 +483,6 @@ proc genLineDir(p: var TProc, n: PNode, r: var TCompRes) = ((p.prc == nil) or not (sfPure in p.prc.flags)): appf(r.com, "F.line = $1;$n", [toRope(line)]) -proc finishTryStmt(p: var TProc, r: var TCompRes, howMany: int) = - for i in countup(1, howMany): - app(r.com, "excHandler = excHandler.prev;" & tnl) - proc genWhileStmt(p: var TProc, n: PNode, r: var TCompRes) = var cond, stmt: TCompRes @@ -498,7 +492,6 @@ proc genWhileStmt(p: var TProc, n: PNode, r: var TCompRes) = length = len(p.blocks) setlen(p.blocks, length + 1) p.blocks[length].id = - p.unique - p.blocks[length].nestedTryStmts = p.nestedTryStmts p.blocks[length].isLoop = true labl = p.unique gen(p, n.sons[0], cond) @@ -543,7 +536,6 @@ proc genTryStmt(p: var TProc, n: PNode, r: var TCompRes) = if optStackTrace in p.Options: app(r.com, "framePtr = F;" & tnl) app(r.com, "try {" & tnl) length = sonsLen(n) - inc(p.nestedTryStmts) genStmt(p, n.sons[0], a) app(r.com, mergeStmt(a)) i = 1 @@ -571,8 +563,6 @@ proc genTryStmt(p: var TProc, n: PNode, r: var TCompRes) = appf(epart, "$1}$n", [mergeStmt(a)]) inc(i) if epart != nil: appf(r.com, "} catch (EXC) {$n$1", [epart]) - finishTryStmt(p, r, p.nestedTryStmts) - dec(p.nestedTryStmts) app(r.com, "} finally {" & tnl & "excHandler = excHandler.prev;" & tnl) if (i < length) and (n.sons[i].kind == nkFinally): genStmt(p, n.sons[i].sons[0], a) @@ -655,7 +645,6 @@ proc genBlock(p: var TProc, n: PNode, r: var TCompRes) = sym.loc.a = idx setlen(p.blocks, idx + 1) p.blocks[idx].id = - p.unique # negative because it isn't used yet - p.blocks[idx].nestedTryStmts = p.nestedTryStmts labl = p.unique if n.kind == nkBlockExpr: genStmtListExpr(p, n.sons[1], r) else: genStmt(p, n.sons[1], r) @@ -682,7 +671,6 @@ proc genBreakStmt(p: var TProc, n: PNode, r: var TCompRes) = if idx < 0 or not p.blocks[idx].isLoop: InternalError(n.info, "no loop to break") p.blocks[idx].id = abs(p.blocks[idx].id) # label is used - finishTryStmt(p, r, p.nestedTryStmts - p.blocks[idx].nestedTryStmts) appf(r.com, "break L$1;$n", [toRope(p.blocks[idx].id)]) proc genAsmStmt(p: var TProc, n: PNode, r: var TCompRes) = @@ -1433,7 +1421,6 @@ proc genReturnStmt(p: var TProc, n: PNode, r: var TCompRes) = if a.com != nil: appf(r.com, "$1;$n", mergeStmt(a)) else: genLineDir(p, n, r) - finishTryStmt(p, r, p.nestedTryStmts) app(r.com, "break BeforeRet;" & tnl) proc genProcBody(p: var TProc, prc: PSym, r: TCompRes): PRope = diff --git a/compiler/nimrod.ini b/compiler/nimrod.ini index 74cf534e4..9febe24aa 100755 --- a/compiler/nimrod.ini +++ b/compiler/nimrod.ini @@ -57,8 +57,6 @@ Files: "compiler/*.nim" Files: "build/empty.txt" Files: "bin/empty.txt" -Files: "packages/docutils/*.nim" - [Lib] Files: "lib/nimbase.h" @@ -85,6 +83,7 @@ Files: "lib/wrappers/zip/libzip_all.c" Files: "lib/windows/*.nim" Files: "lib/posix/*.nim" Files: "lib/js/*.nim" +Files: "lib/packages/docutils/*.nim" [Other] diff --git a/compiler/semfold.nim b/compiler/semfold.nim index e26700e27..d304ddd3c 100755 --- a/compiler/semfold.nim +++ b/compiler/semfold.nim @@ -490,7 +490,7 @@ proc getArrayConstr(m: PSym, n: PNode): PNode = proc foldArrayAccess(m: PSym, n: PNode): PNode = var x = getConstExpr(m, n.sons[0]) - if x == nil: return + if x == nil or x.typ.skipTypes({tyGenericInst}).kind == tyTypeDesc: return var y = getConstExpr(m, n.sons[1]) if y == nil: return @@ -541,7 +541,12 @@ proc foldConStrStr(m: PSym, n: PNode): PNode = let a = getConstExpr(m, n.sons[i]) if a == nil: return nil result.strVal.add(getStrOrChar(a)) - + +proc newSymNodeTypeDesc*(s: PSym; info: TLineInfo): PNode = + result = newSymNode(s, info) + result.typ = newType(tyTypeDesc, s.owner) + result.typ.addSonSkipIntLit(s.typ) + proc getConstExpr(m: PSym, n: PNode): PNode = result = nil case n.kind @@ -569,6 +574,8 @@ proc getConstExpr(m: PSym, n: PNode): PNode = if sfFakeConst notin s.flags: result = copyTree(s.ast) elif s.kind in {skProc, skMethod}: # BUGFIX result = n + elif s.kind in {skType, skGenericParam}: + result = newSymNodeTypeDesc(s, n.info) of nkCharLit..nkNilLit: result = copyNode(n) of nkIfExpr: diff --git a/compiler/semgnrc.nim b/compiler/semgnrc.nim index 2e1eccda2..8c3cef027 100755 --- a/compiler/semgnrc.nim +++ b/compiler/semgnrc.nim @@ -31,11 +31,6 @@ proc getIdentNode(n: PNode): PNode = illFormedAst(n) result = n -proc newSymNodeTypeDesc(s: PSym; info: TLineInfo): PNode = - result = newSymNode(s, info) - result.typ = newType(tyTypeDesc, s.owner) - result.typ.addSonSkipIntLit(s.typ) - proc semGenericStmt(c: PContext, n: PNode, flags: TSemGenericFlags, ctx: var TIntSet): PNode proc semGenericStmtScope(c: PContext, n: PNode, |