dspl.frontend
Class DSPLAstToIntermediateWalker

java.lang.Object
  extended by antlr.TreeParser
      extended by dspl.frontend.DSPLAstToIntermediateWalker
All Implemented Interfaces:
DSPLAstToIntermediateWalkerTokenTypes

public class DSPLAstToIntermediateWalker
extends antlr.TreeParser
implements DSPLAstToIntermediateWalkerTokenTypes

This class is the tree walker which walks the AST for a dspl file and produces an intermediate representation.

Author:
Varun, Jeff, Mike, David

Field Summary
static java.lang.String[] _tokenNames
           
static antlr.collections.impl.BitSet _tokenSet_0
           
static antlr.collections.impl.BitSet _tokenSet_1
           
protected  boolean arrayop
           
protected  int arraysize
          Functions that Assist in Semantic Anaylsis or Array operations
(package private)  boolean convert
           
(package private)  int indexCount
           
(package private)  InstructionSet iSet
           
(package private)  int nextTempNumber
           
(package private)  int rightType
           
(package private)  SymbolTable table
           
 
Fields inherited from class antlr.TreeParser
_retTree, astFactory, ASTNULL, inputState, returnAST, tokenNames, traceDepth
 
Fields inherited from interface dspl.frontend.DSPLAstToIntermediateWalkerTokenTypes
ASSIGN, COMMA, COMMENT, DECLS, DIGITS, DIV, DOT, EOF, EQ, GE, GT, ID, LBRACE, LBRACK, LE, LITERAL_byte, LITERAL_byte_array, LITERAL_ccall, LITERAL_complex, LITERAL_complex_array, LITERAL_else, LITERAL_float, LITERAL_float_array, LITERAL_for, LITERAL_if, LITERAL_int, LITERAL_int_array, LITERAL_string, LITERAL_ubyte, LITERAL_ubyte_array, LITERAL_uint, LITERAL_uint_array, LITERAL_while, LPAREN, LT, MINUS, MUL, NE, NEGATE, NEWLINE, NULL_TREE_LOOKAHEAD, NUM, PLUS, PROGRAM, RBRACE, RBRACK, REAL, RPAREN, SEMI, STRING, TILDE, WS
 
Constructor Summary
DSPLAstToIntermediateWalker()
           
 
Method Summary
protected  void arrayOperationEnter()
           
protected  void arrayOperationExit()
           
 Comparison bool(antlr.collections.AST _t)
           
 java.lang.String ccallname(antlr.collections.AST _t)
          ccallname is unlike other instances of ID because we don't want a variable, we just want the name of the function!
protected  int checkLogical(Variable e1, Variable e2, antlr.collections.AST _t)
          Functions to aid in Semantic checking of logical expressions
 void decls(antlr.collections.AST _t)
          We construct the symbol table outside of the tree walker, so we don't actually do anything for the declarations that we find here
protected  void decrementIndexCount()
           
protected  void disableConversion()
           
 Variable expr(antlr.collections.AST _t)
           
protected  int findType(int dataType)
           
protected  int getSize()
           
 SymbolTable getSymbolTable()
           
protected  Variable getTempAtomicVar(int variableType, java.lang.String prepend)
          Helper function intended to be used by expressions which require a temporary variable to store a result variableType must correspond to one of the Variable.DATATYPE_xxx (int/uint/float/etc)
protected  void incrementIndexCount()
          Series of helper functions for conversion analysis
protected  boolean isArrayOp()
           
protected  boolean isIndex()
           
private static long[] mk_tokenSet_0()
           
private static long[] mk_tokenSet_1()
           
protected  boolean needsConversion(int dataType)
           
protected  Variable newFloatConstant(java.lang.String val)
          Function that creates a new Float "Constant" (since its stored in the symbol table)
 InstructionSet program(antlr.collections.AST _t)
          The program rule is the one that...matches the whole program, represented by the root node of the AST.
protected  void setConversion(int conversionType)
           
protected  void setSize(int size)
           
 Instruction stmt(antlr.collections.AST _t)
          a statements can be one of many types, and an appropriate instruction needs to be appended to the current InstructionSet based on what needs to be done
 Instruction stmts(antlr.collections.AST _t)
          stmts is simply a sequence of statments
 Instruction subprog(antlr.collections.AST _t)
           
protected  boolean validArrayOperation(int size)
           
 
Methods inherited from class antlr.TreeParser
getAST, getASTFactory, getTokenName, getTokenNames, match, match, matchNot, panic, reportError, reportError, reportWarning, setASTFactory, setASTNodeClass, setASTNodeType, traceIn, traceIndent, traceOut
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iSet

InstructionSet iSet

table

SymbolTable table

nextTempNumber

int nextTempNumber

rightType

int rightType

convert

