summaryrefslogtreecommitdiff
path: root/sources/scalac/Global.java
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2003-03-17 17:30:47 +0000
committerpaltherr <paltherr@epfl.ch>2003-03-17 17:30:47 +0000
commit19458ed8e2fe1522805cf4f16dba07781d141eec (patch)
tree9bee148e3bd4d26fce03fc137b1facacd4f348f0 /sources/scalac/Global.java
parentacd1b06b4e803e830cb4047475861b60a31bb807 (diff)
downloadscala-19458ed8e2fe1522805cf4f16dba07781d141eec.tar.gz
scala-19458ed8e2fe1522805cf4f16dba07781d141eec.tar.bz2
scala-19458ed8e2fe1522805cf4f16dba07781d141eec.zip
- Fixed to also print the type of the last term
Diffstat (limited to 'sources/scalac/Global.java')
-rw-r--r--sources/scalac/Global.java40
1 files changed, 26 insertions, 14 deletions
diff --git a/sources/scalac/Global.java b/sources/scalac/Global.java
index cb0d30dc44..4c7df2943e 100644
--- a/sources/scalac/Global.java
+++ b/sources/scalac/Global.java
@@ -292,6 +292,7 @@ public class Global {
SHOW_VALUE_DEFINITION_N = Name.fromString("showValueDefinition"),
SHOW_VALUE_N = Name.fromString("showValue");
private Symbol INTERPRETER;
+ private Symbol SHOW_VALUE;
private Symbol SHOW_DEFINITION;
private Symbol SHOW_VALUE_DEFINITION;
@@ -301,6 +302,12 @@ public class Global {
return INTERPRETER;
}
+ private Symbol SHOW_VALUE() {
+ if (SHOW_VALUE == null)
+ SHOW_VALUE = INTERPRETER().lookup(SHOW_VALUE_N);
+ return SHOW_VALUE;
+ }
+
private Symbol SHOW_DEFINITION() {
if (SHOW_DEFINITION == null)
SHOW_DEFINITION = INTERPRETER().lookup(SHOW_DEFINITION_N);
@@ -327,20 +334,8 @@ public class Global {
}
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]});
- } else if (module == 0) {
- // !!! make sure that Interpreter.scala is compiled
- SHOW_DEFINITION();
- }
+ // !!! make sure that Interpreter.scala is compiled
+ SHOW_DEFINITION();
unit.body = new Tree[] {
make.ModuleDef(0, 0, Name.fromString(CONSOLE_S+module), Tree.Empty,
make.Template(0, new Tree[]{
@@ -363,7 +358,20 @@ public class Global {
switch (unit.body[i]) {
case ModuleDef(_, Name name, _, Tree.Template impl):
if (!name.toString().startsWith(CONSOLE_S)) break;
+ if (impl.body.length <= 0) break;
imports.add(unit.body[i].symbol());
+ Tree last = impl.body[impl.body.length - 1];
+ if (last.isTerm()) {
+ impl.body[impl.body.length - 1] =
+ treeGen.Apply(
+ treeGen.Select(
+ treeGen.mkRef(0, INTERPRETER()),
+ SHOW_VALUE()),
+ new Tree[] {
+ last,
+ make.Literal(0, show(last.type())).setType(
+ definitions.JAVA_STRING_TYPE)});
+ }
TreeList body = new TreeList();
for (int j = 0; j < impl.body.length; j++)
fix2(body, impl.body[j]);
@@ -429,6 +437,10 @@ public class Global {
return buffer.toString();
}
+ private String show(Type type) {
+ return append(new StringBuffer(), type).toString();
+ }
+
private String inner(Symbol symbol) {
switch (symbol.kind) {
case Kinds.CLASS: return " extends ";