fixes #2551; fixes #2212; breaks bootstrapping in debug mode; bootstrap with -d:release

This commit is contained in:
Araq 2015-04-24 17:07:36 +02:00
commit ecc0090939
5 changed files with 38 additions and 17 deletions

View file

@ -812,7 +812,7 @@ proc genTryCpp(p: BProc, t: PNode, d: var TLoc) =
length = sonsLen(t) length = sonsLen(t)
endBlock(p, ropecg(p.module, "} catch (NimException& $1) {$n", [exc])) endBlock(p, ropecg(p.module, "} catch (NimException& $1) {$n", [exc]))
if optStackTrace in p.options: if optStackTrace in p.options:
linefmt(p, cpsStmts, "#setFrame((TFrame*)&F);$n") linefmt(p, cpsStmts, "#setFrame((TFrame*)&FR);$n")
inc p.inExceptBlock inc p.inExceptBlock
i = 1 i = 1
var catchAllPresent = false var catchAllPresent = false
@ -912,7 +912,7 @@ proc genTry(p: BProc, t: PNode, d: var TLoc) =
startBlock(p, "else {$n") startBlock(p, "else {$n")
linefmt(p, cpsStmts, "#popSafePoint();$n") linefmt(p, cpsStmts, "#popSafePoint();$n")
if optStackTrace in p.options: if optStackTrace in p.options:
linefmt(p, cpsStmts, "#setFrame((TFrame*)&F);$n") linefmt(p, cpsStmts, "#setFrame((TFrame*)&FR);$n")
inc p.inExceptBlock inc p.inExceptBlock
var i = 1 var i = 1
while (i < length) and (t.sons[i].kind == nkExceptBranch): while (i < length) and (t.sons[i].kind == nkExceptBranch):

View file

@ -11,20 +11,21 @@
# ------------------------- Name Mangling -------------------------------- # ------------------------- Name Mangling --------------------------------
proc mangleField(name: string): string =
result = mangle(name)
result[0] = result[0].toUpper # Mangling makes everything lowercase,
# but some identifiers are C keywords
proc isKeyword(w: PIdent): bool = proc isKeyword(w: PIdent): bool =
# nimrod and C++ share some keywords # Nim and C++ share some keywords
# it's more efficient to test the whole nimrod keywords range # it's more efficient to test the whole Nim keywords range
case w.id case w.id
of ccgKeywordsLow..ccgKeywordsHigh, of ccgKeywordsLow..ccgKeywordsHigh,
nimKeywordsLow..nimKeywordsHigh, nimKeywordsLow..nimKeywordsHigh,
ord(wInline): return true ord(wInline): return true
else: return false else: return false
proc mangleField(name: PIdent): string =
result = mangle(name.s)
if isKeyword(name):
result[0] = result[0].toUpper # Mangling makes everything lowercase,
# but some identifiers are C keywords
proc mangleName(s: PSym): Rope = proc mangleName(s: PSym): Rope =
result = s.loc.r result = s.loc.r
if result == nil: if result == nil:
@ -379,7 +380,7 @@ proc mangleRecFieldName(field: PSym, rectype: PType): Rope =
({sfImportc, sfExportc} * rectype.sym.flags != {}): ({sfImportc, sfExportc} * rectype.sym.flags != {}):
result = field.loc.r result = field.loc.r
else: else:
result = rope(mangleField(field.name.s)) result = rope(mangleField(field.name))
if result == nil: internalError(field.info, "mangleRecFieldName") if result == nil: internalError(field.info, "mangleRecFieldName")
proc genRecordFieldsAux(m: BModule, n: PNode, proc genRecordFieldsAux(m: BModule, n: PNode,

View file

@ -176,7 +176,7 @@ proc mangle*(name: string): string =
result = newStringOfCap(name.len) result = newStringOfCap(name.len)
case name[0] case name[0]
of Letters: of Letters:
result.add(name[0].toLower) result.add(name[0])
of Digits: of Digits:
result.add("N" & name[0]) result.add("N" & name[0])
else: else:

View file

@ -343,15 +343,15 @@ struct TFrame {
}; };
#define nimfr(proc, file) \ #define nimfr(proc, file) \
TFrame F; \ TFrame FR; \
F.procname = proc; F.filename = file; F.line = 0; F.len = 0; nimFrame(&F); FR.procname = proc; FR.filename = file; FR.line = 0; FR.len = 0; nimFrame(&FR);
#define nimfrs(proc, file, slots, length) \ #define nimfrs(proc, file, slots, length) \
struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; TVarSlot s[slots];} F; \ struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; TVarSlot s[slots];} FR; \
F.procname = proc; F.filename = file; F.line = 0; F.len = length; nimFrame((TFrame*)&F); FR.procname = proc; FR.filename = file; FR.line = 0; FR.len = length; nimFrame((TFrame*)&FR);
#define nimln(n, file) \ #define nimln(n, file) \
F.line = n; F.filename = file; FR.line = n; FR.filename = file;
#define NIM_POSIX_INIT __attribute__((constructor)) #define NIM_POSIX_INIT __attribute__((constructor))

View file

@ -0,0 +1,20 @@
# bug #2551
type Tup = tuple
A, a: int
type Obj = object
A, a: int
var x: Tup # This works.
var y: Obj # This doesn't.
# bug #2212
proc f() =
let
p = 1.0
P = 0.25 + 0.5
f()