mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
Bugfix: no #line dir with 0 generated
This commit is contained in:
@@ -17,7 +17,7 @@ proc genLineDir(p: BProc, t: PNode) =
|
||||
var line = toLinenumber(t.info) # BUGFIX
|
||||
if line < 0:
|
||||
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",
|
||||
[toRope(toFilename(t.info)), toRope(line)])
|
||||
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])
|
||||
|
||||
proc GetUniqueType*(key: PType): PType =
|
||||
var
|
||||
t: PType
|
||||
k: TTypeKind
|
||||
# this is a hotspot in the compiler!
|
||||
result = key
|
||||
if key == nil: return
|
||||
k = key.kind
|
||||
var k = key.kind
|
||||
case k
|
||||
of tyObject, tyEnum:
|
||||
result = PType(IdTableGet(gTypeTable[k], key))
|
||||
@@ -84,20 +81,19 @@ proc GetUniqueType*(key: PType): PType =
|
||||
# to be compared by their structure:
|
||||
if IdTableHasObjectAsKey(gTypeTable[k], key): return
|
||||
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):
|
||||
return t
|
||||
IdTablePut(gTypeTable[k], key, key)
|
||||
|
||||
proc TableGetType*(tab: TIdTable, key: PType): PObject =
|
||||
var t: PType
|
||||
# returns nil if we need to declare this type
|
||||
result = IdTableGet(tab, key)
|
||||
if (result == nil) and (tab.counter > 0):
|
||||
# we have to do a slow linear search because types may need
|
||||
# to be compared by their structure:
|
||||
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 sameType(t, key):
|
||||
return tab.data[h].val
|
||||
|
||||
@@ -195,8 +195,7 @@ proc transformVarSection(c: PTransf, v: PNode): PTransNode =
|
||||
if it.kind == nkCommentStmt:
|
||||
result[i] = PTransNode(it)
|
||||
elif it.kind == nkIdentDefs:
|
||||
if (it.sons[0].kind != nkSym):
|
||||
InternalError(it.info, "transformVarSection")
|
||||
if it.sons[0].kind != nkSym: InternalError(it.info, "transformVarSection")
|
||||
var newVar = copySym(it.sons[0].sym)
|
||||
incl(newVar.flags, sfFromGeneric)
|
||||
# fixes a strange bug for rodgen:
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
# @putenv "key" "val"
|
||||
# Environment variables cannot be used in the options, however!
|
||||
|
||||
cc = gcc
|
||||
cc = clang
|
||||
|
||||
@if nim:
|
||||
# use the old fixed library for bootstrapping with Nim:
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
## ``shallowADT`` to compile a version that uses shallow copies instead.
|
||||
|
||||
import
|
||||
os, hashes, math
|
||||
hashes, math
|
||||
|
||||
when defined(shallowADT):
|
||||
{.pragma: myShallow, shallow.}
|
||||
|
||||
@@ -13,10 +13,9 @@ proc genericAssignAux(dest, src: Pointer, n: ptr TNimNode, shallow: bool) =
|
||||
d = cast[TAddress](dest)
|
||||
s = cast[TAddress](src)
|
||||
case n.kind
|
||||
of nkNone: assert(false)
|
||||
of nkSlot:
|
||||
genericAssignAux(cast[pointer](d +% n.offset), cast[pointer](s +% n.offset),
|
||||
n.typ, shallow)
|
||||
genericAssignAux(cast[pointer](d +% n.offset),
|
||||
cast[pointer](s +% n.offset), n.typ, shallow)
|
||||
of nkList:
|
||||
for i in 0..n.len-1:
|
||||
genericAssignAux(dest, src, n.sons[i], shallow)
|
||||
@@ -25,6 +24,10 @@ proc genericAssignAux(dest, src: Pointer, n: ptr TNimNode, shallow: bool) =
|
||||
n.typ.size)
|
||||
var m = selectBranch(src, n)
|
||||
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) =
|
||||
var
|
||||
|
||||
3
todo.txt
3
todo.txt
@@ -15,7 +15,6 @@ High priority (version 0.9.0)
|
||||
- implement explicit varargs
|
||||
- tests: run modules that contain "#RUN_ME", compile the other
|
||||
modules; run the GC tests
|
||||
- fix implicit generic routines
|
||||
- fix the streams implementation so that it uses methods
|
||||
- fix overloading resolution
|
||||
- wrong co-/contravariance
|
||||
@@ -30,6 +29,7 @@ Bugs
|
||||
- BUG: generic assign still buggy
|
||||
- Optimization: If we use a temporary for the result anyway the code gen
|
||||
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!
|
||||
--> 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
|
||||
@@ -74,6 +74,7 @@ Low priority
|
||||
- 'nimrod def': does not always work
|
||||
- test branch coverage
|
||||
- checked exceptions
|
||||
- fix implicit generic routines
|
||||
|
||||
|
||||
Library
|
||||
|
||||
Reference in New Issue
Block a user