summaryrefslogtreecommitdiff
path: root/sources/scalac/ast
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2004-04-04 15:11:35 +0000
committerpaltherr <paltherr@epfl.ch>2004-04-04 15:11:35 +0000
commit938d635c43dd677f37a0d2cbd86f2e4c04f24187 (patch)
treec47d373934d474765741f24f2b9d4e6245741e42 /sources/scalac/ast
parent4931414ab41236551cd3c364c630a29b5e93c8ba (diff)
downloadscala-938d635c43dd677f37a0d2cbd86f2e4c04f24187.tar.gz
scala-938d635c43dd677f37a0d2cbd86f2e4c04f24187.tar.bz2
scala-938d635c43dd677f37a0d2cbd86f2e4c04f24187.zip
- Changed Tree.New(Template) to Tree.New(Tree)
Diffstat (limited to 'sources/scalac/ast')
-rw-r--r--sources/scalac/ast/Transformer.java.tmpl5
-rw-r--r--sources/scalac/ast/TreeGen.java63
2 files changed, 33 insertions, 35 deletions
diff --git a/sources/scalac/ast/Transformer.java.tmpl b/sources/scalac/ast/Transformer.java.tmpl
index 1af073fc86..2c8d355587 100644
--- a/sources/scalac/ast/Transformer.java.tmpl
+++ b/sources/scalac/ast/Transformer.java.tmpl
@@ -236,9 +236,8 @@ public class GenTransformer {
// case Throw(Tree expr):
- case New(Template(Tree[] base, Tree[] body)):
- assert base.length == 1 && body.length == 0: tree;
- return gen.New(tree.pos, transform(base[0]));
+ case New(Tree init):
+ return gen.New(tree.pos, transform(init));
case Typed(Tree expr, Tree tpe):
return gen.Typed(tree.pos, transform(expr), transform(tpe));
diff --git a/sources/scalac/ast/TreeGen.java b/sources/scalac/ast/TreeGen.java
index 20b3cab3c4..6cf6c6cb23 100644
--- a/sources/scalac/ast/TreeGen.java
+++ b/sources/scalac/ast/TreeGen.java
@@ -458,6 +458,33 @@ public class TreeGen implements Kinds, Modifiers, TypeTags {
}
//########################################################################
+ // Public Methods - Building new instances
+
+ /** Builds a New node corresponding to "new <init>". */
+ public New New(int pos, Tree init) {
+ New tree = make.New(pos, init);
+ tree.setType(init.type);
+ // after AddConstructor use type of symbol
+ switch (init) {
+ case Apply(TypeApply(Tree fun, Tree[] targs), _):
+ Symbol sym = fun.symbol();
+ if (sym == null || sym.isConstructor()) break;
+ Type[] args = Tree.typeOf(targs);
+ tree.setType(Type.appliedType(sym.owner().nextType(), args));
+ break;
+ case Apply(Tree fun, _):
+ Symbol sym = fun.symbol();
+ if (sym == null || sym.isConstructor()) break;
+ tree.setType(sym.owner().nextType());
+ break;
+ }
+ return tree;
+ }
+ public New New(Tree init) {
+ return New(init.pos, init);
+ }
+
+ //########################################################################
// Public Methods - Building expressions - Simple nodes
/** Flattens the given tree array by inlining Block nodes. */
@@ -690,32 +717,6 @@ public class TreeGen implements Kinds, Modifiers, TypeTags {
return Return(value.pos, method, value);
}
- /** Builds a New node corresponding to "new <constr>". */
- public Tree New(int pos, Tree constr) {
- Tree[] constrs = { constr };
- Template templ = Template(pos, Symbol.NONE, constrs, Tree.EMPTY_ARRAY);
- New tree = make.New(pos, templ);
- tree.setType(constr.type);
- // after AddConstructor use type of symbol
- switch (constr) {
- case Apply(TypeApply(Tree fun, Tree[] targs), _):
- Symbol sym = fun.symbol();
- if (sym == null || sym.isConstructor()) break;
- Type[] args = Tree.typeOf(targs);
- tree.setType(Type.appliedType(sym.owner().nextType(), args));
- break;
- case Apply(Tree fun, _):
- Symbol sym = fun.symbol();
- if (sym == null || sym.isConstructor()) break;
- tree.setType(sym.owner().nextType());
- break;
- }
- return tree;
- }
- public Tree New(Tree constr) {
- return New(constr.pos, constr);
- }
-
/** Builds a Typed nodes with given value and type. */
public Typed Typed(int pos, Tree value, Tree type) {
Typed tree = make.Typed(pos, value, type);
@@ -1130,9 +1131,8 @@ public class TreeGen implements Kinds, Modifiers, TypeTags {
changeOwner(body, owner, applyMeth);
Tree[] memberTrees = { DefDef(applyMeth, body) };
Tree classDef = ClassDef(clazz, memberTrees);
- Tree alloc = New(mkApply__(mkPrimaryConstructorLocalRef(pos, clazz)))
- .setType(parentTypes[1]); // !!!
- return mkBlock(classDef, alloc);
+ Tree alloc = New(mkApply__(mkPrimaryConstructorLocalRef(pos, clazz)));
+ return mkBlock(classDef, Typed(alloc, parentTypes[1])); // !!! Typed
}
@@ -1151,9 +1151,8 @@ public class TreeGen implements Kinds, Modifiers, TypeTags {
makeVisitorMethod(pos, Names.isDefinedAt, isDefinedAtVisitor,
pattype, definitions.BOOLEAN_TYPE(), clazz, owner)};
Tree classDef = ClassDef(clazz, memberTrees);
- Tree alloc = New(mkApply__(mkPrimaryConstructorLocalRef(pos, clazz)))
- .setType(parentTypes[1]); // !!!
- return mkBlock(classDef, alloc);
+ Tree alloc = New(mkApply__(mkPrimaryConstructorLocalRef(pos, clazz)));
+ return mkBlock(classDef, Typed(alloc, parentTypes[1])); // !!! Typed
}
//where
private Tree makeVisitorMethod(int pos, Name name, Tree visitor,