diff options
Diffstat (limited to 'src/main/scala/scalam/m/ast/statements.scala')
-rw-r--r-- | src/main/scala/scalam/m/ast/statements.scala | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/main/scala/scalam/m/ast/statements.scala b/src/main/scala/scalam/m/ast/statements.scala index 97b9821..5c39fb9 100644 --- a/src/main/scala/scalam/m/ast/statements.scala +++ b/src/main/scala/scalam/m/ast/statements.scala @@ -1,14 +1,34 @@ package scalam.m.ast -trait Statement extends Mable with Root{ +/** + * A matlab statement. + * @define construct statement + */ +trait Statement extends Mable with Root { def m: String = this match { case Assign(id, value) => id.m + " = " + value.m case AssignMatrixIndex(id, indices, value) => id.m + indices.map(_.m).mkString("(", ",", ")") + " = " + value.m - + case _ => throw new IllegalArgumentException("unkown statement: " + this) } } +/** + * Variable assignment. + * @param variable identifer of variable + * @param value value to assign + * + * @define construct assignment + */ case class Assign(variable: Identifier, value: Expression) extends Statement + +/** + * Variable (matrix) index assignment. + * @param variable identifer of variable + * @param indices indices of variable + * @param value value to assign + * + * @define construct variable (matrix) assignment + */ case class AssignMatrixIndex(variable: Identifier, indices: Seq[Expression], value: Expression) extends Statement |