boolean convert

indexCount

int indexCount

arraysize

protected int arraysize
Functions that Assist in Semantic Anaylsis or Array operations


arrayop

protected boolean arrayop

_tokenNames

public static final java.lang.String[] _tokenNames

_tokenSet_0

public static final antlr.collections.impl.BitSet _tokenSet_0

_tokenSet_1

public static final antlr.collections.impl.BitSet _tokenSet_1
Constructor Detail

DSPLAstToIntermediateWalker

public DSPLAstToIntermediateWalker()
Method Detail

getSymbolTable

public SymbolTable getSymbolTable()

getTempAtomicVar

protected Variable getTempAtomicVar(int variableType,
                                    java.lang.String prepend)
                             throws SemanticAnalysisException
Helper function intended to be used by expressions which require a temporary variable to store a result variableType must correspond to one of the Variable.DATATYPE_xxx (int/uint/float/etc)

Throws:
SemanticAnalysisException

incrementIndexCount

protected void incrementIndexCount()
Series of helper functions for conversion analysis


decrementIndexCount

protected void decrementIndexCount()

isIndex

protected boolean isIndex()

setConversion

protected void setConversion(int conversionType)

disableConversion

protected void disableConversion()

findType

protected int findType(int dataType)

needsConversion

protected boolean needsConversion(int dataType)

newFloatConstant

protected Variable newFloatConstant(java.lang.String val)
                             throws SemanticAnalysisException
Function that creates a new Float "Constant" (since its stored in the symbol table)

Throws:
SemanticAnalysisException

setSize

protected void setSize(int size)

getSize

protected int getSize()

validArrayOperation

protected boolean validArrayOperation(int size)

arrayOperationEnter

protected void arrayOperationEnter()

arrayOperationExit

protected void arrayOperationExit()

isArrayOp

protected boolean isArrayOp()

checkLogical

protected int checkLogical(Variable e1,
                           Variable e2,
                           antlr.collections.AST _t)
                    throws SemanticAnalysisException
Functions to aid in Semantic checking of logical expressions

Throws:
SemanticAnalysisException

program

public final InstructionSet program(antlr.collections.AST _t)
                             throws antlr.RecognitionException,
                                    SemanticAnalysisException,
                                    SymbolicException
The program rule is the one that...matches the whole program, represented by the root node of the AST. The program rule is the one that dsplc calls and so it must return the root instruction set. When writing rules it is important to understand how they work. ANTLR, when tree-walking uses a syntax of: variable=rule {java action} only the rule is required, but it is possible, depending on what the rule return, to set its return value to a variable, and also set some action that will be performed when the the rule has been matched. This action is performed *after* the rule is matched.

Throws:
antlr.RecognitionException
SemanticAnalysisException
SymbolicException

decls

public final void decls(antlr.collections.AST _t)
                 throws antlr.RecognitionException
We construct the symbol table outside of the tree walker, so we don't actually do anything for the declarations that we find here

Throws:
antlr.RecognitionException

stmts

public final Instruction stmts(antlr.collections.AST _t)
                        throws antlr.RecognitionException,
                               SemanticAnalysisException,
                               SymbolicException
stmts is simply a sequence of statments

Throws:
antlr.RecognitionException
SemanticAnalysisException
SymbolicException

stmt

public final Instruction stmt(antlr.collections.AST _t)
                       throws antlr.RecognitionException,
                              SemanticAnalysisException,
                              SymbolicException
a statements can be one of many types, and an appropriate instruction needs to be appended to the current InstructionSet based on what needs to be done

Throws:
antlr.RecognitionException
SemanticAnalysisException
SymbolicException

expr

public final Variable expr(antlr.collections.AST _t)
                    throws antlr.RecognitionException,
                           SemanticAnalysisException,
                           SymbolicException
Throws:
antlr.RecognitionException
SemanticAnalysisException
SymbolicException

ccallname

public final java.lang.String ccallname(antlr.collections.AST _t)
                                 throws antlr.RecognitionException
ccallname is unlike other instances of ID because we don't want a variable, we just want the name of the function!

Throws:
antlr.RecognitionException

bool

public final Comparison bool(antlr.collections.AST _t)
                      throws antlr.RecognitionException,
                             SemanticAnalysisException,
                             SymbolicException
Throws:
antlr.RecognitionException
SemanticAnalysisException
SymbolicException

subprog

public final Instruction subprog(antlr.collections.AST _t)
                          throws antlr.RecognitionException,
                                 SemanticAnalysisException,
                                 SymbolicException
Throws:
antlr.RecognitionException
SemanticAnalysisException
SymbolicException

mk_tokenSet_0

private static final long[] mk_tokenSet_0()

mk_tokenSet_1

private static final long[] mk_tokenSet_1()