CAAS fixes.

--def will now retrieve symbols from the source map correctly. GCC is also
no longer called.
This commit is contained in:
Dominik Picheta 2014-06-16 19:09:58 +01:00
commit 025d8c1c16
2 changed files with 10 additions and 4 deletions

View file

@ -201,7 +201,10 @@ proc commandSuggest =
# issuing the first compile command. This will leave the compiler # issuing the first compile command. This will leave the compiler
# cache in a state where "no recompilation is necessary", but the # cache in a state where "no recompilation is necessary", but the
# cgen pass was never executed at all. # cgen pass was never executed at all.
commandCompileToC() # commandCompileToC()
semanticPasses()
registerPass(cgenPass)
compileProject()
if gDirtyBufferIdx != 0: if gDirtyBufferIdx != 0:
discard compileModule(gDirtyBufferIdx, {sfDirty}) discard compileModule(gDirtyBufferIdx, {sfDirty})
resetModule(gDirtyBufferIdx) resetModule(gDirtyBufferIdx)
@ -424,6 +427,7 @@ proc mainCommand* =
commandEval(mainCommandArg()) commandEval(mainCommandArg())
of "reset": of "reset":
resetMemory() resetMemory()
gGlobalOptions.incl(optCaasEnabled)
of "idetools": of "idetools":
gCmd = cmdIdeTools gCmd = cmdIdeTools
if gEvalExpr != "": if gEvalExpr != "":

View file

@ -286,6 +286,7 @@ proc resetSourceMap*(fileIdx: int32) =
gSourceMaps[fileIdx].lines = @[] gSourceMaps[fileIdx].lines = @[]
proc addToSourceMap(sym: PSym, info: TLineInfo) = proc addToSourceMap(sym: PSym, info: TLineInfo) =
# echo("Adding to source map: ", sym.name.s, " ", info.fileIndex, " ", info.line, " ", info.col)
ensureIdx(gSourceMaps, info.fileIndex) ensureIdx(gSourceMaps, info.fileIndex)
ensureSeq(gSourceMaps[info.fileIndex].lines) ensureSeq(gSourceMaps[info.fileIndex].lines)
ensureIdx(gSourceMaps[info.fileIndex].lines, info.line) ensureIdx(gSourceMaps[info.fileIndex].lines, info.line)
@ -298,14 +299,15 @@ proc defFromLine(entries: var seq[TEntry], col: int32) =
# No need to pay the price for it unless the user requests # No need to pay the price for it unless the user requests
# "goto definition" on a particular line # "goto definition" on a particular line
sort(entries) do (a,b: TEntry) -> int: sort(entries) do (a,b: TEntry) -> int:
return cmp(a.pos, b.pos) return cmp(b.pos, a.pos)
for e in entries: for e in entries:
# currently, the line-infos for most expressions point to # currently, the line-infos for most expressions point to
# one position past the end of the expression. This means # one position past the end of the expression. This means
# that the first expr that ends after the cursor column is # that the first expr that ends after the cursor column is
# the one we are looking for. # the one we are looking for.
if e.pos >= col: # echo(e.pos, " ", col)
if col >= e.pos:
suggestWriteln(symToStr(e.sym, isLocal=false, sectionDef)) suggestWriteln(symToStr(e.sym, isLocal=false, sectionDef))
return return
@ -313,7 +315,7 @@ proc defFromSourceMap*(i: TLineInfo) =
if not ((i.fileIndex < gSourceMaps.len) and if not ((i.fileIndex < gSourceMaps.len) and
(gSourceMaps[i.fileIndex].lines != nil) and (gSourceMaps[i.fileIndex].lines != nil) and
(i.line < gSourceMaps[i.fileIndex].lines.len)): return (i.line < gSourceMaps[i.fileIndex].lines.len)): return
# echo "defFromSourceMap ", i.fileIndex, " ", i.line, " ", i.col
defFromLine(gSourceMaps[i.fileIndex].lines[i.line].entries, i.col) defFromLine(gSourceMaps[i.fileIndex].lines[i.line].entries, i.col)
proc suggestSym*(n: PNode, s: PSym) {.inline.} = proc suggestSym*(n: PNode, s: PSym) {.inline.} =