'nimrod pretty': next steps, doesn't work yet
This commit is contained in:
parent
6810a0e3e3
commit
28ad262a46
2 changed files with 14 additions and 7 deletions
|
|
@ -170,6 +170,7 @@ proc CommandPrettyOld =
|
||||||
renderModule(module, getOutFile(mainCommandArg(), "pretty." & NimExt))
|
renderModule(module, getOutFile(mainCommandArg(), "pretty." & NimExt))
|
||||||
|
|
||||||
proc CommandPretty =
|
proc CommandPretty =
|
||||||
|
msgs.gErrorMax = high(int) # do not stop after first error
|
||||||
semanticPasses()
|
semanticPasses()
|
||||||
registerPass(prettyPass)
|
registerPass(prettyPass)
|
||||||
compileProject()
|
compileProject()
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,13 @@ type
|
||||||
fullpath: string
|
fullpath: string
|
||||||
|
|
||||||
var
|
var
|
||||||
gSourceFiles: seq[TSourceFile]
|
gSourceFiles: seq[TSourceFile] = @[]
|
||||||
|
|
||||||
proc loadFile(info: TLineInfo) =
|
proc loadFile(info: TLineInfo) =
|
||||||
let i = info.fileIndex
|
let i = info.fileIndex
|
||||||
if i >= gSourceFiles.len:
|
if i >= gSourceFiles.len:
|
||||||
gSourceFiles.setLen(i)
|
gSourceFiles.setLen(i+1)
|
||||||
|
if gSourceFiles[i].lines.isNil:
|
||||||
gSourceFiles[i].lines = @[]
|
gSourceFiles[i].lines = @[]
|
||||||
let path = info.toFullPath
|
let path = info.toFullPath
|
||||||
gSourceFiles[i].fullpath = path
|
gSourceFiles[i].fullpath = path
|
||||||
|
|
@ -80,11 +81,14 @@ proc identLen(line: string, start: int): int =
|
||||||
inc result
|
inc result
|
||||||
|
|
||||||
proc differ(line: string, a, b: int, x: string): bool =
|
proc differ(line: string, a, b: int, x: string): bool =
|
||||||
var j = 0
|
let y = line[a..b]
|
||||||
for i in a..b:
|
result = cmpIgnoreStyle(y, x) == 0 and y != x
|
||||||
if line[i] != x[j]: return true
|
when false:
|
||||||
inc j
|
var j = 0
|
||||||
return false
|
for i in a..b:
|
||||||
|
if line[i] != x[j]: return true
|
||||||
|
inc j
|
||||||
|
return false
|
||||||
|
|
||||||
var cannotRename = initIntSet()
|
var cannotRename = initIntSet()
|
||||||
|
|
||||||
|
|
@ -106,6 +110,8 @@ proc processSym(c: PPassContext, n: PNode): PNode =
|
||||||
|
|
||||||
let line = gSourceFiles[n.info.fileIndex].lines[n.info.line-1]
|
let line = gSourceFiles[n.info.fileIndex].lines[n.info.line-1]
|
||||||
var first = n.info.col.int - len(s.name.s)
|
var first = n.info.col.int - len(s.name.s)
|
||||||
|
if first < 0: return
|
||||||
|
#inc first, skipIgnoreCase(line, "proc ", first)
|
||||||
if line[first] == '`': inc first
|
if line[first] == '`': inc first
|
||||||
|
|
||||||
if {sfImportc, sfExportc} * s.flags != {}:
|
if {sfImportc, sfExportc} * s.flags != {}:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue