diff options
author | buraq <buraq@epfl.ch> | 2003-06-17 12:49:02 +0000 |
---|---|---|
committer | buraq <buraq@epfl.ch> | 2003-06-17 12:49:02 +0000 |
commit | 6734a441e8517b0ac215f4936a6ae2805d477b94 (patch) | |
tree | f9acffc0fce90b7bf439a77e67462724722ee53f /sources/scalac/transformer | |
parent | 563e00ffc7a4920c0cdfcd64c76ec46f44f8e23c (diff) | |
download | scala-6734a441e8517b0ac215f4936a6ae2805d477b94.tar.gz scala-6734a441e8517b0ac215f4936a6ae2805d477b94.tar.bz2 scala-6734a441e8517b0ac215f4936a6ae2805d477b94.zip |
using TransMatch.Matcher for input, output.
Diffstat (limited to 'sources/scalac/transformer')
-rw-r--r-- | sources/scalac/transformer/matching/PatternMatcher.java | 54 | ||||
-rw-r--r-- | sources/scalac/transformer/matching/PatternNode.java | 2 |
2 files changed, 53 insertions, 3 deletions
diff --git a/sources/scalac/transformer/matching/PatternMatcher.java b/sources/scalac/transformer/matching/PatternMatcher.java index 437e51a80c..f05b482e3a 100644 --- a/sources/scalac/transformer/matching/PatternMatcher.java +++ b/sources/scalac/transformer/matching/PatternMatcher.java @@ -18,6 +18,7 @@ import scalac.typechecker.*; import PatternNode.*; import Tree.*; +import scalac.transformer.TransMatch.Matcher ; public class PatternMatcher { @@ -77,17 +78,21 @@ public class PatternMatcher { /** the statics of class Boolean */ - Symbol statics; + //Symbol statics; + /** container + */ + Matcher _m; /** constructor */ - public PatternMatcher(Unit unit, Infer infer, Symbol owner, Tree selector, Type tpe) { + public PatternMatcher(Unit unit, Infer infer/*, Symbol owner, Tree selector, Type tpe*/) { this.unit = unit; this.fresh = unit.global.freshNameCreator; this.make = unit.global.make; this.gen = unit.global.treeGen; this.defs = unit.global.definitions; + /* this.owner = owner; this.selector = selector; this.root = makeConstrPat(selector.pos, @@ -103,10 +108,53 @@ public class PatternMatcher { owner, Modifiers.MUTABLE); this.resultVar.setType(tpe); - this.statics = defs.getModule(Names.scala_Boolean); + */ + //this.statics = defs.getModule(Names.scala_Boolean); this.infer = infer; } + + /** constructs an algebraic pattern matcher from cases + */ + public void construct( Matcher m, Tree[] cases /*, boolean doBinding*/) { + //this.doBinding = doBinding; + this._m = m; + initialize(); + for( int i = 0; i < cases.length; i++ ) { + enter( (CaseDef) cases[i]/*, i*/ ); + } + _m.tree = toTree(); + } + + /** initializes this AlgebraicMatcher, see Matcher.initialize + */ + protected void initialize() { + + //this.mk = new PatternNodeCreator( unit, infer, _m.owner/*_m.clazzOwner*/ ); + //this.cf = new CodeFactory( unit, infer, _m.pos ); + this.owner = _m.owner; + this.selector = _m.selector; + + this.root = makeConstrPat/*mk.ConstrPat*/( _m.pos, + _m.selector.type.widen() ); + + this.root.and = makeHeader/*mk.Header*/( _m.pos, + _m.selector.type.widen(), + gen.Ident( _m.pos, root.symbol() ) + .setType(_m.selector.type)); + + this.resultVar = new TermSymbol(_m.pos, + /*cf.*/fresh.newName( RESULT_N ), + _m.owner, + Modifiers.MUTABLE ); + //this.resultType = resultType; + this.resultVar.setType( _m.resultType ); + + //System.out.println(" constructed matcherDefs "); + } + + + /** return the analyzed type */ public Type typeOf(Symbol sym) { diff --git a/sources/scalac/transformer/matching/PatternNode.java b/sources/scalac/transformer/matching/PatternNode.java index f75600c98f..4c598768f5 100644 --- a/sources/scalac/transformer/matching/PatternNode.java +++ b/sources/scalac/transformer/matching/PatternNode.java @@ -14,6 +14,8 @@ import scalac.ast.*; import scalac.symtab.*; import scalac.typechecker.*; +/** intermediary data structure for algebraic matching + */ public class PatternNode { public int pos = Position.NOPOS; |