def getArray : Expression[_] = array
def getSize : Seq[Expression[IntType]] = size
+ def getExpressions = array +: size
}
def getLHS : Expression[_] = lhs
def getRHS : Expression[_] = rhs
+ def getExpressions = List(lhs, rhs)
}
class Comment(value: String) extends Statement {
def getValue = value
+ def getExpressions = Nil
}
package ofc.codegen
import ofc.LogicError
-class DeallocateStatement(array: Expression[_]) extends Statement {
+class DeallocateStatement(array: Expression[_ <: Type]) extends Statement {
array.getType match {
case (_: ArrayType[_]) => ()
case _ => throw new LogicError("Can only deallocate an array expression.")
}
def getArray : Expression[_] = array
+ def getExpressions = List(array)
}
def getIndex = index
def getBegin = begin
def getEnd = end
+ def getExpressions = List(begin, end)
}
class FunctionCallStatement(call: FunctionCall[VoidType]) extends Statement {
def getCall : FunctionCall[VoidType] = call
+ def getExpressions = call.getParams
}
class IfStatement(predicate: Expression[BoolType]) extends ScopeStatement {
def getPredicate : Expression[BoolType] = predicate
+ def getExpressions = predicate
}
def toConcrete : Statement =
toConcrete(new Comment("Placeholder statement for consumer."))
+
+ def getExpressions =
+ throw new LogicError("Call IterationContext::toConcrete() before trying to access expressions.")
}
}
class BlockStatement(initialStatements: Seq[Statement] = Nil) extends ScopeStatement(initialStatements) {
+ def getExpressions = Nil
}
package ofc.codegen
-trait Statement
-class NullStatement extends Statement
+trait Statement {
+ def getExpressions: Traversable[Expression[_]]
+}
+
+class NullStatement extends Statement {
+ def getExpressions = Nil
+}