edu.toronto.cs.cparser.block
Class Block

java.lang.Object
  extended by antlr.BaseAST
      extended by antlr.CommonAST
          extended by edu.toronto.cs.cparser.TNode
              extended by edu.toronto.cs.cparser.block.Block
All Implemented Interfaces:
antlr.collections.AST, CILTokenTypes, java.io.Serializable

public class Block
extends TNode
implements CILTokenTypes

See Also:
Serialized Form

Field Summary
 
Fields inherited from class edu.toronto.cs.cparser.TNode
attributes, defNode, left, lineNum, marker, text, ttype, up
 
Fields inherited from class antlr.BaseAST
down, right
 
Fields inherited from interface edu.toronto.cs.cparser.CILTokenTypes
ASSIGN, BadStringLiteral, BAND, BAND_ASSIGN, BNOT, BOR, BOR_ASSIGN, BXOR, BXOR_ASSIGN, CharLiteral, COLON, COMMA, Comment, CPPComment, DEC, Digit, DIV, DIV_ASSIGN, DOT, DoubleDoubleConst, EOF, EQUAL, Escape, Exponent, FloatDoubleConst, FloatSuffix, GT, GTE, ID, INC, IntHexConst, IntIntConst, IntOctalConst, LAND, LBRACKET, LCURLY, LineDirective, LITERAL___asm__, LITERAL___attribute__, LITERAL___inline, LITERAL___nd_goto, LITERAL_asm, LITERAL_auto, LITERAL_break, LITERAL_char, LITERAL_const, LITERAL_double, LITERAL_else, LITERAL_enum, LITERAL_extern, LITERAL_float, LITERAL_goto, LITERAL_if, LITERAL_int, LITERAL_long, LITERAL_register, LITERAL_return, LITERAL_short, LITERAL_signed, LITERAL_sizeof, LITERAL_static, LITERAL_struct, LITERAL_typedef, LITERAL_union, LITERAL_unsigned, LITERAL_void, LITERAL_volatile, LITERAL_while, LNOT, LongDoubleConst, LongHexConst, LongIntConst, LongOctalConst, LongSuffix, LOR, LPAREN, LSHIFT, LSHIFT_ASSIGN, LT, LTE, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NArrayElement, NArrayIndex, NAsmAttribute, NAssignStmt, NBlock, NBreak, NCast, NCommaExpr, NCompoundStatement, NContinue, NDeclaration, NDeclarator, NDeclSpecifiers, NEmptyExpression, NEmptyScope, NFunctionBody, NFunctionCall, NFunctionCallArgs, NFunctionCallAssignStmt, NFunctionCallStmt, NFunctionDeclSpecifiers, NFunctionDef, NGnuAsmExpr, NGoto, NIf, NImplicitAssignStmt, NInitDecl, NInitializer, NLabel, NLabelledStmt, NLCurlyInitializer, NLHS, NLocalDeclarations, NNDGoto, NNonemptyAbstractDeclarator, NOT_EQUAL, NParameterDeclaration, NParameterTypeList, NPointerGroup, NPostfixExpr, NProgram, NPureExpr, NPureExpressionGroup, NRangeExpr, NReturn, NRHS, NScope, NStatementExpr, NStringSeq, NStructDeclarator, NStructFields, NTypedefName, NULL_TREE_LOOKAHEAD, Number, NUnaryExpr, NWhile, PLUS, PLUS_ASSIGN, PREPROC_DIRECTIVE, PTR, QUESTION, RBRACKET, RCURLY, RPAREN, RSHIFT, RSHIFT_ASSIGN, SEMI, Space, STAR, STAR_ASSIGN, StringLiteral, UnsignedHexConst, UnsignedIntConst, UnsignedOctalConst, UnsignedSuffix, VARARGS, Vocabulary, Whitespace
 
Constructor Summary
Block()
           
Block(BlockType type)
           
 
Method Summary
 BlockType getBlockType()
           
 Block getBody()
           
 int getCallIndex()
           
 Block getCond()
           
 java.lang.String getDeclName()
          A variable or function prototype declaration AST looks like: NBlock [declaration] NDeclSpecifiers NDeclarator ID NInitializer A struct/union/enum type declaration AST looks like: NBlock [declaration] NDeclSpecifiers LITERAL_struct | LITERAL_union | LITERAL_enum ID ...
 Block getDecls()
          Deprecated. Use getLocalDecls ().
 Block getElseBlock()
           
 Block getFunctionCallArgs()
           
 java.lang.String getFunctionCallName()
          A function call AST looks like either: NBlock [functionCall] NFunctionCallStmt NFunctionCall ID (call name) ...
 java.lang.String getFunctionCallReturnVarName()
           
 java.lang.String getFunctionName()
          A function definition AST looks like this: NBlock [functionDefinition] NFunctionDeclSpecifiers NDeclarator ID ...
 Block getFunctionParameterList()
           
 Block getFunctionParameters()
          A function definition AST looks like this: NBlock [functionDefinition] NFunctionDeclSpecifiers NDeclarator ID NParameterTypeList NBlock [scope]
 Block getFunctionReturnType()
          A function definition AST looks like this: NBlock [functionDefinition] NDeclSpecifiers ...
 java.lang.String getGotoTargetLabel()
          A goto AST looks like this: NBlock [goto] ID
 java.lang.String getLabel()
           
 Block getLabelledStmt()
          A labelled statement AST looks like this: NBlock [labelledStatement] NLabel NBlock
 Block getLocalDecls()
          A scope AST looks like: NBlock [scope] NLocalDeclarations ...
 Block getLocalDeclsRoot()
           
 Block getMainFunctionDef()
          When called on a PROGRAM Block, finds a "main" function definition amongst its children, and returns that subtree.
 int getNumCallSites()
           
 Block getReturnExpr()
           
 Block getThenBlock()
           
 Block getWhileBody()
           
 boolean isNamedDeclaration()
           
 boolean isNonVoidFunction()
           
