Permalink
Browse files

Factored name of Rascal shell out into a constant field member in Mod…

…uleEnvironment, replacing the existing uses; modified external imports to use this to detect when we are importing a resource in the console, which then generates the resource module into cwd
  • Loading branch information...
1 parent cb21fe4 commit e24611b354fa7a66f2da91a64bea303f6dd76cfc @mahills mahills committed Jul 30, 2012
@@ -34,7 +34,6 @@
public class JavaToRascal {
- private final static String SHELL_MODULE = "$shell$";
private GlobalEnvironment heap = new GlobalEnvironment();
final private Evaluator evaluator;
@@ -62,7 +61,7 @@ public Evaluator getEvaluator() {
public JavaToRascal(PrintWriter stdout, PrintWriter stderr) {
this.evaluator = new Evaluator(vf, stderr, stdout,
- new ModuleEnvironment(SHELL_MODULE, heap), heap);
+ new ModuleEnvironment(ModuleEnvironment.SHELL_MODULE, heap), heap);
}
public JavaToRascal(Evaluator evaluator) {
@@ -75,6 +75,8 @@
protected Map<String, AbstractFunction> resourceImporters;
protected static final TypeFactory TF = TypeFactory.getInstance();
+
+ public final static String SHELL_MODULE = "$shell$";
public ModuleEnvironment(String name, GlobalEnvironment heap) {
super(name);
@@ -98,7 +98,13 @@ public External(IConstructor node, QualifiedName name,
try {
URIResolverRegistry reg = eval.getResolverRegistry();
- URI ur = eval.getRascalResolver().getRootForModule((URI.create("rascal://" + eval.getCurrentModuleEnvironment().getName())));
+ String moduleEnvName = eval.getCurrentModuleEnvironment().getName();
+ URI ur = null;
+ if (moduleEnvName.equals(ModuleEnvironment.SHELL_MODULE)) {
+ ur = URI.create("cwd:///");
+ } else {
+ ur = eval.getRascalResolver().getRootForModule((URI.create("rascal://" + moduleEnvName)));
+ }
Result<?> loc = new SourceLocationResult(TF.sourceLocationType(), VF.sourceLocation(ur), eval);
String modulePath = moduleName.replaceAll("::", "/");
loc = loc.add(ResultFactory.makeResult(TF.stringType(), VF.string(modulePath), eval));

0 comments on commit e24611b

Please sign in to comment.