at.dms.kjc.sir
Class SIRStream

java.lang.Object
  extended by at.dms.kjc.sir.SIROperator
      extended by at.dms.kjc.sir.SIRStream
All Implemented Interfaces:
DeepCloneable, Finalizable, SIRCodeUnit, Serializable, Cloneable
Direct Known Subclasses:
SIRContainer, SIRGlobal, SIRHelper, SIRPhasedFilter, SIRRecursiveStub, SIRStructure

public abstract class SIRStream
extends SIROperator
implements Cloneable, SIRCodeUnit

This class represents a stream structure with one input and one output.

See Also:
Serialized Form

Field Summary
protected  JFieldDeclaration[] fields
          The fields of this, not including the input and output channels.
protected  String ident
          The name of the class in the StreamIt source file corresponding to this stream.
protected  JMethodDeclaration init
          The init function.
protected  JMethodDeclaration[] methods
          The methods of this, INCLUDING work, init, initPath, etc.
protected  JMethodDeclaration work
          The work function.
 
Constructor Summary
protected SIRStream()
           
protected SIRStream(SIRContainer parent, String ident, JFieldDeclaration[] fields, JMethodDeclaration[] methods)
           
 
Method Summary
 void addField(int offset, JFieldDeclaration f)
          Add a field before a particular offset.
 void addField(JFieldDeclaration field)
          adds field to this, if is not already registered as a field of this.
 void addFields(int offset, JFieldDeclaration[] f)
          Add fields before a particular offset.
 void addFields(JFieldDeclaration[] f)
          Adds to the fields of this.
 void addMethod(JMethodDeclaration method)
          adds method to this, if is not already registered as a method of this.
 void addMethods(JMethodDeclaration[] m)
          Adds to the methods of this.
protected  void addReplacementMethod(JMethodDeclaration newMethod, JMethodDeclaration origMethod)
          Adds newMethod to this.
 Object deepClone()
          Returns a deep clone of this object.
protected  void deepCloneInto(SIRStream other)
          Clones all fields of this into
 JFieldDeclaration[] getFields()
          Gets the field decl's of this stream.
 String getIdent()
          Returns an identifier for this which is NOT unique.
 JMethodDeclaration getInit()
          gets the init function
abstract  CType getInputType()
          Returns the input type of this.
 JMethodDeclaration[] getMethods()
          Gets the method decl's of this stream.
abstract  CType getOutputType()
          Returns the output type of this.
 List<JExpression> getParams()
          Get the parameters that were used to initialize this.
abstract  int getPopForSchedule(HashMap[] counts)
          Same as getPushForSchedule, but with pop instead of push.
abstract  int getPushForSchedule(HashMap[] counts)
          Returns the number of items pushed out of this stream in one execution of the steady-state, given the steady-state execution counts specified by (as in SIRScheduler.) Requires that contains a firing for each *filter* that contained in the hierarchy of this (does not depend on splitters / joiners.) The intent of this method is that can be calculated once for a stream graph, then the splitjoins & pipelines of the graph can be refactored, and one can still call this to get the push count of new constructs without re-invoking the scheduler.
abstract  LIRStreamType getStreamType()
          Returns the type of this stream.
 SIRStream getStreamWithNumber(int num)
          Returns a child stream of this that has number , or null if no deep-child of this has number .
 String getTypeNameInC()
          Returns the C type of the object, which is always a stream_context.
 JMethodDeclaration getWork()
          Gets the work function.
 boolean hasMethod(String name)
          Returns whether or not a function named is defined in this.
 boolean insideFeedbackLoop()
           
static JMethodDeclaration makeEmptyInit()
          Returns an empty init function.
static JMethodDeclaration makeEmptyInitWork()
          Returns an empty prework function.
static JMethodDeclaration makeEmptyWork()
          Returns an empty work function.
 boolean needsInit()
          Returns whether or not this class needs a call to an init function to be generated.
 boolean needsWork()
          Returns whether or not this class needs a call to a work function to be generated.
 void setFields(JFieldDeclaration[] f)
          Set the fields of this to fields, overwriting the old array.
 void setIdent(String ident)
          Sets the identifier of this.
 void setInit(JMethodDeclaration newInit)
          sets the init function
 void setInitWithoutReplacement(JMethodDeclaration newInit)
          sets the init function WITHOUT eliminating the old one in the methods array.
 void setMethods(JMethodDeclaration[] m)
          Install methods as the new methods array.
 void setWork(JMethodDeclaration newWork)
          Sets the work function.
 String toString()
           
 
Methods inherited from class at.dms.kjc.sir.SIROperator
accept, assertMutable, deepCloneInto, getAncestors, getName, getNumber, getParent, getParents, getParentStructureAccess, getRelativeName, getShortIdent, hashCode, readResolve, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

fields

protected JFieldDeclaration[] fields
The fields of this, not including the input and output channels.


methods

protected JMethodDeclaration[] methods
The methods of this, INCLUDING work, init, initPath, etc. This includes all message handlers and local utility functions that are used within this structure.


init

protected JMethodDeclaration init
The init function. Can be null


work

protected JMethodDeclaration work
The work function. Must be non-null for filters, but may be null for SIRContainers.


ident

protected String ident
The name of the class in the StreamIt source file corresponding to this stream.

Constructor Detail

SIRStream

protected SIRStream(SIRContainer parent,
                    String ident,
                    JFieldDeclaration[] fields,
                    JMethodDeclaration[] methods)

SIRStream

protected SIRStream()
Method Detail

setFields

public void setFields(JFieldDeclaration[] f)
Description copied from interface: SIRCodeUnit
Set the fields of this to fields, overwriting the old array.

