|
1 | 1 | package org.combinators.ep.language.inbetween.imperative /*DI:LI:AI*/ |
2 | 2 |
|
3 | | -import org.combinators.cogen.paradigm.{IfThenElse, control, Ternary} |
| 3 | +import org.combinators.cogen.paradigm.{IfThenElse, control} |
4 | 4 | import org.combinators.cogen.paradigm.control.{AssignVariable, DeclareVariable, LiftExpression, Return, While} |
5 | 5 | import org.combinators.cogen.Command.Generator |
6 | 6 | import org.combinators.cogen.{Command, FileWithPath, Understands, paradigm} |
@@ -44,21 +44,7 @@ trait Imperative[AST <: ImperativeAST, B](val _base: AnyParadigm.WithAST[AST] & |
44 | 44 | (context, liftStmt) |
45 | 45 | } |
46 | 46 | } |
47 | | - implicit val canTernary: Understands[Ctxt, Ternary[any.Expression, any.Expression]] = |
48 | | - new Understands[Ctxt, Ternary[any.Expression, any.Expression]] { |
49 | | - /** Returns the updated context and the result of the command. */ |
50 | | - override def perform(context: Ctxt, command: Ternary[any.Expression, any.Expression]): (Ctxt, any.Expression) = { |
51 | | - def contextWithoutMethodBody(context: Ctxt) = |
52 | | - context.copy(statements = Seq.empty) |
53 | | - |
54 | | - val (condCtxt, cond) = Command.runGenerator(Command.lift[Ctxt, any.Expression](command.condition), contextWithoutMethodBody(context)) |
55 | | - val (trueCtxt, trueExpr) = Command.runGenerator(Command.lift[Ctxt, any.Expression](command.trueExpression), contextWithoutMethodBody(condCtxt)) |
56 | | - val (falseCtxt, falseExpr) = Command.runGenerator(Command.lift[Ctxt, any.Expression](command.falseExpression), contextWithoutMethodBody(trueCtxt)) |
57 | | - |
58 | | - val ternaryExpr = imperativeFactory.tertiary(cond, trueExpr, falseExpr) |
59 | | - (context.copy(statements = context.statements), ternaryExpr) |
60 | | - } |
61 | | - } |
| 47 | + |
62 | 48 | implicit val canIfThenElse: Understands[Ctxt, IfThenElse[any.Expression, Generator[Ctxt, Unit], Option[Generator[Ctxt, Unit]], any.Statement]] = |
63 | 49 | new Understands[Ctxt, IfThenElse[any.Expression, Generator[Ctxt, Unit], Option[Generator[Ctxt, Unit]], any.Statement]] { |
64 | 50 | /** Returns the updated context and the result of the command. */ |
|
0 commit comments