de.cau.cs.kieler.krep.compiler.lustre
Class Expression

java.lang.Object
  extended by de.cau.cs.kieler.krep.compiler.lustre.Expression
Direct Known Subclasses:
BinOpExpression, CurrentExpression, IfExpression, InitExpression, NotExpression, NumberExpression, PreExpression, VarAccessExpression, WhenExpression

public abstract class Expression
extends Object

Abstract superclass for Lustre(ec) expression. They are closely related to ceq expression, but here the clock operators are usual expressions.

Rating yellow
(2010-02-05) review by cmot, msp, tam

Field Summary
static int STAGE_CURRENT
          declock clocked equation when current has been seen.
static int STAGE_INIT
          declock clocked equation when init has been seen.
static int STAGE_NEW
          declock fresh clocked equation.
static int STAGE_WHEN
          declock clocked equation when "when" has been seen.
 
Constructor Summary
protected Expression(String n)
           
 
Method Summary
 void addClock(String c)
           
abstract  Equation declock(String basename, int stage, String c, LinkedList<Equation> aux, Program prog)
          remove all clock operators inside.
abstract  Expression extractPre(HashMap<String,Expression> eqs)
           
 ClockList getClock()
           
 Expression getInit()
           
 String getName()
           
 Type getType()
           
abstract  ClockList inferClock(HashMap<String,Variable> vars)
          Compute clock on which this expression runs.
protected abstract  void inferType()
          compute types and set type member recursively in all sub-expressions.
abstract  boolean isAtom()
           
abstract  Expression liftClock()
           
abstract  void propagateClock(ClockList l)
          Propagate to each expression, on which clock it runs.
abstract  Expression propagatePre(HashMap<String,Expression> eqs)
          make sure only simple variables are inside of pre operators.
protected  void setClock(ClockList clk)
           
 void setInit(Expression e)
           
protected  void setName(String n)
           
protected  void setType(Type t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STAGE_NEW

public static final int STAGE_NEW
declock fresh clocked equation.

See Also:
Constant Field Values

STAGE_CURRENT

public static final int STAGE_CURRENT
declock clocked equation when current has been seen.

See Also:
Constant Field Values

STAGE_WHEN

public static final int STAGE_WHEN
declock clocked equation when "when" has been seen.

See Also:
Constant Field Values

STAGE_INIT

public static final int STAGE_INIT
declock clocked equation when init has been seen.

See Also:
Constant Field Values
Constructor Detail

Expression

protected Expression(String n)
Parameters:
n - unique name of the expression
Method Detail

setType

protected void setType(Type t)
Parameters:
t - type of the expression

propagatePre

public abstract Expression propagatePre(HashMap<String,Expression> eqs)
make sure only simple variables are inside of pre operators.

Parameters:
eqs - additionally added equations
Returns:
simplified expression

extractPre

public abstract Expression extractPre(HashMap<String,Expression> eqs)
Parameters:
eqs - add auxiliary equations
Returns:
expression without multiple pres

isAtom

public abstract boolean isAtom()
Returns:
true if expression does not contain any subexpressions

inferClock

public abstract ClockList inferClock(HashMap<String,Variable> vars)
                              throws ClockException
Compute clock on which this expression runs.

Parameters:
vars - list of all defined variables
Returns:
list of all sub-clocks
Throws:
ClockException - thrown if any clock error occurs

propagateClock

public abstract void propagateClock(ClockList l)
Propagate to each expression, on which clock it runs. The clock vector should be computed by inferClock before.

Parameters:
l - clock-vector for the expression

declock

public abstract Equation declock(String basename,
                                 int stage,
                                 String c,
                                 LinkedList<Equation> aux,
                                 Program prog)
remove all clock operators inside.

Parameters:
basename - name of the expression, used for auxiliary expressions
stage - indicate what clock operators have already been in this equation: 0: on top level 1: beyond current 2: beyond when 3: beyond ->
c - clock
aux - additional equations
prog - program that contains the expression
Returns:
new expression, without current, ->, and when

getClock

public ClockList getClock()
Returns:
name of the clock on which this expression runs

inferType

protected abstract void inferType()
                           throws TypeException
compute types and set type member recursively in all sub-expressions.

Throws:
TypeException - thrown if any type problem occurs

getType

public Type getType()
Returns:
type of the expression

getName

public String getName()
Returns:
unique Name of this expression

setInit

public void setInit(Expression e)
Parameters:
e - expression to initialize this variable

getInit

public Expression getInit()
Returns:
expression to initialize this variable

liftClock

public abstract Expression liftClock()
Returns:
equivalent expression with clocks lifted as much as possible.

addClock

public void addClock(String c)
Parameters:
c - additional clock for this expression.

setName

protected void setName(String n)
Parameters:
n - the name to set

setClock

protected void setClock(ClockList clk)
Parameters:
clk - the clock to set