diff options
author | paltherr <paltherr@epfl.ch> | 2003-03-13 12:27:35 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2003-03-13 12:27:35 +0000 |
commit | 1501b629e813824783eb0fdb8092feb3bb9d4b70 (patch) | |
tree | 163c9d6fd3021f83275473d67bdcc3fe388d04f7 /sources | |
parent | 2301c181a8fc73353cb6dea995caadb0db790079 (diff) | |
download | scala-1501b629e813824783eb0fdb8092feb3bb9d4b70.tar.gz scala-1501b629e813824783eb0fdb8092feb3bb9d4b70.tar.bz2 scala-1501b629e813824783eb0fdb8092feb3bb9d4b70.zip |
- Adapted to the new module schema
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scala/tools/scalai/Compiler.java | 44 | ||||
-rw-r--r-- | sources/scalac/Global.java | 3 |
2 files changed, 13 insertions, 34 deletions
diff --git a/sources/scala/tools/scalai/Compiler.java b/sources/scala/tools/scalai/Compiler.java index ad2386225a..0ea8e67c6d 100644 --- a/sources/scala/tools/scalai/Compiler.java +++ b/sources/scala/tools/scalai/Compiler.java @@ -44,7 +44,6 @@ public class Compiler { private final Global global; private final Definitions definitions; - private final TreeGen make; private final Constants constants; private final ClassLoader loader; private final Environment environment; @@ -57,7 +56,6 @@ public class Compiler { public Compiler(Global global, Evaluator evaluator, SymbolWriter writer) { this.global = global; this.definitions = global.definitions; - this.make = global.treeGen; this.constants = new Constants(); this.loader = new PathClassLoader(global.classPath); scala.runtime.RunTime.setClassLoader(loader); @@ -336,31 +334,25 @@ public class Compiler { return; case ValDef(_, _, _, Tree body): - if (symbol.isModule()) { - environment.insertVariable(symbol, Variable.Module(new CodePromise(new ModuleBuilder(this, symbol, body)), null)); - if (mustShowDefinition(symbol)) writer.write1(symbol); - } else { - Variable variable = environment.insertVariable(symbol, Variable.Global(constants.zero(symbol.type()))); - if (body != Tree.Empty) buffer.add(make.Assign(make.Ident(symbol), body)); - if (mustShowDefinition(symbol)) buffer.add( - make.Apply(make.Select(make.Ident(WRITER), WRITER_WRITE), - new Tree[] { - make.Ident(newGlobalVariable(SYMBOL_TYPE, symbol)), - make.Ident(symbol)})); + assert symbol.isModule() : Debug.show(symbol); + environment.insertVariable(symbol, Variable.Module(new CodePromise(new ModuleBuilder(this, symbol, body)), null)); + if (interactive && writer != null && + symbol.name.toString().startsWith(global.CONSOLE_S)) // !!! + { + global.prevPhase(); + buffer.add(global.treeGen.Ident(symbol)); + global.nextPhase(); } return; case DefDef(_, _, _, _, _, _): + // !!! impossible ? => remove ! CodePromise function = compile(symbol, (Tree.DefDef)tree); environment.insertFunction(symbol, Function.Global(function)); - if (isEntryPoint(symbol)) { - buffer.add(make.Apply(make.Ident(symbol), new Tree[0])); - } else if (mustShowDefinition(symbol)) { - writer.write1(symbol); - } return; default: + // !!! impossible ? => remove ! buffer.add(tree); return; } @@ -372,22 +364,6 @@ public class Compiler { // !!! move elsewhere ? public static final Name MAIN_N = Name.fromString("main"); - private boolean isEntryPoint(Symbol symbol) { - if (symbol.name != MAIN_N) return false; - switch (symbol.type()) { - case MethodType(Symbol[] vparams, _): return vparams.length == 0; - default: return true; - } - } - - private boolean mustShowDefinition(Symbol symbol) { - // !!! the last test is to avoid printing of lifted symbols - return - (interactive && - // !!! symbol.owner() == definitions.CONSOLE_CLASS && - writer != null && symbol.name.lastPos((byte)'$') < 0); // !!! '$' - } - private Symbol newGlobalVariable(Type type, Object value) { Symbol symbol = new TermSymbol(Position.NOPOS, Name.fromString(value.toString()), definitions.ROOT, 0); diff --git a/sources/scalac/Global.java b/sources/scalac/Global.java index 05184bb250..0a8e6f5add 100644 --- a/sources/scalac/Global.java +++ b/sources/scalac/Global.java @@ -275,6 +275,9 @@ public class Global { printer.end(); } + // !!! <<< Interpreter stuff + public static final String CONSOLE_S = "$console$"; + // !!! >>> Interpreter stuff /** stop the compilation process immediately */ |