Specified by:
setFields in interface SIRCodeUnit
Parameters:
f - The fields to install.

addFields

public void addFields(JFieldDeclaration[] f)
Adds to the fields of this. Does not check for duplicates. Adds to end of fields.

Specified by:
addFields in interface SIRCodeUnit
Parameters:
f - The fields to add to the end.

addFields

public void addFields(int offset,
                      JFieldDeclaration[] f)
Add fields before a particular offset. Does not check for duplicates.

Parameters:
offset - offset to add before
f - fields to add

addField

public void addField(int offset,
                     JFieldDeclaration f)
Add a field before a particular offset. Does not check for duplicates.

Parameters:
offset - offset to add before
f - field to add

addMethods

public void addMethods(JMethodDeclaration[] m)
Adds to the methods of this. Does not check for duplicates.

Specified by:
addMethods in interface SIRCodeUnit
Parameters:
m - The methods to attempt to add to the end of the methods.

getFields

public JFieldDeclaration[] getFields()
Gets the field decl's of this stream.

Specified by:
getFields in interface SIRCodeUnit
Returns:
the fields of this unit.

getMethods

public JMethodDeclaration[] getMethods()
Gets the method decl's of this stream.

Specified by:
getMethods in interface SIRCodeUnit
Returns:
the methods of this unit.

setIdent

public void setIdent(String ident)
Sets the identifier of this.


getIdent

public String getIdent()
Description copied from class: SIROperator
Returns an identifier for this which is NOT unique. This will return the same string for a given type of filter that was added to the stream graph.

Specified by:
getIdent in class SIROperator

toString

public String toString()
Overrides:
toString in class Object

setWork

public void setWork(JMethodDeclaration newWork)
Sets the work function.


getParams

public List<JExpression> getParams()
Get the parameters that were used to initialize this. Returns null if this is a top-level stream; returns an empty list if the parameters haven't been resolved yet.


getWork

public JMethodDeclaration getWork()
Gets the work function.


setMethods

public void setMethods(JMethodDeclaration[] m)
Description copied from interface: SIRCodeUnit
Install methods as the new methods array. Disregarding the old methods array.

Specified by:
setMethods in interface SIRCodeUnit
Parameters:
m - The new methods to install.

getOutputType

public abstract CType getOutputType()
Returns the output type of this.


getStreamType

public abstract LIRStreamType getStreamType()
Returns the type of this stream.


getInputType

public abstract CType getInputType()
Returns the input type of this.


getStreamWithNumber

public SIRStream getStreamWithNumber(int num)
Returns a child stream of this that has number , or null if no deep-child of this has number .


getPushForSchedule

public abstract int getPushForSchedule(HashMap[] counts)
Returns the number of items pushed out of this stream in one execution of the steady-state, given the steady-state execution counts specified by (as in SIRScheduler.) Requires that contains a firing for each *filter* that contained in the hierarchy of this (does not depend on splitters / joiners.) The intent of this method is that can be calculated once for a stream graph, then the splitjoins & pipelines of the graph can be refactored, and one can still call this to get the push count of new constructs without re-invoking the scheduler.


getPopForSchedule

public abstract int getPopForSchedule(HashMap[] counts)
Same as getPushForSchedule, but with pop instead of push.


needsInit

public boolean needsInit()
Returns whether or not this class needs a call to an init function to be generated. Special library functions like FileReader's and FileWriter's do not need an init call.


needsWork

public boolean needsWork()
Returns whether or not this class needs a call to a work function to be generated. Special library functions like FileReader's and FileWriter's do not need a work call at the level of the Kopi IR (it is generated in C).


setInit

public void setInit(JMethodDeclaration newInit)
sets the init function


setInitWithoutReplacement

public void setInitWithoutReplacement(JMethodDeclaration newInit)
sets the init function WITHOUT eliminating the old one in the methods array. Usually you want to use the plain setInit unless you're fusing.


addReplacementMethod

protected void addReplacementMethod(JMethodDeclaration newMethod,
                                    JMethodDeclaration origMethod)
Adds newMethod to this. If origMethod is a method of this, then newMethod takes its first place (origMethod is removed). If origMethod is null, then newMethod is just added to this. If newMethod is null, then origMethod is removed. Assumes origMethod appears at most once in this (as should all methods.)


addMethod

public void addMethod(JMethodDeclaration method)
adds method to this, if is not already registered as a method of this. Requires that is non-null.

Specified by:
addMethod in interface SIRCodeUnit
Parameters:
method - The method to add.

addField

public void addField(JFieldDeclaration field)
adds field to this, if is not already registered as a field of this.

Specified by:
addField in interface SIRCodeUnit
Parameters:
field - The field to attempt to add.

hasMethod

public boolean hasMethod(String name)
Returns whether or not a function named is defined in this.


getTypeNameInC

public String getTypeNameInC()
Returns the C type of the object, which is always a stream_context. In the generated C code, there will be a structure by this name to hold the state of the stream. This is SPECIFIC TO THE UNIPROCESSOR BACKEND.


getInit

public JMethodDeclaration getInit()
gets the init function


insideFeedbackLoop

public boolean insideFeedbackLoop()

makeEmptyWork

public static JMethodDeclaration makeEmptyWork()
Returns an empty work function.


makeEmptyInitWork

public static JMethodDeclaration makeEmptyInitWork()
Returns an empty prework function.


makeEmptyInit

public static JMethodDeclaration makeEmptyInit()
Returns an empty init function.


deepClone

public Object deepClone()
Returns a deep clone of this object.

Specified by:
deepClone in interface DeepCloneable
Overrides:
deepClone in class SIROperator

deepCloneInto

protected void deepCloneInto(SIRStream other)
Clones all fields of this into
other