at.dms.kjc.cluster
Class TapeBase

java.lang.Object
  extended by at.dms.kjc.cluster.TapeBase
All Implemented Interfaces:
Tape
Direct Known Subclasses:
TapeCluster, TapeDynrate, TapeFixedBase

public abstract class TapeBase
extends Object
implements Tape

Author:
dimock

Field Summary
protected  int dst
          unique id of downstream node from NodeEnumerator
protected  String peek_name
          name of peek routine (downstream)
protected  String pop_name
          name of pop routine (downstream)
protected  String push_name
          name of push routine (upstream)
protected  int src
          unique id of upstream node from NodeEnumerator
protected  CType type
          type of items on the tape.
protected  String typeString
          type of items on the tape as a string.
 
Constructor Summary
TapeBase(int source, int dest, CType type)
          Constructor.
 
Method Summary
abstract  String assignPeekToVar(String varName, String offset)
          Assign the result of peeking.
abstract  String assignPopToVar(String varName)
          Statement, but no ";" to pop an item into a variable.
abstract  String dataDeclaration()
          Data declaration: in .c file if needed else noop.
abstract  String dataDeclarationH()
          Data declaration: in .h file if needed else noop.
abstract  String downstreamCleanup()
          Any cleanup needed before exit for downstream end of tape.
abstract  String downstreamDeclaration()
          Data declaration: for code doing downstream processing.
abstract  String downstreamDeclarationExtern()
          Data declaration: following "extern" if needed else noop.
 int getDest()
          Destination of tape.
 String getPeekName()
          get name of peek(int) routine for downstream end of tape.
 String getPopName()
          get name of pop() routine for downstream end of tape.
 String getPushName()
          get name of push(val) routine for upstream end of tape.
 int getSource()
          Source of tape.
 CType getType()
          Get type of objects communicated over the tape
static Tape newTape(int src, int dest, CType type)
          Select type of tape and return one.
abstract  String peekPrefix()
          prefix to peek expression
abstract  String peekSuffix()
          suffix to peek expression
abstract  String popExpr()
          expression to pop an item: to end of statement.
abstract  String popExprCleanup()
          if expression to pop an item requires statements to clean up then this is cleanup.
abstract  String popExprNoCleanup()
          expression to pop an item, really an expression.
 String popManyItems(String destBuffer, int destOffset, int numItems)
           
abstract  String popNStmt(int N)
          prefix to pop N items discarding them.
abstract  String pushbackCleanup()
           
abstract  String pushbackInit(int NumberToPush)
           
abstract  String pushbackPrefix()
           
abstract  String pushbackSuffix()
           
 String pushManyItems(String sourceBuffer, int sourceOffset, int numItems)
           
abstract  String pushPrefix()
          prefix before data expression to push.
abstract  String pushSuffix()
          suffix after data expression to push.
abstract  String topOfWorkIteration()
          Code used at top of work iteration.
abstract  String upstreamCleanup()
          Any cleanup needed before exit for upstream end of tape.
abstract  String upstreamDeclaration()
          Data declaration: for code doing upstream processing.
abstract  String upstreamDeclarationExtern()
          Data declaration: following "extern" if needed else noop.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

push_name

protected final String push_name
name of push routine (upstream)


pop_name

protected final String pop_name
name of pop routine (downstream)


peek_name

protected final String peek_name
name of peek routine (downstream)


src

protected int src
unique id of upstream node from NodeEnumerator


dst

protected int dst
unique id of downstream node from NodeEnumerator


type

protected CType type
type of items on the tape.


typeString

protected String typeString
type of items on the tape as a string.

Constructor Detail

TapeBase

public TapeBase(int source,
                int dest,
                CType type)
Constructor.

Parameters:
source - a number representing input operator
dest - a number representing output operator
type - a CType representing type of data communicated between the operators
Method Detail

newTape

public static Tape newTape(int src,
                           int dest,
                           CType type)
Select type of tape and return one.
Tapes connect nodes (filters, splitters, joiners). An output of a node is the upstream end of a tape found by RegisterStreams.getNodeOutStreams(at.dms.kjc.sir.SIROperator). An input of a node is the downstream end of a tape found by RegisterStreams.getNodeInStreams(at.dms.kjc.sir.SIROperator)

Parameters:
src - Source node's integer id from NodeEnumerator.
dest - Destination Node's integer if deom NodeEnumerator.
type - Type of data to be passed on tape.
Returns:
an object implementing Tape with sufficient info for code generation.

getSource

public int getSource()
Description copied from interface: Tape
Source of tape.

Specified by:
getSource in interface Tape
Returns:
unique indicator for source SIROperator of tape

getDest

public int getDest()
Description copied from interface: Tape
Destination of tape.

Specified by:
getDest in interface Tape
Returns:
unique indicator for destination SIROperator of tape

getType

public CType getType()
Description copied from interface: Tape
Get type of objects communicated over the tape

Specified by:
getType in interface Tape
Returns:
The type of objects communicated over the tape

getPushName

public String getPushName()
get name of push(val) routine for upstream end of tape.