static Block mergeCons(Block elt, Block list)
           
static Block mergeCopy(Block list)
           
static Block mergeNodes(Block m, Block n)
           
 void setBlockType(BlockType type)
           
 void setCallIndex(int v)
           
 void setLabel(java.lang.String label)
           
 void setNumCallSites(int numCallSites)
           
 
Methods inherited from class edu.toronto.cs.cparser.TNode
addSibling, deepCopy, deepCopyWithRightSiblings, doubleLink, firstChildOfType, firstSiblingOfType, getAttribute, getAttributesTable, getDefNode, getFirstSibling, getLastChild, getLastSibling, getLineNum, getLocalLineNum, getMarker, getNameForType, getParent, getText, getType, initialize, initialize, numberOfChildren, parentOfType, printASTNode, printTree, printTree, removeSelf, setAttribute, setDefNode, setLineNum, setMarker, setText, setTokenVocabulary, setType, toString
 
Methods inherited from class antlr.CommonAST
initialize
 
Methods inherited from class antlr.BaseAST
addChild, decode, encode, equals, equalsList, equalsListPartial, equalsTree, equalsTreePartial, findAll, findAllPartial, getColumn, getFirstChild, getLine, getNextSibling, getNumberOfChildren, getTokenNames, removeChildren, setFirstChild, setNextSibling, setVerboseStringConversion, toStringList, toStringTree, xmlSerialize, xmlSerializeNode, xmlSerializeRootClose, xmlSerializeRootOpen
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Block

public Block()

Block

public Block(BlockType type)
Method Detail

getBlockType

public BlockType getBlockType()

setBlockType

public void setBlockType(BlockType type)

getMainFunctionDef

public Block getMainFunctionDef()
When called on a PROGRAM Block, finds a "main" function definition amongst its children, and returns that subtree.

Parameters:
block -
Returns:

getDecls

public Block getDecls()
Deprecated. Use getLocalDecls ().


getLocalDecls

public Block getLocalDecls()
A scope AST looks like: NBlock [scope] NLocalDeclarations ...

Returns:
the first child of the NLocalDeclarations subtree.

getLocalDeclsRoot

public Block getLocalDeclsRoot()

getWhileBody

public Block getWhileBody()

getBody

public Block getBody()

getCond

public Block getCond()

getThenBlock

public Block getThenBlock()

getElseBlock

public Block getElseBlock()

getLabel

public java.lang.String getLabel()

setLabel

public void setLabel(java.lang.String label)

getFunctionName

public java.lang.String getFunctionName()
A function definition AST looks like this: NBlock [functionDefinition] NFunctionDeclSpecifiers NDeclarator ID ... NBlock [scope]

Returns:
the text of the "ID" node.

getFunctionReturnType

public Block getFunctionReturnType()
A function definition AST looks like this: NBlock [functionDefinition] NDeclSpecifiers ...

Returns:
the NDeclSpecifiers subtree.

isNonVoidFunction

public boolean isNonVoidFunction()

getFunctionParameters

public Block getFunctionParameters()
A function definition AST looks like this: NBlock [functionDefinition] NFunctionDeclSpecifiers NDeclarator ID NParameterTypeList NBlock [scope]

Returns:
the NParameterTypeList subtree.

getFunctionParameterList

public Block getFunctionParameterList()

getGotoTargetLabel

public java.lang.String getGotoTargetLabel()
A goto AST looks like this: NBlock [goto] ID

Returns:
the text of the ID subtree.

getReturnExpr

public Block getReturnExpr()

getLabelledStmt

public Block getLabelledStmt()
A labelled statement AST looks like this: NBlock [labelledStatement] NLabel NBlock

Returns:
the NBlock child subtree.

isNamedDeclaration

public boolean isNamedDeclaration()
Returns:
true if this is a DECLARATION Block which has a name; the only case which currently yields false is the "void" declaration in a function parameter list.

getDeclName

public java.lang.String getDeclName()
A variable or function prototype declaration AST looks like: NBlock [declaration] NDeclSpecifiers NDeclarator ID NInitializer A struct/union/enum type declaration AST looks like: NBlock [declaration] NDeclSpecifiers LITERAL_struct | LITERAL_union | LITERAL_enum ID ... A void declaration AST looks like: NBlock [declaration] NDeclSpecifiers LITERAL_void

Returns:
the name of the declaration; null if the declaration is void.

getFunctionCallName

public java.lang.String getFunctionCallName()
A function call AST looks like either: NBlock [functionCall] NFunctionCallStmt NFunctionCall ID (call name) ... (args) e.g. foo (1) or NBlock [functionCall] NFunctionCallAssignStmt ID (lval) NFunctionCall ID (call name) ... (args) e.g. y = foo (1)

Returns:
the call name.

getFunctionCallReturnVarName

public java.lang.String getFunctionCallReturnVarName()

getFunctionCallArgs

public Block getFunctionCallArgs()

setNumCallSites

public void setNumCallSites(int numCallSites)

getNumCallSites

public int getNumCallSites()

setCallIndex

public void setCallIndex(int v)

getCallIndex

public int getCallIndex()

mergeNodes

public static Block mergeNodes(Block m,
                               Block n)

mergeCons

public static Block mergeCons(Block elt,
                              Block list)

mergeCopy

public static Block mergeCopy(Block list)