summaryrefslogtreecommitdiff
path: root/sources/scalac/transformer/matching/PatternNodeCreator.java
diff options
context:
space:
mode:
Diffstat (limited to 'sources/scalac/transformer/matching/PatternNodeCreator.java')
-rw-r--r--sources/scalac/transformer/matching/PatternNodeCreator.java82
1 files changed, 33 insertions, 49 deletions
diff --git a/sources/scalac/transformer/matching/PatternNodeCreator.java b/sources/scalac/transformer/matching/PatternNodeCreator.java
index 6e62f54751..909f44a7ee 100644
--- a/sources/scalac/transformer/matching/PatternNodeCreator.java
+++ b/sources/scalac/transformer/matching/PatternNodeCreator.java
@@ -13,7 +13,7 @@ import Tree.*;
import java.util.Vector ;
/** PatternNode factory.
- * we inherit the globals from PatternTool
+ * we inherit the globals from PatternTool.
*/
public class PatternNodeCreator extends PatternTool {
@@ -26,46 +26,36 @@ public class PatternNodeCreator extends PatternTool {
return node;
}
public SeqContainerPat SeqContainerPat(int pos, Type type, Tree seqpat) {
- Symbol sym = newVar(Position.FIRSTPOS, type);
+ Symbol sym = newVar(Position.NOPOS, type);
SeqContainerPat node = new SeqContainerPat(sym, seqpat);
node.pos = pos;
node.type = type;
return node;
}
- /* MY CODE
- public static SequencePat SequencePat(int pos, Tree seqpat, int case_ix) {
- SequencePat node = new SequencePat( seqpat, case_ix );
- node.pos = pos;
- return node;
- }
- */
- public static DefaultPat DefaultPat(int pos, Type type) {
- DefaultPat node = new DefaultPat();
- node.pos = pos;
- node.type = type;
- return node;
- }
-
- public ConstrPat ConstrPat(int pos, Type type) {
- ConstrPat node = new ConstrPat(newVar(pos, type));
- node.pos = pos;
- node.type = type;
- return node;
- }
-
- public static ConstantPat ConstantPat(int pos, Type type, Object value) {
- ConstantPat node = new ConstantPat( value );
- node.pos = pos;
- node.type = type;
- return node;
- }
-
- public static VariablePat VariablePat(int pos, Tree tree) {
- VariablePat node = new VariablePat( tree );
- node.pos = pos;
- node.type = tree.type;
- return node;
- }
+ public static DefaultPat DefaultPat(int pos, Type type) {
+ DefaultPat node = new DefaultPat();
+ node.pos = pos;
+ node.type = type;
+ return node;
+ }
+ public ConstrPat ConstrPat(int pos, Type type) {
+ ConstrPat node = new ConstrPat(newVar(pos, type));
+ node.pos = pos;
+ node.type = type;
+ return node;
+ }
+ public static ConstantPat ConstantPat(int pos, Type type, Object value) {
+ ConstantPat node = new ConstantPat( value );
+ node.pos = pos;
+ node.type = type;
+ return node;
+ }
+ public static VariablePat VariablePat(int pos, Tree tree) {
+ VariablePat node = new VariablePat( tree );
+ node.pos = pos;
+ node.type = tree.type;
+ return node;
+ }
// factories
@@ -75,13 +65,11 @@ public class PatternNodeCreator extends PatternTool {
node.type = type;
return node;
}
-
public Body Body(int pos, ValDef[] bound, Tree guard, Tree body) {
Body node = new Body(new ValDef[][]{bound}, new Tree[]{guard}, new Tree[]{body});
node.pos = pos;
return node;
}
-
public TermSymbol newVar(int pos, Name name, Type type) {
TermSymbol sym = new TermSymbol(pos, name, owner, 0);
sym.setType(type);
@@ -89,20 +77,16 @@ public class PatternNodeCreator extends PatternTool {
//System.out.println("owner: "+sym.owner());
return sym;
}
-
public TermSymbol newVar(int pos, Type type) {
return newVar(pos, fresh.newName("temp"), type);
}
- /** the owner of the variable symbols that might be create
- */
- Symbol owner;
-
- public PatternNodeCreator( Unit unit, Infer infer, Symbol owner ) {
- super( unit, infer );
- assert owner != null;
- this.owner = owner;
- }
-
+ /** the owner of the variable symbols that might be created */
+ Symbol owner;
+ public PatternNodeCreator( Unit unit, Infer infer, Symbol owner ) {
+ super( unit, infer );
+ assert owner != null;
+ this.owner = owner;
+ }
}