diff options
author | paltherr <paltherr@epfl.ch> | 2003-03-13 13:30:22 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2003-03-13 13:30:22 +0000 |
commit | 9e6cc7fa40db0b339f2d4d695a5b80636071a19c (patch) | |
tree | ab8bae561754b690d398321b57dcaf9b3b3c7caa /sources/scalac | |
parent | 0f9346336d1ca5f6b5b2ec1c6187ca6ea61f8535 (diff) | |
download | scala-9e6cc7fa40db0b339f2d4d695a5b80636071a19c.tar.gz scala-9e6cc7fa40db0b339f2d4d695a5b80636071a19c.tar.bz2 scala-9e6cc7fa40db0b339f2d4d695a5b80636071a19c.zip |
- Added code to embed console code into a module
- Added code to print last expression from console
Diffstat (limited to 'sources/scalac')
-rw-r--r-- | sources/scalac/Global.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/sources/scalac/Global.java b/sources/scalac/Global.java index 0a8e6f5add..d9ea76ee16 100644 --- a/sources/scalac/Global.java +++ b/sources/scalac/Global.java @@ -271,12 +271,48 @@ public class Global { operation("stopped after phase " + currentPhase.name()); break; } + if (currentPhase == PHASE.PARSER) fix1(); } printer.end(); } // !!! <<< Interpreter stuff public static final String CONSOLE_S = "$console$"; + private static final Name + INTERPRETER_N = Name.fromString("Interpreter"), + SHOW_DEFINITION_N = Name.fromString("showDefinition"), + SHOW_VALUE_DEFINITION_N = Name.fromString("showValueDefinition"), + SHOW_VALUE_N = Name.fromString("showValue"); + + private int module = 0; + + private void fix1() { + for (int i = 0; i < units.length; i++) { + if (units[i].console) fix1(units[i]); + } + } + + private void fix1(Unit unit) { + if (unit.body.length > 0 && unit.body[unit.body.length - 1].isTerm()) { + unit.body[unit.body.length - 1] = + make.Apply(0, + make.Select(0, + make.Select(0, + make.Ident(0, Names.scala), + INTERPRETER_N), + SHOW_VALUE_N), + new Tree[] { + unit.body[unit.body.length - 1]}); + } + unit.body = new Tree[] { + make.ModuleDef(0, 0, Name.fromString(CONSOLE_S+module), Tree.Empty, + make.Template(0, new Tree[]{ + make.Select(0, + make.Ident(0, Names.scala), + Names.Object.toConstrName())}, + unit.body))}; + module++; + } // !!! >>> Interpreter stuff /** stop the compilation process immediately |