diff options
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/ccgexprs.nim | 2 | ||||
-rw-r--r-- | compiler/ccgtypes.nim | 47 | ||||
-rw-r--r-- | compiler/ccgutils.nim | 21 | ||||
-rw-r--r-- | compiler/cgen.nim | 3 | ||||
-rw-r--r-- | compiler/jsgen.nim | 12 | ||||
-rw-r--r-- | compiler/main.nim | 2 | ||||
-rw-r--r-- | compiler/nimrod.ini | 2 | ||||
-rw-r--r-- | compiler/rodutils.nim | 2 |
8 files changed, 31 insertions, 60 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 94a6f4781..39333a80d 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -484,7 +484,7 @@ proc unaryArithOverflow(p: BProc, e: PNode, d: var TLoc, m: TMagic) = opr: array[mUnaryMinusI..mAbsI64, string] = [ mUnaryMinusI: "((NI$2)-($1))", mUnaryMinusI64: "-($1)", - mAbsI: "(NI$2)abs($1)", + mAbsI: "($1 > 0? ($1) : -($1))", mAbsI64: "($1 > 0? ($1) : -($1))"] var a: TLoc diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index f51e66897..7c11d3e9a 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -11,49 +11,10 @@ # ------------------------- Name Mangling -------------------------------- -proc mangleField(name: string): string = - case name[0] - of 'a'..'z': - result = "" - add(result, chr(ord(name[0]) - ord('a') + ord('A'))) - of '0'..'9', 'A'..'Z': - result = "" - add(result, name[0]) - else: result = "HEX" & toHex(ord(name[0]), 2) - for i in countup(1, len(name) - 1): - case name[i] - of 'A'..'Z': - add(result, chr(ord(name[i]) - ord('A') + ord('a'))) - of '_': - discard - of 'a'..'z', '0'..'9': - add(result, name[i]) - else: - add(result, "HEX") - add(result, toHex(ord(name[i]), 2)) - -proc mangle(name: string): string = - when false: - case name[0] - of 'a'..'z': - result = "" - add(result, chr(ord(name[0]) - ord('a') + ord('A'))) - of '0'..'9', 'A'..'Z': - result = "" - add(result, name[0]) - else: result = "HEX" & toHex(ord(name[0]), 2) - result = "" - for i in countup(0, len(name) - 1): - case name[i] - of 'A'..'Z': - add(result, chr(ord(name[i]) - ord('A') + ord('a'))) - of '_': - discard - of 'a'..'z', '0'..'9': - add(result, name[i]) - else: - add(result, "HEX") - add(result, toHex(ord(name[i]), 2)) +proc mangleField(name: string): string = + result = mangle(name) + if name[0] in 'a'..'z': + result[0] = name[0].toUpper proc isKeyword(w: PIdent): bool = # nimrod and C++ share some keywords diff --git a/compiler/ccgutils.nim b/compiler/ccgutils.nim index 1d8f0158b..9beb08a21 100644 --- a/compiler/ccgutils.nim +++ b/compiler/ccgutils.nim @@ -161,6 +161,27 @@ proc makeSingleLineCString*(s: string): string = result.add(c.toCChar) result.add('\"') +proc mangle*(name: string): string = + result = "" + case name[0] + of Letters: + result.add(name[0].toLower) + of Digits: + result.add("N" & name[0]) + else: + result = "HEX" & toHex(ord(name[0]), 2) + for i in 1..(name.len-1): + let c = name[i] + case c + of 'A'..'Z': + add(result, c.toLower) + of '_': + discard + of 'a'..'z', '0'..'9': + add(result, c) + else: + add(result, "HEX" & toHex(ord(c), 2)) + proc makeLLVMString*(s: string): PRope = const MaxLineLength = 64 result = nil diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 8d66d7a3b..198b1187d 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -503,7 +503,8 @@ proc assignLocalVar(p: BProc, s: PSym) = if sfRegister in s.flags: app(decl, " register") #elif skipTypes(s.typ, abstractInst).kind in GcTypeKinds: # app(decl, " GC_GUARD") - if sfVolatile in s.flags or p.nestedTryStmts.len > 0: + if sfVolatile in s.flags or (p.nestedTryStmts.len > 0 and + gCmd != cmdCompileToCpp): app(decl, " volatile") appf(decl, " $1;$n", [s.loc.r]) else: diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 373a11e9a..6687e2e8e 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -136,18 +136,6 @@ proc mapType(typ: PType): TJSTypeKind = of tyProc: result = etyProc of tyCString: result = etyString -proc mangle(name: string): string = - result = "" - for i in countup(0, len(name) - 1): - case name[i] - of 'A'..'Z': - add(result, chr(ord(name[i]) - ord('A') + ord('a'))) - of '_': - discard - of 'a'..'z', '0'..'9': - add(result, name[i]) - else: add(result, 'X' & toHex(ord(name[i]), 2)) - proc mangleName(s: PSym): PRope = result = s.loc.r if result == nil: diff --git a/compiler/main.nim b/compiler/main.nim index f833394f7..b4af49248 100644 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -310,7 +310,7 @@ proc mainCommand* = of "cpp", "compiletocpp": extccomp.cExt = ".cpp" gCmd = cmdCompileToCpp - if cCompiler == ccGcc: setCC("gpp") + if cCompiler == ccGcc: setCC("gcc") wantMainModule() defineSymbol("cpp") commandCompileToC() diff --git a/compiler/nimrod.ini b/compiler/nimrod.ini index 0dc44a7c9..8b2353aab 100644 --- a/compiler/nimrod.ini +++ b/compiler/nimrod.ini @@ -3,7 +3,7 @@ Name: "Nimrod" Version: "$version" Platforms: """ windows: i386;amd64 - linux: i386;amd64;powerpc64;arm;sparc;mips + linux: i386;amd64;powerpc64;arm;sparc;mips;powerpc macosx: i386;amd64;powerpc64 solaris: i386;amd64;sparc freebsd: i386;amd64 diff --git a/compiler/rodutils.nim b/compiler/rodutils.nim index 4433ed4ab..09b92cd8a 100644 --- a/compiler/rodutils.nim +++ b/compiler/rodutils.nim @@ -10,7 +10,7 @@ ## Serialization utilities for the compiler. import strutils -proc c_sprintf(buf, frmt: cstring) {.importc: "sprintf", nodecl, varargs.} +proc c_sprintf(buf, frmt: cstring) {.importc: "sprintf", header: "<stdio.h>", nodecl, varargs.} proc toStrMaxPrecision*(f: BiggestFloat): string = if f != f: |