Merge branch 'devel' of https://github.com/Araq/Nimrod into devel
This commit is contained in:
commit
04a1555f4a
32 changed files with 294 additions and 286 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue