xrel.analyzer
Class PatternMatching

java.lang.Object
  |
  +--xrel.analyzer.PatternMatching
All Implemented Interfaces:
SymElementKind

public class PatternMatching
extends java.lang.Object
implements SymElementKind

Contains the run-time pattern matching algorithm. The method matchWith calls the algorithm for pattern matching.

N.B.:

Author:
Fabrizio Bisi

Fields inherited from interface xrel.parser.SymElementKind
EXPRESSION, LABEL, PATTERN, S_EXPRESSIONS, S_LABELS, S_PATTERNS, S_TYPES, S_VARIABLES, TYPE, UNDEFINED, VARIABLE
 
Constructor Summary
PatternMatching()
           
 
Method Summary
static SimpleNode getEvaluation()
          Evaluates the output value.
static int matchWith(SymTable st, SimpleNode value, java.io.PrintStream out, boolean debug)
          The main method of this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PatternMatching

public PatternMatching()
Method Detail

matchWith

public static int matchWith(SymTable st,
                            SimpleNode value,
                            java.io.PrintStream out,
                            boolean debug)
The main method of this class. It tries to match a value passed as argument against the patterns of the program. If the match is successful and a typeswitch instruction appears in the code the variable matchingClause contains the number of the clause that matched with the value.
Parameters:
value - the value to check. The patterns are passed throughout the symbol table.
out - where to print out debug information
debug - if true print out debug information
Returns:
the matching clause or -1

getEvaluation

public static SimpleNode getEvaluation()
Evaluates the output value. Call only after executing the main algorithm.
Returns:
the output value