diff options
Diffstat (limited to 'sources/scalac/transformer/matching')
7 files changed, 55 insertions, 97 deletions
diff --git a/sources/scalac/transformer/matching/Autom2Scala.java b/sources/scalac/transformer/matching/Autom2Scala.java index 102353c8d4..4c302b9c00 100644 --- a/sources/scalac/transformer/matching/Autom2Scala.java +++ b/sources/scalac/transformer/matching/Autom2Scala.java @@ -3,7 +3,6 @@ package scalac.transformer.matching ; import scalac.* ; import scalac.symtab.Symbol ; import scalac.symtab.Type ; -import scalac.symtab.TermSymbol ; import scalac.symtab.Definitions ; import scalac.symtab.Modifiers; import scalac.ast.Tree; diff --git a/sources/scalac/transformer/matching/FreshVariableTraverser.java b/sources/scalac/transformer/matching/FreshVariableTraverser.java index a90bd5bb06..04f9a8a684 100644 --- a/sources/scalac/transformer/matching/FreshVariableTraverser.java +++ b/sources/scalac/transformer/matching/FreshVariableTraverser.java @@ -63,10 +63,9 @@ class FreshVariableTraverser extends VariableTraverser { */ void handleVariableSymbol(Symbol sym) { Symbol helpVar = - new TermSymbol(pos, - fresh.newName(sym.name.toString()), - owner, - 0); + owner.newVariable(pos, + 0, + fresh.newName(sym.name.toString())); helpVar.setType(sym.type()); helpMap.put(sym, helpVar); diff --git a/sources/scalac/transformer/matching/LeftTracerInScala.java b/sources/scalac/transformer/matching/LeftTracerInScala.java index 56604e511d..5a407a7a88 100644 --- a/sources/scalac/transformer/matching/LeftTracerInScala.java +++ b/sources/scalac/transformer/matching/LeftTracerInScala.java @@ -41,24 +41,21 @@ public class LeftTracerInScala extends TracerInScala { this.funSym = owner.newLabel( pos, cf.fresh.newName( "left" )); - this.iterSym = new TermSymbol( pos, - cf.fresh.newName( "iter" ), - owner, - Modifiers.MUTABLE ) + this.iterSym = owner.newVariable( pos, + Modifiers.MUTABLE, + cf.fresh.newName( "iter" )) .setType( cf._seqIterType( elementType ) ) ; - this.stateSym = new TermSymbol( pos, - cf.fresh.newName( "q" ), - owner, - Modifiers.MUTABLE ) + this.stateSym = owner.newVariable( pos, + Modifiers.MUTABLE, + cf.fresh.newName( "q" )) .setType( defs.INT_TYPE() ) ; this.accumType = _accumType( elementType ); this.accumTypeArg = accumType.typeArgs()[0]; - this.accumSym = new TermSymbol( pos, // accumulator - cf.fresh.newName( "acc" ), - owner, - Modifiers.MUTABLE ) + this.accumSym = owner.newVariable( pos, // accumulator + Modifiers.MUTABLE, + cf.fresh.newName( "acc" )) .setType( accumType ); //this.funSym @@ -68,29 +65,19 @@ public class LeftTracerInScala extends TracerInScala { this.funSym .setType( new Type.MethodType( new Symbol[] { // dummy symbol MethodType - new TermSymbol( pos, - cf.fresh.newName( "q" ), // q:int - funSym, - Modifiers.PARAM ) - .setType( defs.INT_TYPE() ), - new TermSymbol( pos, // acc:List[T] accumulator - cf.fresh.newName( "acc" ), - funSym, - Modifiers.PARAM ) - .setType( accumType ) - }, + funSym.newVParam( pos, 0, cf.fresh.newName( "q" ), defs.INT_TYPE()), + funSym.newVParam( pos, 0, cf.fresh.newName( "acc" ), accumType ) }, accumType)); // result type = List[T] - this.resultSym = new TermSymbol(pos, - cf.fresh.newName("trace"), - owner, - 0 ) + this.resultSym = owner.newVariable(pos, + 0, + cf.fresh.newName("trace")) .setType( accumType ) ; - this.curSym = new TermSymbol( pos, CURRENT_ELEM, owner, 0) + this.curSym = owner.newVariable( pos, 0, CURRENT_ELEM ) .setType( elementType ); - this.hasnSym = new TermSymbol( pos, HASNEXT, owner, 0) + this.hasnSym = owner.newVariable( pos, 0, HASNEXT ) .setType( defs.BOOLEAN_TYPE() ); } diff --git a/sources/scalac/transformer/matching/PatternMatcher.java b/sources/scalac/transformer/matching/PatternMatcher.java index 085e0d8d17..380927676f 100644 --- a/sources/scalac/transformer/matching/PatternMatcher.java +++ b/sources/scalac/transformer/matching/PatternMatcher.java @@ -71,10 +71,9 @@ public class PatternMatcher extends PatternTool { this.root.and = mk.Header(selector.pos, selector.type.widen(), gen.Ident(selector.pos, root.symbol())); - this.resultVar = new TermSymbol(selector.pos, - fresh.newName(RESULT_N), - owner, - Modifiers.MUTABLE); + this.resultVar = owner.newVariable(selector.pos, + Modifiers.MUTABLE, + fresh.newName(RESULT_N)); this.resultVar.setType(resultType); this.owner = owner; this.selector = selector; diff --git a/sources/scalac/transformer/matching/PatternNodeCreator.java b/sources/scalac/transformer/matching/PatternNodeCreator.java index dedae105d0..3a0d7cf0b9 100644 --- a/sources/scalac/transformer/matching/PatternNodeCreator.java +++ b/sources/scalac/transformer/matching/PatternNodeCreator.java @@ -99,15 +99,15 @@ public class PatternNodeCreator extends PatternTool { return node; } - public TermSymbol newVar(int pos, Name name, Type type) { - TermSymbol sym = new TermSymbol(pos, name, owner, 0); + public Symbol newVar(int pos, Name name, Type type) { + Symbol sym = owner.newVariable(pos, 0, name); sym.setType(type); //System.out.println("PatternNodeCreator::newVar creates symbol "+sym); //System.out.println("owner: "+sym.owner()); return sym; } - public TermSymbol newVar(int pos, Type type) { + public Symbol newVar(int pos, Type type) { return newVar(pos, fresh.newName("temp"), type); } } diff --git a/sources/scalac/transformer/matching/RightTracerInScala.java b/sources/scalac/transformer/matching/RightTracerInScala.java index 2d41544331..9d6c70e378 100644 --- a/sources/scalac/transformer/matching/RightTracerInScala.java +++ b/sources/scalac/transformer/matching/RightTracerInScala.java @@ -87,11 +87,10 @@ public class RightTracerInScala extends TracerInScala { */ void makeHelpVar( Symbol realVar, boolean keepType ) { - Symbol helpVar = new TermSymbol( cf.pos, - cf.fresh.newName( realVar.name - .toString()+"RTIS" ), - owner, - 0); + Symbol helpVar = owner.newVariable( cf.pos, + 0, + cf.fresh.newName( realVar.name + .toString()+"RTIS" )); Tree rhs; //System.out.println("RTiS making helpvar : "+realVar+" -> "+helpVar); @@ -129,41 +128,29 @@ public class RightTracerInScala extends TracerInScala { this.funSym = owner.newLabel( pos, cf.fresh.newName( "right" )); - this.iterSym = new TermSymbol( pos, - cf.fresh.newName("iter"), - owner, - Modifiers.MUTABLE ) + this.iterSym = owner.newVariable( pos, + Modifiers.MUTABLE, + cf.fresh.newName("iter")) .setType( cf.SeqTraceType( elementType )); - this.stateSym = new TermSymbol( pos, - cf.fresh.newName("q"), - owner, - Modifiers.MUTABLE ) + this.stateSym = owner.newVariable ( pos, + Modifiers.MUTABLE, + cf.fresh.newName("q")) .setType( defs.INT_TYPE() ) ; - this.curSym = new TermSymbol( pos, - cf.fresh.newName("cur"), - owner, - 0) + this.curSym = owner.newVariable( pos, + Modifiers.MUTABLE, + cf.fresh.newName("cur")) .setType( elementType ) ; - this.targetSym = new TermSymbol( pos, - cf.fresh.newName("p"), - owner, - 0) + this.targetSym = owner.newVariable( pos, + Modifiers.MUTABLE, + cf.fresh.newName("p")) .setType( defs.INT_TYPE() ) ; funSym.setType( new Type.MethodType( new Symbol[] { // dummy symbol MethodType - new TermSymbol( pos, - cf.fresh.newName("iter"), // iter:List[Pair[int,T]] - funSym, - Modifiers.PARAM ) - .setType( cf.SeqTraceType( elementType )) , - new TermSymbol( pos, - cf.fresh.newName( "q" ), // q:int - funSym, - Modifiers.PARAM ) - .setType( defs.INT_TYPE() ) }, + funSym.newVParam( pos, 0, cf.fresh.newName("iter"), cf.SeqTraceType( elementType )), + funSym.newVParam( pos, 0, cf.fresh.newName( "q" ), defs.INT_TYPE()) }, defs.UNIT_TYPE() )); // result } diff --git a/sources/scalac/transformer/matching/WordAutomInScala.java b/sources/scalac/transformer/matching/WordAutomInScala.java index c1d5c439f6..dff5603bb6 100644 --- a/sources/scalac/transformer/matching/WordAutomInScala.java +++ b/sources/scalac/transformer/matching/WordAutomInScala.java @@ -15,7 +15,6 @@ import scalac.ast.Tree; import scalac.ast.TreeGen; import scalac.symtab.Type; import scalac.symtab.Symbol; -import scalac.symtab.TermSymbol; // test import scalac.symtab.Modifiers; // test import scalac.transformer.TransMatch.Matcher; //import scalac.typechecker.*; @@ -71,42 +70,30 @@ public class WordAutomInScala extends Autom2Scala { this.funSym = owner.newLabel( pos, cf.fresh.newName( "matcher" )); - this.iterSym = new TermSymbol( pos, - cf.fresh.newName("iter"), - owner, - Modifiers.MUTABLE /*| NOT : Modifiers.PARAM*/ ) + this.iterSym = owner.newVariable( pos, + Modifiers.MUTABLE, + cf.fresh.newName("iter")) .setType( cf._seqIterType( elementType ) ) ; - this.stateSym = new TermSymbol( pos, - cf.fresh.newName("q"), - owner, - Modifiers.MUTABLE ) + this.stateSym = owner.newVariable( pos, + Modifiers.MUTABLE, + cf.fresh.newName("q")) .setType( defs.INT_TYPE() ) ; - this.resultSym = new TermSymbol( pos, - cf.fresh.newName("swRes"), - owner, - 0 ) + this.resultSym = owner.newVariable( pos, + Modifiers.MUTABLE, + cf.fresh.newName("swRes")) .setType( defs.INT_TYPE() ) ; this.funSym .setType( new Type.MethodType( new Symbol[] { - new TermSymbol( pos, - cf.fresh.newName("q"), - funSym, - Modifiers.PARAM ).setType( defs.INT_TYPE() ) + funSym.newVParam( pos, 0, cf.fresh.newName("q"), defs.INT_TYPE()) }, defs.INT_TYPE() )); - this.curSym = new TermSymbol( pos, - CURRENT_ELEM, - owner, - 0) + this.curSym = owner.newVariable( pos, 0, CURRENT_ELEM ) .setType( elementType ); - this.hasnSym = new TermSymbol( pos, - HASNEXT, - owner, - 0) + this.hasnSym = owner.newVariable( pos, 0, HASNEXT ) .setType( defs.BOOLEAN_TYPE() ); } |