c2nim compiles again
This commit is contained in:
parent
3c53c4c2b0
commit
4487b614e1
5 changed files with 15 additions and 10 deletions
|
|
@ -283,7 +283,7 @@ proc parsePegLit(p: var TParser): TPeg =
|
||||||
try:
|
try:
|
||||||
result = parsePeg(
|
result = parsePeg(
|
||||||
pattern = if p.tok.xkind == pxStrLit: p.tok.s else: escapePeg(p.tok.s),
|
pattern = if p.tok.xkind == pxStrLit: p.tok.s else: escapePeg(p.tok.s),
|
||||||
filename = p.lex.filename,
|
filename = p.lex.fileIdx.ToFilename,
|
||||||
line = p.lex.linenumber,
|
line = p.lex.linenumber,
|
||||||
col = col)
|
col = col)
|
||||||
getTok(p)
|
getTok(p)
|
||||||
|
|
|
||||||
|
|
@ -410,23 +410,23 @@ proc newFileInfo(fullPath, projPath: string): TFileInfo =
|
||||||
|
|
||||||
proc fileInfoIdx*(filename: string): int32 =
|
proc fileInfoIdx*(filename: string): int32 =
|
||||||
var
|
var
|
||||||
canonical: string
|
canon: string
|
||||||
pseudoPath = false
|
pseudoPath = false
|
||||||
|
|
||||||
try:
|
try:
|
||||||
canonical = canonicalizePath(filename)
|
canon = canonicalizePath(filename)
|
||||||
except:
|
except:
|
||||||
canonical = filename
|
canon = filename
|
||||||
# The compiler uses "filenames" such as `command line` or `stdin`
|
# The compiler uses "filenames" such as `command line` or `stdin`
|
||||||
# This flag indicates that we are working with such a path here
|
# This flag indicates that we are working with such a path here
|
||||||
pseudoPath = true
|
pseudoPath = true
|
||||||
|
|
||||||
if filenameToIndexTbl.hasKey(canonical):
|
if filenameToIndexTbl.hasKey(canon):
|
||||||
result = filenameToIndexTbl[canonical]
|
result = filenameToIndexTbl[canon]
|
||||||
else:
|
else:
|
||||||
result = fileInfos.len.int32
|
result = fileInfos.len.int32
|
||||||
fileInfos.add(newFileInfo(canonical, if pseudoPath: "" else: canonical.shortenDir))
|
fileInfos.add(newFileInfo(canon, if pseudoPath: "" else: canon.shortenDir))
|
||||||
filenameToIndexTbl[canonical] = result
|
filenameToIndexTbl[canon] = result
|
||||||
|
|
||||||
proc newLineInfo*(fileInfoIdx: int32, line, col: int): TLineInfo =
|
proc newLineInfo*(fileInfoIdx: int32, line, col: int): TLineInfo =
|
||||||
result.fileIndex = fileInfoIdx
|
result.fileIndex = fileInfoIdx
|
||||||
|
|
@ -478,6 +478,10 @@ proc ToFilename*(info: TLineInfo): string =
|
||||||
if info.fileIndex < 0: result = "???"
|
if info.fileIndex < 0: result = "???"
|
||||||
else: result = fileInfos[info.fileIndex].projPath
|
else: result = fileInfos[info.fileIndex].projPath
|
||||||
|
|
||||||
|
proc ToFilename*(fileIdx: int32): string =
|
||||||
|
if fileIdx < 0: result = "???"
|
||||||
|
else: result = fileInfos[fileIdx].projPath
|
||||||
|
|
||||||
proc toFullPath*(info: TLineInfo): string =
|
proc toFullPath*(info: TLineInfo): string =
|
||||||
if info.fileIndex < 0: result = "???"
|
if info.fileIndex < 0: result = "???"
|
||||||
else: result = fileInfos[info.fileIndex].fullPath
|
else: result = fileInfos[info.fileIndex].fullPath
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ proc copyStrLast(s: NimString, start, last: int): NimString {.compilerProc.} =
|
||||||
c_memcpy(result.data, addr(s.data[start]), len * sizeof(Char))
|
c_memcpy(result.data, addr(s.data[start]), len * sizeof(Char))
|
||||||
result.data[len] = '\0'
|
result.data[len] = '\0'
|
||||||
else:
|
else:
|
||||||
result = mnewString(0)
|
result = rawNewString(len)
|
||||||
|
|
||||||
proc copyStr(s: NimString, start: int): NimString {.compilerProc.} =
|
proc copyStr(s: NimString, start: int): NimString {.compilerProc.} =
|
||||||
result = copyStrLast(s, start, s.len-1)
|
result = copyStrLast(s, start, s.len-1)
|
||||||
|
|
|
||||||
1
todo.txt
1
todo.txt
|
|
@ -5,6 +5,7 @@ version 0.8.14
|
||||||
- compiler should optimize string creation
|
- compiler should optimize string creation
|
||||||
- marker procs for the GC
|
- marker procs for the GC
|
||||||
- need to generate code to prevent tail call optimization
|
- need to generate code to prevent tail call optimization
|
||||||
|
- write barrier specialization
|
||||||
- warning for implicit openArray -> varargs convention
|
- warning for implicit openArray -> varargs convention
|
||||||
- implement explicit varargs; **but** ``len(varargs)`` problem remains!
|
- implement explicit varargs; **but** ``len(varargs)`` problem remains!
|
||||||
--> solve by implicit conversion from varargs to openarray
|
--> solve by implicit conversion from varargs to openarray
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue