summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2003-10-31 12:03:01 +0000
committerpaltherr <paltherr@epfl.ch>2003-10-31 12:03:01 +0000
commit8c3432973c2a9519bdf8e2e74cf7f8a942414871 (patch)
tree4eaf4fb3e33984ea06f463ce248c350d48ee3928 /sources
parent8ff5e6c0e540e1b186ffe7925490f2c3f2a34e74 (diff)
downloadscala-8c3432973c2a9519bdf8e2e74cf7f8a942414871.tar.gz
scala-8c3432973c2a9519bdf8e2e74cf7f8a942414871.tar.bz2
scala-8c3432973c2a9519bdf8e2e74cf7f8a942414871.zip
- Changed the return type of initializers to Un...
- Changed the return type of initializers to Unit also for interpreter
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/tools/scalai/Code.java2
-rw-r--r--sources/scala/tools/scalai/ExpressionCompiler.java10
-rw-r--r--sources/scalac/transformer/AddConstructors.java8
3 files changed, 12 insertions, 8 deletions
diff --git a/sources/scala/tools/scalai/Code.java b/sources/scala/tools/scalai/Code.java
index 69d68de2a1..28796238b0 100644
--- a/sources/scala/tools/scalai/Code.java
+++ b/sources/scala/tools/scalai/Code.java
@@ -21,7 +21,7 @@ public class Code {
public case Label(Symbol symbol, Variable[] variables, Code expression);
- public case Create(ScalaTemplate template); // !!! remove ?
+ public case Create(ScalaTemplate template);
public case Invoke(Code target, Function function, Code[] arguments, int pos);
public case Load(Code target, Variable variable);
public case Store(Code target, Variable variable, Code expression);
diff --git a/sources/scala/tools/scalai/ExpressionCompiler.java b/sources/scala/tools/scalai/ExpressionCompiler.java
index b88d1253ce..9cdbb483bc 100644
--- a/sources/scala/tools/scalai/ExpressionCompiler.java
+++ b/sources/scala/tools/scalai/ExpressionCompiler.java
@@ -133,6 +133,8 @@ public class ExpressionCompiler {
case New(Tree.Template(Tree[] bases, Tree[] body)): // !!!
assert bases.length == 1 : Debug.show(tree);
assert body.length == 0 : Debug.show(tree);
+ Symbol symbol = new scalac.symtab.TermSymbol(tree.pos, Name.fromString("new"), Symbol.NONE, 0); // !!!
+ Variable variable = Variable.Local(context.push());
Code code = compute(bases[0]);
switch (context.lookupTemplate(tree.type().symbol())) {
case Global(ScalaTemplate template):
@@ -140,7 +142,13 @@ public class ExpressionCompiler {
Code.Invoke invoke = (Code.Invoke)code;
// !!! correct ?
assert invoke.target == Code.Self | invoke.target == Code.Null : Debug.show(code);
- invoke.target = Code.Create(template);
+ invoke.target = Code.Load(Code.Null, variable);
+ context.insertVariable(symbol, variable);
+ code = Code.Block(
+ new Code[] {
+ Code.Store(Code.Null, variable, Code.Create(template)),
+ invoke},
+ Code.Load(Code.Null, variable));
}
return code;
diff --git a/sources/scalac/transformer/AddConstructors.java b/sources/scalac/transformer/AddConstructors.java
index bc00cfd709..639328a222 100644
--- a/sources/scalac/transformer/AddConstructors.java
+++ b/sources/scalac/transformer/AddConstructors.java
@@ -84,8 +84,7 @@ public class AddConstructors extends Transformer {
new TermSymbol(classConstr.pos, classConstr.name, owner, flags);
Type constrType = Type.MethodType
- (paramSyms, forINT ? owner.type()
- : global.definitions.UNIT_TYPE());
+ (paramSyms, global.definitions.UNIT_TYPE());
if (tparamSyms.length != 0)
constrType = Type.PolyType(tparamSyms, constrType);
@@ -234,10 +233,7 @@ public class AddConstructors extends Transformer {
rhs = transform(rhs);
subst.removeSymbol(constr.valueParams());
subst.removeSymbol(constr.typeParams());
- Tree result = forINT
- ? gen.This(rhs.pos, constr.constructorClass())
- : gen.mkUnitLit(rhs.pos);
- rhs = gen.mkBlock(new Tree[] { rhs, result });
+ rhs = gen.mkBlock(new Tree[] { rhs, gen.mkUnitLit(rhs.pos) });
return gen.DefDef(init, rhs);
// Substitute the constructor into the 'new' expressions