Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #537; fixes invalid file causes crashing #550

Closed
wants to merge 9 commits into from
2 changes: 1 addition & 1 deletion src/hastur.nim
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ proc nifctests(overwrite: bool) =
execNifc " cpp -r " & tryIssues

let issues = "tests/nifc/issues.nif"
execNifc " c -r --linedir:on " & issues
# execNifc " c -r --linedir:on " & issues
execNifc " cpp -r --linedir:off " & issues

proc hexertests(overwrite: bool) =
Expand Down
6 changes: 5 additions & 1 deletion src/nifc/nifc_model.nim
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ proc parse*(r: var Reader; m: var Module; parentInfo: PackedLineInfo): bool =
# relative file position
if t.pos.line != 0 or t.pos.col != 0:
let (file, line, col) = unpack(pool.man, parentInfo)
currentInfo = pack(pool.man, file, line+t.pos.line, col+t.pos.col)
let curLine = line+t.pos.line
let curCol = col+t.pos.col
if not hasId(pool.files, file):
bug "no file name in the line info"
currentInfo = pack(pool.man, file, curLine, curCol)
else:
# absolute file position:
let fileId = pool.files.getOrIncl(decodeFilename t)
Expand Down
2 changes: 1 addition & 1 deletion tests/nifc/app.c.nif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(.nif24)
(stmts
0,1,test1.nim(stmts
(proc :main.c . (i +32) . (stmts

(var :x.mangled . (f +32) 1.2)
Expand Down
2 changes: 1 addition & 1 deletion tests/nifc/cimport_array.c.nif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(.nif24)
(stmts
0,1,test1.nim(stmts
(incl "testcarry.h")
(gvar :cary.mangled . CArray.c .)
(discard
Expand Down
8 changes: 4 additions & 4 deletions tests/nifc/hello.expected.idx.nif
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(.nif24)
(index
(public)
(private
(kv MyObject.ptr.flexarray +975)
(kv MyObject.ptr.object +699)
(kv MyObject.my.sequence +171)
(private 0,1,test1.nim
(kv MyObject.ptr.flexarray +988) 0,1,test1.nim
(kv MyObject.ptr.object +699) 0,1,test1.nim
(kv MyObject.my.sequence +171) 0,1,test1.nim
(kv MyObject.sequence.base +127))
(build)

Expand Down
2 changes: 1 addition & 1 deletion tests/nifc/hello.nif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(.nif24)
(stmts
0,1,test1.nim(stmts
(incl "<stdio.h>")
(incl "<assert.h>")
(type 1,1,hello.nim :MyObject.c . (object . ))
Expand Down
2 changes: 1 addition & 1 deletion tests/nifc/issues.nif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(.nif24)
(stmts
0,1,test1.nim(stmts
(incl "<stdio.h>")
(incl "<assert.h>")
(type :MyProc.e . (proctype . (params (param :x.0 . (ptr MyObject3.m)) (param :y.0 . (ptr MyObject4.m))) MyObject2.m . ))
Expand Down
2 changes: 1 addition & 1 deletion tests/nifc/selectany/t1.nif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(.nif24)
(stmts
0,1,test1.nim(stmts
(incl "<stdio.h>")

(proc :genericProc.c . (void) (pragmas (selectany)) (stmts
Expand Down
2 changes: 1 addition & 1 deletion tests/nifc/selectany/t2.nif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(.nif24)
(stmts
0,1,test2.nim(stmts
(incl "<stdio.h>")
(proc :genericProc.c . (void) (pragmas (selectany)) (stmts
(call printf.c "hello %s\0A" "file t2")
Expand Down
2 changes: 1 addition & 1 deletion tests/nifc/selectany/t3.nif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(.nif24)
(stmts
0,1,test3.nim(stmts
(incl "<stdio.h>")
(proc :genericProc.c . (void) (pragmas (selectany)) (stmts
(call printf.c "hello %s\0A" "file t3")
Expand Down
2 changes: 1 addition & 1 deletion tests/nifc/try.nif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(.nif24)
(stmts
0,1,test1.nim(stmts
(incl "<assert.h>")
(incl "<stdio.h>")

Expand Down
Loading