summaryrefslogtreecommitdiff
path: root/sources/scalac/transformer/matching/WordAutomInScala.java
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2003-06-23 17:11:16 +0000
committermichelou <michelou@epfl.ch>2003-06-23 17:11:16 +0000
commit3102d7d40fcc65e6174e84d5424cd45d688c0257 (patch)
tree3bf41d77ce7f537ae886601302a020b668bfb267 /sources/scalac/transformer/matching/WordAutomInScala.java
parentf29ec2158b34fc7d8ca8b206aed7659618aa7772 (diff)
downloadscala-3102d7d40fcc65e6174e84d5424cd45d688c0257.tar.gz
scala-3102d7d40fcc65e6174e84d5424cd45d688c0257.tar.bz2
scala-3102d7d40fcc65e6174e84d5424cd45d688c0257.zip
cleaned up
Diffstat (limited to 'sources/scalac/transformer/matching/WordAutomInScala.java')
-rw-r--r--sources/scalac/transformer/matching/WordAutomInScala.java142
1 files changed, 80 insertions, 62 deletions
diff --git a/sources/scalac/transformer/matching/WordAutomInScala.java b/sources/scalac/transformer/matching/WordAutomInScala.java
index a8da5d8652..f27b6cb286 100644
--- a/sources/scalac/transformer/matching/WordAutomInScala.java
+++ b/sources/scalac/transformer/matching/WordAutomInScala.java
@@ -1,84 +1,102 @@
-package scalac.transformer.matching ;
+/* ____ ____ ____ ____ ______ *\
+** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
+** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
+** /_____/\____/\___/\____/____/ **
+\* */
+
+// $Id$
+
+package scalac.transformer.matching;
+
+import ch.epfl.lamp.util.Position;
import scalac.*;
import scalac.ast.Tree;
import scalac.ast.TreeGen;
import scalac.symtab.Type;
import scalac.symtab.Symbol;
+import scalac.transformer.TransMatch.Matcher;
import scalac.typechecker.*;
import Tree.*;
-import scalac.transformer.TransMatch.Matcher ;
-import java.util.* ;
-import ch.epfl.lamp.util.Position;
+import java.util.*;
-public class WordAutomInScala extends Autom2Scala {
- Tree getMatcherSwitch( Tree selector,
- Tree failTree,
- Tree body[],
- Type resultType) {
+/**
+ */
+public class WordAutomInScala extends Autom2Scala {
+ Tree getMatcherSwitch(Tree selector,
+ Tree failTree,
+ Tree body[],
+ Type resultType) {
- Tree run = callFun( new Tree[] {
- cf.newIterator( selector ),
- gen.mkIntLit(Position.NOPOS,0) } );
+ Tree run = callFun( new Tree[] {
+ cf.newIterator(selector),
+ gen.mkIntLit(Position.NOPOS, 0) } );
- /* return code `var <swres>: scala.Int = <init>' */
+ /* return code `var <swres>: scala.Int = <init>' */
- run = _intvar( resultSym, run );
+ run = _intvar(resultSym, run);
- Tree result;
+ Tree result;
- // conditions
- Tree cond[] = new Tree[ body.length ];
- //Tree bbody[] = new Tree[ body.length ];
- for( int i = body.length - 1; i >= 0; i-- )
- cond[ i ] = cf.Equals( _swres(), gen.mkIntLit(Position.NOPOS, i ));
+ // conditions
+ Tree cond[] = new Tree[body.length];
+ //Tree bbody[] = new Tree[body.length];
+ for (int i = body.length - 1; i >= 0; i--)
+ cond[i] = cf.Equals(_swres(), gen.mkIntLit(Position.NOPOS, i));
- result = cf.Switch( selector, cond, body, failTree );
+ result = cf.Switch( selector, cond, body, failTree );
- result = cf.make.Block( pos, new Tree[] { theDefDef, run, result } )
+ result = cf.make.Block( pos, new Tree[] { theDefDef, run, result } )
.setType( resultType );
- //unit.global.debugPrinter.print( result );
- return result;
-
-
- }
-
- /** do the translation
- */
- public void translate() {
- initializeSyms();
- Tree tb = code_body();
- theDefDef = gen.DefDef( this.funSym,
- tb );
- }
-
- /** returns translation of transition with label from i.
- * returns null if there is no such transition(no translation needed)
- */
- Tree code_delta( int i, Label label ) {
- Integer target = dfa.delta( i, label );
-
- if( target == null )
- switch( label ) {
- case DefaultLabel:
- return code_fail(); // this may not happen !
- default:
- return null; // not good
- }
- else if( target.intValue() == dfa.nstates - 1 ) // that one is a dead state
- return code_fail();
-
- return callFun( new Tree[] { _iter(), gen.mkIntLit(Position.NOPOS, target.intValue() )} );
- }
-
- public WordAutomInScala( DetWordAutom dfa,
- Type elementType,
- Symbol owner,
- CodeFactory cf ) {
- super( dfa, elementType, owner, cf );
- }
+ //unit.global.debugPrinter.print( result );
+ return result;
+ }
+
+ /** do the translation
+ */
+ public void translate() {
+ initializeSyms();
+ Tree tb = code_body();
+ theDefDef = gen.DefDef(this.funSym, tb);
+ }
+
+ /** ...
+ * @return returns translation of transition with label from i.
+ * returns null if there is no such transition
+ * (no translation needed)
+ */
+ Tree code_delta(int i, Label label) {
+ Integer target = dfa.delta(i, label);
+
+ if (target == null)
+ switch (label) {
+ case DefaultLabel:
+ return code_fail(); // this may not happen !
+ default:
+ return null; // not good
+ }
+ else if (target.intValue() == dfa.nstates - 1) // that one is a dead state
+ return code_fail();
+
+ return callFun(new Tree[] { _iter(),
+ gen.mkIntLit(Position.NOPOS, target.intValue())} );
+ }
+
+ /** ...
+ * @param dfa ...
+ * @param elementType ...
+ * @param owner ...
+ * @param cf ...
+ * @return ...
+ */
+ public WordAutomInScala(DetWordAutom dfa,
+ Type elementType,
+ Symbol owner,
+ CodeFactory cf) {
+ super(dfa, elementType, owner, cf);
+ }
}