disable transitive closure computations; only semcheck procs that have the cursor

This commit is contained in:
Andreas Rumpf
2017-02-09 17:40:24 +01:00
parent 5ff6ff28bf
commit 733ed91d33
3 changed files with 41 additions and 25 deletions

View File

@@ -73,7 +73,7 @@ proc addDep*(g: ModuleGraph; m: PSym, dep: int32) =
deps.incl m.position.dependsOn(dep)
# we compute the transitive closure later when quering the graph lazily.
# this improve efficiency quite a lot:
invalidTransitiveClosure = true
#invalidTransitiveClosure = true
proc addIncludeDep*(g: ModuleGraph; module, includeFile: int32) =
discard hasKeyOrPut(inclToMod, includeFile, module)

View File

@@ -1177,11 +1177,22 @@ proc semOverride(c: PContext, s: PSym, n: PNode) =
localError(n.info, errGenerated,
"'destroy' or 'deepCopy' expected for 'override'")
proc cursorInProcAux(n: PNode): bool =
if inCheckpoint(n.info) != cpNone: return true
for i in 0..<n.safeLen:
if cursorInProcAux(n[i]): return true
proc cursorInProc(n: PNode): bool =
if n.info.fileIndex == gTrackPos.fileIndex:
result = cursorInProcAux(n)
type
TProcCompilationSteps = enum
stepRegisterSymbol,
stepDetermineType,
import compilerlog
proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
validPragmas: TSpecialWords,
phase = stepRegisterSymbol): PNode =
@@ -1303,29 +1314,34 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
# Macros and Templates can have generic parameters, but they are
# only used for overload resolution (there is no instantiation of
# the symbol, so we must process the body now)
pushProcCon(c, s)
if n.sons[genericParamsPos].kind == nkEmpty or usePseudoGenerics:
if not usePseudoGenerics: paramsTypeCheck(c, s.typ)
c.p.wasForwarded = proto != nil
maybeAddResult(c, s, n)
if lfDynamicLib notin s.loc.flags:
# no semantic checking for importc:
let semBody = hloBody(c, semProcBody(c, n.sons[bodyPos]))
# unfortunately we cannot skip this step when in 'system.compiles'
# context as it may even be evaluated in 'system.compiles':
n.sons[bodyPos] = transformBody(c.module, semBody, s)
if not usePseudoGenerics and gIdeCmd in {ideSug, ideCon} and not
cursorInProc(n.sons[bodyPos]):
discard "speed up nimsuggest"
logStr "skipped " & s.name.s
else:
if s.typ.sons[0] != nil and kind != skIterator:
addDecl(c, newSym(skUnknown, getIdent"result", nil, n.info))
openScope(c)
n.sons[bodyPos] = semGenericStmt(c, n.sons[bodyPos])
closeScope(c)
fixupInstantiatedSymbols(c, s)
if sfImportc in s.flags:
# so we just ignore the body after semantic checking for importc:
n.sons[bodyPos] = ast.emptyNode
popProcCon(c)
pushProcCon(c, s)
if n.sons[genericParamsPos].kind == nkEmpty or usePseudoGenerics:
if not usePseudoGenerics: paramsTypeCheck(c, s.typ)
c.p.wasForwarded = proto != nil
maybeAddResult(c, s, n)
if lfDynamicLib notin s.loc.flags:
# no semantic checking for importc:
let semBody = hloBody(c, semProcBody(c, n.sons[bodyPos]))
# unfortunately we cannot skip this step when in 'system.compiles'
# context as it may even be evaluated in 'system.compiles':
n.sons[bodyPos] = transformBody(c.module, semBody, s)
else:
if s.typ.sons[0] != nil and kind != skIterator:
addDecl(c, newSym(skUnknown, getIdent"result", nil, n.info))
openScope(c)
n.sons[bodyPos] = semGenericStmt(c, n.sons[bodyPos])
closeScope(c)
fixupInstantiatedSymbols(c, s)
if sfImportc in s.flags:
# so we just ignore the body after semantic checking for importc:
n.sons[bodyPos] = ast.emptyNode
popProcCon(c)
else:
if proto != nil: localError(n.info, errImplOfXexpected, proto.name.s)
if {sfImportc, sfBorrow} * s.flags == {} and s.magic == mNone:

View File

@@ -297,10 +297,10 @@ proc suggestFieldAccess(c: PContext, n: PNode, outputs: var int) =
suggestOperations(c, n, typ, outputs)
type
TCheckPointResult = enum
TCheckPointResult* = enum
cpNone, cpFuzzy, cpExact
proc inCheckpoint(current: TLineInfo): TCheckPointResult =
proc inCheckpoint*(current: TLineInfo): TCheckPointResult =
if current.fileIndex == gTrackPos.fileIndex:
if current.line == gTrackPos.line and
abs(current.col-gTrackPos.col) < 4: