diff --git a/src/org/rascalmpl/exceptions/RascalStackOverflowError.java b/src/org/rascalmpl/exceptions/RascalStackOverflowError.java index cecee677b0..934599e179 100644 --- a/src/org/rascalmpl/exceptions/RascalStackOverflowError.java +++ b/src/org/rascalmpl/exceptions/RascalStackOverflowError.java @@ -36,7 +36,7 @@ public Throw makeThrow() { Environment env = deepestEnvironment; while (env != null) { - trace.add(env.getLocation(), env.getName()); + trace.add(env.getCreatorLocation(), env.getName()); env = env.getCallerScope(); } diff --git a/src/org/rascalmpl/interpreter/Evaluator.java b/src/org/rascalmpl/interpreter/Evaluator.java index d5fb66fd6c..f3572a4b20 100755 --- a/src/org/rascalmpl/interpreter/Evaluator.java +++ b/src/org/rascalmpl/interpreter/Evaluator.java @@ -578,7 +578,7 @@ public IValue main(IRascalMonitor monitor, String module, String function, Strin ModuleEnvironment modEnv = getHeap().getModule(module); setCurrentEnvt(modEnv); - Name name = Names.toName(function, modEnv.getLocation()); + Name name = Names.toName(function, modEnv.getCreatorLocation()); Result func = getCurrentEnvt().getVariable(name); @@ -633,7 +633,7 @@ public IValue main(IRascalMonitor monitor, String module, String function, Map func = getCurrentEnvt().getVariable(name); @@ -690,7 +690,7 @@ public IValue call(String name, String module, Map kwArgs, IValu } private IValue call(String name, Map kwArgs, IValue... args) { - QualifiedName qualifiedName = Names.toQualifiedName(name, getCurrentEnvt().getLocation()); + QualifiedName qualifiedName = Names.toQualifiedName(name, getCurrentEnvt().getCreatorLocation()); setCurrentAST(qualifiedName); return call(qualifiedName, kwArgs, args); } @@ -807,7 +807,7 @@ public StackTrace getStackTrace() { StackTrace trace = new StackTrace(); Environment env = currentEnvt; while (env != null) { - trace.add(env.getLocation(), env.getName()); + trace.add(env.getCreatorLocation(), env.getName()); env = env.getCallerScope(); } return trace.freeze(); @@ -1174,13 +1174,27 @@ private void reloadModules(IRascalMonitor monitor, Set names, ISourceLoc for (String mod : names) { if (heap.existsModule(mod)) { - onHeap.add(mod); + var uri = heap.getModuleURI(mod); + assert uri != null : "guaranteed by Import::loadModule"; + + if (resolverRegistry.exists(vf.sourceLocation(uri))) { + // otherwise the file has been renamed or deleted, and we do + // not add it to the todo list. + onHeap.add(mod); + } + if (recurseToExtending) { + // even if a module was renamed, or deleted, the modules that were + // previously extending it have to be re-evaluated. extendingModules.addAll(heap.getExtendingModules(mod)); } + + // this module starts with a clean slate heap.removeModule(heap.getModule(mod)); } } + + // all extending modules start with a clean slate too. extendingModules.removeAll(names); job(LOADING_JOB_CONSTANT, onHeap.size(), (jobName, step) -> { @@ -1222,7 +1236,7 @@ private void reloadModules(IRascalMonitor monitor, Set names, ISourceLoc affectedModules.add(mod); } else { - warning("could not reimport " + imp, errorLocation); + warning("File of previously imported module " + imp + " is not available anymore.", errorLocation); } } } @@ -1240,7 +1254,7 @@ private void reloadModules(IRascalMonitor monitor, Set names, ISourceLoc env.addExtend(ext); } else { - warning("could not re-extend " + ext, errorLocation); + warning("File of previously extended module " + ext + " is not available anymore.", errorLocation); } } } @@ -1326,7 +1340,7 @@ public void pushEnv() { } private ISourceLocation getCurrentLocation() { - return currentAST != null ? currentAST.getLocation() : getCurrentEnvt().getLocation(); + return currentAST != null ? currentAST.getLocation() : getCurrentEnvt().getCreatorLocation(); } @Override @@ -1774,7 +1788,7 @@ public IRascalFrame getTopFrame() { @Override public ISourceLocation getCurrentPointOfExecution() { AbstractAST cpe = getCurrentAST(); - return cpe != null ? cpe.getLocation() : getCurrentEnvt().getLocation(); + return cpe != null ? cpe.getLocation() : getCurrentEnvt().getCreatorLocation(); } @Override diff --git a/src/org/rascalmpl/interpreter/env/Environment.java b/src/org/rascalmpl/interpreter/env/Environment.java index 711693a1fd..936fd4d586 100644 --- a/src/org/rascalmpl/interpreter/env/Environment.java +++ b/src/org/rascalmpl/interpreter/env/Environment.java @@ -205,7 +205,7 @@ public String getName() { /** * @return the location where this environment was created (i.e. call site) for use in tracing */ - public ISourceLocation getLocation() { + public ISourceLocation getCreatorLocation() { return loc; } diff --git a/src/org/rascalmpl/interpreter/env/GlobalEnvironment.java b/src/org/rascalmpl/interpreter/env/GlobalEnvironment.java index d1ec3fa7fc..7afa17c456 100644 --- a/src/org/rascalmpl/interpreter/env/GlobalEnvironment.java +++ b/src/org/rascalmpl/interpreter/env/GlobalEnvironment.java @@ -149,11 +149,9 @@ public ModuleEnvironment getModule(QualifiedName name, AbstractAST ast) { return module; } - public boolean existsModule(String name) { return moduleEnvironment.containsKey(name); } - @Override public String toString(){ diff --git a/src/org/rascalmpl/interpreter/result/AbstractFunction.java b/src/org/rascalmpl/interpreter/result/AbstractFunction.java index d6e0248097..66b283fb11 100644 --- a/src/org/rascalmpl/interpreter/result/AbstractFunction.java +++ b/src/org/rascalmpl/interpreter/result/AbstractFunction.java @@ -346,7 +346,7 @@ protected Type bindTypeParameters(Type actualStaticTypes, IValue[] actuals, Type if (actualStaticTypes.isOpen()) { // we have to make the environment hygenic now, because the caller scope // may have the same type variable names as the current scope - actualStaticTypes = renameType(actualStaticTypes, renamings, env.getLocation()); + actualStaticTypes = renameType(actualStaticTypes, renamings, env.getCreatorLocation()); } diff --git a/src/org/rascalmpl/interpreter/result/ConstructorFunction.java b/src/org/rascalmpl/interpreter/result/ConstructorFunction.java index c55440e0a7..702135f3e9 100644 --- a/src/org/rascalmpl/interpreter/result/ConstructorFunction.java +++ b/src/org/rascalmpl/interpreter/result/ConstructorFunction.java @@ -79,7 +79,7 @@ public Result computeDefaultKeywordParameter(String label, IConstructor Set kws = callerEnvironment.lookupGenericKeywordParameters(constructorType.getAbstractDataType()); IWithKeywordParameters wkw = value.asWithKeywordParameters(); Environment old = ctx.getCurrentEnvt(); - Environment resultEnv = new Environment(declarationEnvironment, callerEnvironment, callerEnvironment.getLocation(), URIUtil.rootLocation("initializer"), "keyword parameter initializer"); + Environment resultEnv = new Environment(declarationEnvironment, callerEnvironment, callerEnvironment.getCreatorLocation(), URIUtil.rootLocation("initializer"), "keyword parameter initializer"); // first we compute the keyword parameters for the abstract data-type: for (GenericKeywordParameters gkw : kws) { diff --git a/src/org/rascalmpl/interpreter/result/JavaMethod.java b/src/org/rascalmpl/interpreter/result/JavaMethod.java index c315763709..881681f8fa 100644 --- a/src/org/rascalmpl/interpreter/result/JavaMethod.java +++ b/src/org/rascalmpl/interpreter/result/JavaMethod.java @@ -202,7 +202,7 @@ private Map fastBindTypeParameters(Type[] actualStaticTypes, IValue[ // we have to make the environment hygenic now, because the caller scope // may have the same type variable names as the current scope renamings = new HashMap<>(); - actualStaticTypes = fastRenameType(actualStaticTypes, renamings, env.getLocation()); + actualStaticTypes = fastRenameType(actualStaticTypes, renamings, env.getCreatorLocation()); } else { renamings = Collections.emptyMap(); diff --git a/src/org/rascalmpl/interpreter/utils/Profiler.java b/src/org/rascalmpl/interpreter/utils/Profiler.java index 40eba86065..f7671310df 100644 --- a/src/org/rascalmpl/interpreter/utils/Profiler.java +++ b/src/org/rascalmpl/interpreter/utils/Profiler.java @@ -111,10 +111,10 @@ public void run(){ env = env.getParent(); } if (env != null) { - Count currentCount = frame.get(env.getLocation()); + Count currentCount = frame.get(env.getCreatorLocation()); if (currentCount == null) { - frame.put(env.getLocation(), new Count()); - names.put(env.getLocation(), env.getName()); + frame.put(env.getCreatorLocation(), new Count()); + names.put(env.getCreatorLocation(), env.getName()); } else { currentCount.increment(); diff --git a/src/org/rascalmpl/semantics/dynamic/Import.java b/src/org/rascalmpl/semantics/dynamic/Import.java index 5998c2d523..79401aa90b 100644 --- a/src/org/rascalmpl/semantics/dynamic/Import.java +++ b/src/org/rascalmpl/semantics/dynamic/Import.java @@ -563,7 +563,7 @@ else if (reg.exists(parserCacheFile)) { } } catch (URISyntaxException | ClassNotFoundException | IOException e) { - eval.warning("reusing parsers failed during module import: " + e.getMessage(), env.getLocation()); + eval.warning("reusing parsers failed during module import: " + e.getMessage(), env.getCreatorLocation()); } return result;