Bugfix: no #line dir with 0 generated
This commit is contained in:
parent
3bc821aa5c
commit
5f2d930a54
7 changed files with 15 additions and 16 deletions
|
|
@ -17,7 +17,7 @@ proc genLineDir(p: BProc, t: PNode) =
|
||||||
var line = toLinenumber(t.info) # BUGFIX
|
var line = toLinenumber(t.info) # BUGFIX
|
||||||
if line < 0:
|
if line < 0:
|
||||||
line = 0 # negative numbers are not allowed in #line
|
line = 0 # negative numbers are not allowed in #line
|
||||||
if optLineDir in p.Options:
|
if optLineDir in p.Options and line > 0:
|
||||||
appff(p.s[cpsStmts], "#line $2 \"$1\"$n", "; line $2 \"$1\"$n",
|
appff(p.s[cpsStmts], "#line $2 \"$1\"$n", "; line $2 \"$1\"$n",
|
||||||
[toRope(toFilename(t.info)), toRope(line)])
|
[toRope(toFilename(t.info)), toRope(line)])
|
||||||
if ({optStackTrace, optEndb} * p.Options == {optStackTrace, optEndb}) and
|
if ({optStackTrace, optEndb} * p.Options == {optStackTrace, optEndb}) and
|
||||||
|
|
|
||||||
|
|
@ -62,13 +62,10 @@ proc initTypeTables() =
|
||||||
for i in countup(low(TTypeKind), high(TTypeKind)): InitIdTable(gTypeTable[i])
|
for i in countup(low(TTypeKind), high(TTypeKind)): InitIdTable(gTypeTable[i])
|
||||||
|
|
||||||
proc GetUniqueType*(key: PType): PType =
|
proc GetUniqueType*(key: PType): PType =
|
||||||
var
|
|
||||||
t: PType
|
|
||||||
k: TTypeKind
|
|
||||||
# this is a hotspot in the compiler!
|
# this is a hotspot in the compiler!
|
||||||
result = key
|
result = key
|
||||||
if key == nil: return
|
if key == nil: return
|
||||||
k = key.kind
|
var k = key.kind
|
||||||
case k
|
case k
|
||||||
of tyObject, tyEnum:
|
of tyObject, tyEnum:
|
||||||
result = PType(IdTableGet(gTypeTable[k], key))
|
result = PType(IdTableGet(gTypeTable[k], key))
|
||||||
|
|
@ -84,20 +81,19 @@ proc GetUniqueType*(key: PType): PType =
|
||||||
# to be compared by their structure:
|
# to be compared by their structure:
|
||||||
if IdTableHasObjectAsKey(gTypeTable[k], key): return
|
if IdTableHasObjectAsKey(gTypeTable[k], key): return
|
||||||
for h in countup(0, high(gTypeTable[k].data)):
|
for h in countup(0, high(gTypeTable[k].data)):
|
||||||
t = PType(gTypeTable[k].data[h].key)
|
var t = PType(gTypeTable[k].data[h].key)
|
||||||
if (t != nil) and sameType(t, key):
|
if (t != nil) and sameType(t, key):
|
||||||
return t
|
return t
|
||||||
IdTablePut(gTypeTable[k], key, key)
|
IdTablePut(gTypeTable[k], key, key)
|
||||||
|
|
||||||
proc TableGetType*(tab: TIdTable, key: PType): PObject =
|
proc TableGetType*(tab: TIdTable, key: PType): PObject =
|
||||||
var t: PType
|
|
||||||
# returns nil if we need to declare this type
|
# returns nil if we need to declare this type
|
||||||
result = IdTableGet(tab, key)
|
result = IdTableGet(tab, key)
|
||||||
if (result == nil) and (tab.counter > 0):
|
if (result == nil) and (tab.counter > 0):
|
||||||
# we have to do a slow linear search because types may need
|
# we have to do a slow linear search because types may need
|
||||||
# to be compared by their structure:
|
# to be compared by their structure:
|
||||||
for h in countup(0, high(tab.data)):
|
for h in countup(0, high(tab.data)):
|
||||||
t = PType(tab.data[h].key)
|
var t = PType(tab.data[h].key)
|
||||||
if t != nil:
|
if t != nil:
|
||||||
if sameType(t, key):
|
if sameType(t, key):
|
||||||
return tab.data[h].val
|
return tab.data[h].val
|
||||||
|
|
|
||||||
|
|
@ -195,8 +195,7 @@ proc transformVarSection(c: PTransf, v: PNode): PTransNode =
|
||||||
if it.kind == nkCommentStmt:
|
if it.kind == nkCommentStmt:
|
||||||
result[i] = PTransNode(it)
|
result[i] = PTransNode(it)
|
||||||
elif it.kind == nkIdentDefs:
|
elif it.kind == nkIdentDefs:
|
||||||
if (it.sons[0].kind != nkSym):
|
if it.sons[0].kind != nkSym: InternalError(it.info, "transformVarSection")
|
||||||
InternalError(it.info, "transformVarSection")
|
|
||||||
var newVar = copySym(it.sons[0].sym)
|
var newVar = copySym(it.sons[0].sym)
|
||||||
incl(newVar.flags, sfFromGeneric)
|
incl(newVar.flags, sfFromGeneric)
|
||||||
# fixes a strange bug for rodgen:
|
# fixes a strange bug for rodgen:
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
# @putenv "key" "val"
|
# @putenv "key" "val"
|
||||||
# Environment variables cannot be used in the options, however!
|
# Environment variables cannot be used in the options, however!
|
||||||
|
|
||||||
cc = gcc
|
cc = clang
|
||||||
|
|
||||||
@if nim:
|
@if nim:
|
||||||
# use the old fixed library for bootstrapping with Nim:
|
# use the old fixed library for bootstrapping with Nim:
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
## ``shallowADT`` to compile a version that uses shallow copies instead.
|
## ``shallowADT`` to compile a version that uses shallow copies instead.
|
||||||
|
|
||||||
import
|
import
|
||||||
os, hashes, math
|
hashes, math
|
||||||
|
|
||||||
when defined(shallowADT):
|
when defined(shallowADT):
|
||||||
{.pragma: myShallow, shallow.}
|
{.pragma: myShallow, shallow.}
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,9 @@ proc genericAssignAux(dest, src: Pointer, n: ptr TNimNode, shallow: bool) =
|
||||||
d = cast[TAddress](dest)
|
d = cast[TAddress](dest)
|
||||||
s = cast[TAddress](src)
|
s = cast[TAddress](src)
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkNone: assert(false)
|
|
||||||
of nkSlot:
|
of nkSlot:
|
||||||
genericAssignAux(cast[pointer](d +% n.offset), cast[pointer](s +% n.offset),
|
genericAssignAux(cast[pointer](d +% n.offset),
|
||||||
n.typ, shallow)
|
cast[pointer](s +% n.offset), n.typ, shallow)
|
||||||
of nkList:
|
of nkList:
|
||||||
for i in 0..n.len-1:
|
for i in 0..n.len-1:
|
||||||
genericAssignAux(dest, src, n.sons[i], shallow)
|
genericAssignAux(dest, src, n.sons[i], shallow)
|
||||||
|
|
@ -25,6 +24,10 @@ proc genericAssignAux(dest, src: Pointer, n: ptr TNimNode, shallow: bool) =
|
||||||
n.typ.size)
|
n.typ.size)
|
||||||
var m = selectBranch(src, n)
|
var m = selectBranch(src, n)
|
||||||
if m != nil: genericAssignAux(dest, src, m, shallow)
|
if m != nil: genericAssignAux(dest, src, m, shallow)
|
||||||
|
else:
|
||||||
|
echo "ugh memory corruption! ", n.kind
|
||||||
|
quit 1
|
||||||
|
#of nkNone: assert(false)
|
||||||
|
|
||||||
proc genericAssignAux(dest, src: Pointer, mt: PNimType, shallow: bool) =
|
proc genericAssignAux(dest, src: Pointer, mt: PNimType, shallow: bool) =
|
||||||
var
|
var
|
||||||
|
|
|
||||||
3
todo.txt
3
todo.txt
|
|
@ -15,7 +15,6 @@ High priority (version 0.9.0)
|
||||||
- implement explicit varargs
|
- implement explicit varargs
|
||||||
- tests: run modules that contain "#RUN_ME", compile the other
|
- tests: run modules that contain "#RUN_ME", compile the other
|
||||||
modules; run the GC tests
|
modules; run the GC tests
|
||||||
- fix implicit generic routines
|
|
||||||
- fix the streams implementation so that it uses methods
|
- fix the streams implementation so that it uses methods
|
||||||
- fix overloading resolution
|
- fix overloading resolution
|
||||||
- wrong co-/contravariance
|
- wrong co-/contravariance
|
||||||
|
|
@ -30,6 +29,7 @@ Bugs
|
||||||
- BUG: generic assign still buggy
|
- BUG: generic assign still buggy
|
||||||
- Optimization: If we use a temporary for the result anyway the code gen
|
- Optimization: If we use a temporary for the result anyway the code gen
|
||||||
should make use of this fact to generate better code...
|
should make use of this fact to generate better code...
|
||||||
|
- bug: invoking a generic iterator twice triggers a code gen bug
|
||||||
- sorting with leads to a strange memory corruption!
|
- sorting with leads to a strange memory corruption!
|
||||||
--> system.swap or genericAssign is broken! And indeed, if reference counts
|
--> system.swap or genericAssign is broken! And indeed, if reference counts
|
||||||
are not modified and the GC is triggered in between a swap, bad things
|
are not modified and the GC is triggered in between a swap, bad things
|
||||||
|
|
@ -74,6 +74,7 @@ Low priority
|
||||||
- 'nimrod def': does not always work
|
- 'nimrod def': does not always work
|
||||||
- test branch coverage
|
- test branch coverage
|
||||||
- checked exceptions
|
- checked exceptions
|
||||||
|
- fix implicit generic routines
|
||||||
|
|
||||||
|
|
||||||
Library
|
Library
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue