diff options
author | paltherr <paltherr@epfl.ch> | 2003-10-13 16:34:41 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2003-10-13 16:34:41 +0000 |
commit | 785aa26ab6867898b899f938235bc186f96451fe (patch) | |
tree | b9180820fc80573080ee0dfa8eef8979de0164e3 /sources/scalac/transformer/matching | |
parent | 110211dfccf6eaa4cd9811294d1cddf4f272a868 (diff) | |
download | scala-785aa26ab6867898b899f938235bc186f96451fe.tar.gz scala-785aa26ab6867898b899f938235bc186f96451fe.tar.bz2 scala-785aa26ab6867898b899f938235bc186f96451fe.zip |
- Removed field PatternTool.make
- Removed method Autom2Scala._ref
Diffstat (limited to 'sources/scalac/transformer/matching')
4 files changed, 28 insertions, 59 deletions
diff --git a/sources/scalac/transformer/matching/Autom2Scala.java b/sources/scalac/transformer/matching/Autom2Scala.java index 8b2430a07b..e250fa5231 100644 --- a/sources/scalac/transformer/matching/Autom2Scala.java +++ b/sources/scalac/transformer/matching/Autom2Scala.java @@ -81,9 +81,7 @@ public class Autom2Scala { Tree callFun( Tree[] args ) { - return gen.Apply( pos, - gen.Ident( pos, funSym ), - args).setType( funRetType() ); + return gen.mkApply_V(gen.Ident(pos, funSym), args); } @@ -157,7 +155,7 @@ public class Autom2Scala { cf.gen.ValDef( this.hasnSym, cf._hasNext( _iter() ) ), cf.gen.ValDef( this.curSym, - cf.If( _ref( hasnSym ),//cf._hasNext( _iter() ), + cf.If( gen.Ident( pos, hasnSym ),//cf._hasNext( _iter() ), cf._next( _iter() ), gen.mkDefaultValue(cf.pos,curSym.type()))), //cf.ignoreValue( curSym.type() ) @@ -212,7 +210,7 @@ public class Autom2Scala { if( dfa.isSink( i )) bodies[ i ] = run_finished( i ); // state won't change! else - bodies[ i ] = cf.If( cf.Negate( _ref( hasnSym )),//cf._not_hasNext( _iter() ), + bodies[ i ] = cf.If( cf.Negate( gen.Ident( pos, hasnSym )),//cf._not_hasNext( _iter() ), run_finished( i ), code_state_NEW( i )); } @@ -256,18 +254,12 @@ public class Autom2Scala { defs.BOOLEAN_TYPE ); am.construct( m, new CaseDef[] { - (CaseDef) cf.make.CaseDef( pat.pos, - pat, - Tree.Empty, - gen.mkBooleanLit( Position.FIRSTPOS, true )), - (CaseDef) cf.make.CaseDef( pat.pos, - cf.gen.Ident(pat.pos, defs.PATTERN_WILDCARD), - Tree.Empty, - gen.mkBooleanLit( pat.pos, false )) }, - false - ); - Tree res = am.toTree().setType( defs.BOOLEAN_TYPE ); - return res; + cf.gen.CaseDef( pat, + gen.mkBooleanLit( pat.pos, true )), + cf.gen.CaseDef( cf.gen.Ident(pat.pos, defs.PATTERN_WILDCARD), + gen.mkBooleanLit( pat.pos, false )) }, + false); + return am.toTree(); } Tree code_delta( int i, Label label ) { @@ -318,12 +310,4 @@ public class Autom2Scala { } return stateBody; } - - /** code to reference a variable - */ - Tree _ref( Symbol sym ) { - return gen.Ident( pos, sym ); - } - - } diff --git a/sources/scalac/transformer/matching/LeftTracerInScala.java b/sources/scalac/transformer/matching/LeftTracerInScala.java index 9a20a93bc2..6f216aa677 100644 --- a/sources/scalac/transformer/matching/LeftTracerInScala.java +++ b/sources/scalac/transformer/matching/LeftTracerInScala.java @@ -134,7 +134,7 @@ public class LeftTracerInScala extends TracerInScala { Tree newAcc = gen.Cons(cf.pos, hd.type, hd, - _ref( accumSym )); + gen.Ident( cf.pos, accumSym )); return callFun( new Tree[] { newAcc , _iter(), gen.mkIntLit( cf.pos, target )} ); } @@ -189,7 +189,7 @@ public class LeftTracerInScala extends TracerInScala { stateBody); } } - stateBody = cf.If( cf.Negate( _ref( hasnSym )), + stateBody = cf.If( cf.Negate( gen.Ident( cf.pos, hasnSym )), runFinished, stateBody ); return cf.If( cf.Equals( _state(), gen.mkIntLit(cf.pos, i )), @@ -289,17 +289,12 @@ public class LeftTracerInScala extends TracerInScala { //replaceVars( pat ); am.construct( m, new CaseDef[] { - (CaseDef) cf.make.CaseDef( pat.pos, - pat, - Tree.Empty, - gen.mkBooleanLit( cf.pos, true )), - (CaseDef) cf.make.CaseDef( pat.pos, - cf.gen.Ident(pat.pos, defs.PATTERN_WILDCARD), - Tree.Empty, - gen.mkBooleanLit( cf.pos, false)) }, - false - ); - Tree res = am.toTree().setType( defs.BOOLEAN_TYPE ); + cf.gen.CaseDef( pat, + gen.mkBooleanLit( cf.pos, true )), + cf.gen.CaseDef( cf.gen.Ident(pat.pos, defs.PATTERN_WILDCARD), + gen.mkBooleanLit( cf.pos, false)) }, + false); + Tree res = am.toTree(); return res; } @@ -315,7 +310,7 @@ public class LeftTracerInScala extends TracerInScala { return gen.Cons( cf.pos, hd.type(), hd, - _ref( accumSym )); + gen.Ident( cf.pos, accumSym )); } } diff --git a/sources/scalac/transformer/matching/PatternTool.java b/sources/scalac/transformer/matching/PatternTool.java index 7cd144de7c..8a58a0e8bc 100644 --- a/sources/scalac/transformer/matching/PatternTool.java +++ b/sources/scalac/transformer/matching/PatternTool.java @@ -43,10 +43,6 @@ abstract class PatternTool { */ FreshNameCreator fresh; - /** the global tree factory - */ - TreeFactory make; - /** the global definitions component */ Definitions defs; @@ -77,7 +73,6 @@ abstract class PatternTool { this.unit = unit; this.infer = infer; this.fresh = unit.global.freshNameCreator; - this.make = unit.global.make; this.gen = unit.global.treeGen; this.defs = unit.global.definitions; diff --git a/sources/scalac/transformer/matching/RightTracerInScala.java b/sources/scalac/transformer/matching/RightTracerInScala.java index 73ef37520f..084050ea56 100644 --- a/sources/scalac/transformer/matching/RightTracerInScala.java +++ b/sources/scalac/transformer/matching/RightTracerInScala.java @@ -118,8 +118,7 @@ public class RightTracerInScala extends TracerInScala { rhs = gen.mkDefaultValue(cf.pos, realVar.type()); //cf.ignoreValue( realVar.type() ); else - rhs = /* cf.newRef( cf.newSeqNil( */ gen.Nil( cf.pos ) - .setType( cf.SeqListType( elementType )); + rhs = /* cf.newRef( cf.newSeqNil( */ gen.Nil( cf.pos ); /* ) */; helpVar.flags |= Modifiers.MUTABLE; Tree varDef = gen.ValDef( helpVar, rhs ); @@ -351,18 +350,14 @@ public class RightTracerInScala extends TracerInScala { // case _ => false am.construct( m, new CaseDef[] { - (CaseDef) cf.make.CaseDef( pat.pos, - pat, // if tree val matches pat -> update vars, return true - Tree.Empty, - handleBody1( helpMap3 )/* "freshening */), - (CaseDef) cf.make.CaseDef( pat.pos, - cf.gen.Ident( pat.pos, defs.PATTERN_WILDCARD ), - Tree.Empty, - gen.mkBooleanLit( pat.pos, false )) }, // else return false - true // do binding please - ); - - return am.toTree().setType( defs.BOOLEAN_TYPE ); + cf.gen.CaseDef( pat, // if tree val matches pat -> update vars, return true + handleBody1( helpMap3 )/* "freshening */), + cf.gen.CaseDef( cf.gen.Ident( pat.pos, defs.PATTERN_WILDCARD ), + gen.mkBooleanLit( pat.pos, false )) }, // else return false + true // do binding please + ); + + return am.toTree(); } @@ -466,7 +461,7 @@ public class RightTracerInScala extends TracerInScala { * todo: move tree generation of Unit somewhere else */ Tree run_finished( int state ) { - return gen.Block(Position.FIRSTPOS, Tree.EMPTY_ARRAY).setType( defs.UNIT_TYPE ); + return gen.Block(Position.FIRSTPOS, Tree.EMPTY_ARRAY); } Tree current() { |