Specified by:
getPushName in interface Tape
Returns:

getPopName

public String getPopName()
get name of pop() routine for downstream end of tape.

Specified by:
getPopName in interface Tape
Returns:

getPeekName

public String getPeekName()
get name of peek(int) routine for downstream end of tape.

Specified by:
getPeekName in interface Tape
Returns:

dataDeclarationH

public abstract String dataDeclarationH()
Description copied from interface: Tape
Data declaration: in .h file if needed else noop.

Specified by:
dataDeclarationH in interface Tape
Returns:
TODO

dataDeclaration

public abstract String dataDeclaration()
Description copied from interface: Tape
Data declaration: in .c file if needed else noop.

Specified by:
dataDeclaration in interface Tape
Returns:
TODO

downstreamDeclarationExtern

public abstract String downstreamDeclarationExtern()
Description copied from interface: Tape
Data declaration: following "extern" if needed else noop. For downstream end of tape.

Specified by:
downstreamDeclarationExtern in interface Tape
Returns:
TODO

downstreamDeclaration

public abstract String downstreamDeclaration()
Description copied from interface: Tape
Data declaration: for code doing downstream processing.

Specified by:
downstreamDeclaration in interface Tape
Returns:
TODO

upstreamDeclarationExtern

public abstract String upstreamDeclarationExtern()
Description copied from interface: Tape
Data declaration: following "extern" if needed else noop. For upstream end of tape.

Specified by:
upstreamDeclarationExtern in interface Tape
Returns:
TODO

upstreamDeclaration

public abstract String upstreamDeclaration()
Description copied from interface: Tape
Data declaration: for code doing upstream processing.

Specified by:
upstreamDeclaration in interface Tape
Returns:
TODO

topOfWorkIteration

public abstract String topOfWorkIteration()
Description copied from interface: Tape
Code used at top of work iteration.
For instance: resetting pointers in a buffer.

Specified by:
topOfWorkIteration in interface Tape
Returns:
TODO

upstreamCleanup

public abstract String upstreamCleanup()
Description copied from interface: Tape
Any cleanup needed before exit for upstream end of tape.

Specified by:
upstreamCleanup in interface Tape
Returns:
TODO

downstreamCleanup

public abstract String downstreamCleanup()
Description copied from interface: Tape
Any cleanup needed before exit for downstream end of tape.

Specified by:
downstreamCleanup in interface Tape
Returns:
TODO

pushPrefix

public abstract String pushPrefix()
Description copied from interface: Tape
prefix before data expression to push.

Specified by:
pushPrefix in interface Tape
Returns:
TODO

pushSuffix

public abstract String pushSuffix()
Description copied from interface: Tape
suffix after data expression to push.

Specified by:
pushSuffix in interface Tape
Returns:
TODO

pushManyItems

public String pushManyItems(String sourceBuffer,
                            int sourceOffset,
                            int numItems)
Specified by:
pushManyItems in interface Tape

popManyItems

public String popManyItems(String destBuffer,
                           int destOffset,
                           int numItems)
Specified by:
popManyItems in interface Tape

assignPopToVar

public abstract String assignPopToVar(String varName)
Description copied from interface: Tape
Statement, but no ";" to pop an item into a variable. Useful since C can not handle arrays over tapes by simple assignment.

Specified by:
assignPopToVar in interface Tape

popExpr

public abstract String popExpr()
Description copied from interface: Tape
expression to pop an item: to end of statement.

Specified by:
popExpr in interface Tape
Returns:
TODO

popExprNoCleanup

public abstract String popExprNoCleanup()
Description copied from interface: Tape
expression to pop an item, really an expression.

Specified by:
popExprNoCleanup in interface Tape

popExprCleanup

public abstract String popExprCleanup()
Description copied from interface: Tape
if expression to pop an item requires statements to clean up then this is cleanup.

Specified by:
popExprCleanup in interface Tape

popNStmt

public abstract String popNStmt(int N)
Description copied from interface: Tape
prefix to pop N items discarding them.

Specified by:
popNStmt in interface Tape
Returns:
TODO

assignPeekToVar

public abstract String assignPeekToVar(String varName,
                                       String offset)
Description copied from interface: Tape
Assign the result of peeking. Must deal with peeking an array.

Specified by:
assignPeekToVar in interface Tape
Returns:

peekPrefix

public abstract String peekPrefix()
Description copied from interface: Tape
prefix to peek expression

Specified by:
peekPrefix in interface Tape
Returns:
TODO

peekSuffix

public abstract String peekSuffix()
Description copied from interface: Tape
suffix to peek expression

Specified by:
peekSuffix in interface Tape
Returns:
TODO

pushbackInit

public abstract String pushbackInit(int NumberToPush)
Specified by:
pushbackInit in interface Tape

pushbackPrefix

public abstract String pushbackPrefix()
Specified by:
pushbackPrefix in interface Tape

pushbackSuffix

public abstract String pushbackSuffix()
Specified by:
pushbackSuffix in interface Tape

pushbackCleanup

public abstract String pushbackCleanup()
Specified by:
pushbackCleanup in interface Tape