spiglet.meta
Class SpigletStatement

java.lang.Object
  extended by spiglet.meta.SpigletStatement

public final class SpigletStatement
extends java.lang.Object

This class represents the metadata of a single statement in a Spiglet thread. It encodes the information necessary to do calculation on a control flow graph. This includes the label of the statement (if it exists), the def and use sets, the label of the statement that it can jump to, and whether it falls through the next statement.

Author:
Santoso Wijaya

Nested Class Summary
static class SpigletStatement.Type
           
 
Field Summary
protected  SpigletStatement.Type type
          An enum value indicating what type this statement is.
 
Constructor Summary
SpigletStatement(Label lbl, Stmt stmt)
          Creates a statement metadata object.
SpigletStatement(SimpleExp exp)
          Creates a "statement" metadata object that encodes the information in a SimpleExp expression as if it was a statement.
 
Method Summary
 java.util.Set<SpigletTemp> def()
          Returns the set of variables that are in the def set of this statement.
 boolean falls()
          Returns true if this statement falls through the next one.
 SpigletLabel getJump()
          Returns the label of the statement to where this statement can have a control flow to jump.
 SpigletLabel getLabel()
          Returns the label that preclude this statement, if it exists.
 SpigletStatement.Type getType()
          Returns the type of this statement.
 java.lang.String toString()
          Returns a one line string representation of this Spiglet statement followed by its metadata, in the form (Label)? Stmt [def={...}, use={...}, jump=(Label), falls=(bool)].
 java.util.Set<SpigletTemp> use()
          Returns the set of variables that are in the use set of this statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

protected SpigletStatement.Type type
An enum value indicating what type this statement is.

Constructor Detail

SpigletStatement

public SpigletStatement(Label lbl,
                        Stmt stmt)
Creates a statement metadata object. It encodes information from the label (optional) of the statement, and the set of def and use variables in the statement. The constructor method visits and analyzes the given stmt node to generate the def and use sets.

Parameters:
lbl - the label (optional) AST of the processed statement
stmt - the Spiglet statement AST to be processed

SpigletStatement

public SpigletStatement(SimpleExp exp)
Creates a "statement" metadata object that encodes the information in a SimpleExp expression as if it was a statement. Used in encoding the use set of a returned expression in Spiglet. Ultimately, as an exit block in a control flow graph. The "statement" is classified as non-jumping, non-falling through, and label-less.

Parameters:
exp - the return expression to analyze
Method Detail

getLabel

public SpigletLabel getLabel()
Returns the label that preclude this statement, if it exists. null otherwise.

Returns:
the label that precludes this statement

getJump

public SpigletLabel getJump()
Returns the label of the statement to where this statement can have a control flow to jump. null if there is no such jump.

Returns:
the label of the control flow jump

falls

public boolean falls()
Returns true if this statement falls through the next one.

Returns:
true if this statement falls through the next one

getType

public SpigletStatement.Type getType()
Returns the type of this statement.

Returns:
the type of this statement

def

public java.util.Set<SpigletTemp> def()
Returns the set of variables that are in the def set of this statement.

Returns:
the (unmodifiable) set of variables in the def set of this statement

use

public java.util.Set<SpigletTemp> use()
Returns the set of variables that are in the use set of this statement.

Returns:
the (unmodifiable) set of variables in the use set of this statement

toString

public java.lang.String toString()
Returns a one line string representation of this Spiglet statement followed by its metadata, in the form (Label)? Stmt [def={...}, use={...}, jump=(Label), falls=(bool)].

Overrides:
toString in class java.lang.Object
Returns:
A string representation of this Spiglet statement info