From 025d8c1c168d6627e29157eb62d8d34da12658fa Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Mon, 16 Jun 2014 19:09:58 +0100 Subject: [PATCH] CAAS fixes. --def will now retrieve symbols from the source map correctly. GCC is also no longer called. --- compiler/main.nim | 6 +++++- compiler/suggest.nim | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/compiler/main.nim b/compiler/main.nim index b4af49248..ee345c44d 100644 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -201,7 +201,10 @@ proc commandSuggest = # issuing the first compile command. This will leave the compiler # cache in a state where "no recompilation is necessary", but the # cgen pass was never executed at all. - commandCompileToC() + # commandCompileToC() + semanticPasses() + registerPass(cgenPass) + compileProject() if gDirtyBufferIdx != 0: discard compileModule(gDirtyBufferIdx, {sfDirty}) resetModule(gDirtyBufferIdx) @@ -424,6 +427,7 @@ proc mainCommand* = commandEval(mainCommandArg()) of "reset": resetMemory() + gGlobalOptions.incl(optCaasEnabled) of "idetools": gCmd = cmdIdeTools if gEvalExpr != "": diff --git a/compiler/suggest.nim b/compiler/suggest.nim index db95c480f..002e02f4e 100644 --- a/compiler/suggest.nim +++ b/compiler/suggest.nim @@ -286,6 +286,7 @@ proc resetSourceMap*(fileIdx: int32) = gSourceMaps[fileIdx].lines = @[] proc addToSourceMap(sym: PSym, info: TLineInfo) = + # echo("Adding to source map: ", sym.name.s, " ", info.fileIndex, " ", info.line, " ", info.col) ensureIdx(gSourceMaps, info.fileIndex) ensureSeq(gSourceMaps[info.fileIndex].lines) 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 # "goto definition" on a particular line sort(entries) do (a,b: TEntry) -> int: - return cmp(a.pos, b.pos) + return cmp(b.pos, a.pos) for e in entries: # currently, the line-infos for most expressions point to # one position past the end of the expression. This means # that the first expr that ends after the cursor column is # 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)) return @@ -313,7 +315,7 @@ proc defFromSourceMap*(i: TLineInfo) = if not ((i.fileIndex < gSourceMaps.len) and (gSourceMaps[i.fileIndex].lines != nil) and (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) proc suggestSym*(n: PNode, s: PSym) {.inline.} =