scale.clef.stmt
Class Statement

java.lang.Object
  extended by scale.common.Root
      extended by scale.clef.Node
          extended by scale.clef.stmt.Statement
All Implemented Interfaces:
AnnotationInterface, DisplayNode
Direct Known Subclasses:
AssignLabelStmt, BlockStmt, BreakStmt, CaseStmt, ContinueStmt, DeclStmt, EvalStmt, ExitStmt, GotoStmt, IfStmt, LabelStmt, LoopStmt, MultiBranchStmt, NullStmt, ReturnStmt, SwitchStmt

public abstract class Statement
extends Node

This class is the abstract (base) class for all language imperative statements.

$Id: Statement.java,v 1.44 2007-08-09 17:29:22 burrill Exp $

Copyright 2007 by the Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.


Constructor Summary
Statement()
           
 
Method Summary
 boolean containsLoopStmt()
          Return true if this statement is a loop statement or contains a loop statement.
 void dump(java.lang.String indents, java.io.PrintStream out)
           
 DColor getDisplayColorHint()
          Return a String specifying the color to use for coloring this node in a graphical display.
 java.lang.String getDisplayLabel()
          Return a String suitable for labeling this node in a graphical display.
 DShape getDisplayShapeHint()
          Return a String specifying a shape to use when drawing this node in a graphical display.
 PragmaStk.Pragma getPragma()
           
 int getSourceLineNumber()
          Return the source line number associated with this node or -1 if not known.
 boolean hasReturnStmt()
          Return true if this statement is, or contains, a return statement or a call to exit().
 int numTotalStmts()
          Return the number of statements represented by this statement.
 void setPragma(PragmaStk.Pragma pragma)
           
 void setSourceLineNumber(int lineNumber)
          Set the source line number associated with this node or -1 if not known.
 void visit(Predicate p)
          Process a node by calling its associated routine.
 
Methods inherited from class scale.clef.Node
getChild, getCoreType, getDecl, getType, numChildren, setAnnotationLevel, setReportLevel, toString, toString, toStringChildren, toStringSpecial
 
Methods inherited from class scale.common.Root
addAnnotation, allAnnotations, allMatchingAnnotations, getAnnotation, getDisplayName, getDisplayString, getNodeCount, getNodeID, hasAnnotation, hasEqualAnnotation, hashCode, removeAnnotation, removeAnnotations, toStringAnnotations, toStringClass, trace, trace, trace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Statement

public Statement()
Method Detail

setPragma

public final void setPragma(PragmaStk.Pragma pragma)

getPragma

public final PragmaStk.Pragma getPragma()

getDisplayLabel

public java.lang.String getDisplayLabel()
Return a String suitable for labeling this node in a graphical display. This method should be over-ridden as it simplay returns the class name.

Specified by:
getDisplayLabel in interface DisplayNode
Overrides:
getDisplayLabel in class Root

getDisplayColorHint

public DColor getDisplayColorHint()
Return a String specifying the color to use for coloring this node in a graphical display.

Specified by:
getDisplayColorHint in interface DisplayNode
Overrides:
getDisplayColorHint in class Root
See Also:
DColor

getDisplayShapeHint

public DShape getDisplayShapeHint()
Return a String specifying a shape to use when drawing this node in a graphical display.

Specified by:
getDisplayShapeHint in interface DisplayNode
Overrides:
getDisplayShapeHint in class Root
See Also:
DShape

visit

public void visit(Predicate p)
Description copied from class: Node
Process a node by calling its associated routine. See the "visitor" design pattern in Design Patterns: Elements of Reusable Object-Oriented Software by E. Gamma, et al, Addison Wesley, ISBN 0-201-63361-2.

Each class has a visit(Predicate p) method. For example, in class ABC:

   public void visit(Predicate p)
   {
     p.visitABC(this);
   }
 
and the class that implements Predicate has a method
   public void visitABC(Node n)
   {
     ABC a = (ABC) n;
     ...
   }
 
Thus, the class that implements Predicate can call
   n.visit(this);
 
where n is a Node sub-class without determining which specific sub-class n is. The visit pattern basically avoids implementing a large switch statement or defining different methods in each class for some purpose.

Specified by:
visit in class Node
See Also:
Predicate

getSourceLineNumber

public final int getSourceLineNumber()
Return the source line number associated with this node or -1 if not known.

Overrides:
getSourceLineNumber in class Node

setSourceLineNumber

public void setSourceLineNumber(int lineNumber)
Set the source line number associated with this node or -1 if not known.

Overrides:
setSourceLineNumber in class Node

hasReturnStmt

public boolean hasReturnStmt()
Return true if this statement is, or contains, a return statement or a call to exit().


numTotalStmts

public int numTotalStmts()
Return the number of statements represented by this statement. Most statements return 1. A block statement returns sum of the number of statements in each statement in the block.


containsLoopStmt

public boolean containsLoopStmt()
Return true if this statement is a loop statement or contains a loop statement.


dump

public void dump(java.lang.String indents,
                 java.io.PrintStream out)