mirror of
https://github.com/irmen/prog8.git
synced 2025-11-01 22:16:16 +00:00
add if-expression versions for the conditionals if_cc, if_cs, if_vc etc
This commit is contained in:
@@ -100,6 +100,7 @@ class SimplifiedAstMaker(private val program: Program, private val errors: IErro
|
||||
is StringLiteral -> transform(expr)
|
||||
is TypecastExpression -> transform(expr)
|
||||
is IfExpression -> transform(expr)
|
||||
is BranchConditionExpression -> transform(expr)
|
||||
is PtrDereference -> transform(expr)
|
||||
is StaticStructInitializer -> transform(expr)
|
||||
is ArrayIndexedPtrDereference -> throw FatalAstException("this should have been converted to some other ast nodes")
|
||||
@@ -141,6 +142,14 @@ class SimplifiedAstMaker(private val program: Program, private val errors: IErro
|
||||
return ifexpr
|
||||
}
|
||||
|
||||
private fun transform(branchExpr: BranchConditionExpression): PtBranchCondExpression {
|
||||
val type = branchExpr.inferType(program).getOrElse { throw FatalAstException("unknown dt") }
|
||||
val bexpr = PtBranchCondExpression(branchExpr.condition, type, branchExpr.position)
|
||||
bexpr.add(transformExpression(branchExpr.truevalue))
|
||||
bexpr.add(transformExpression(branchExpr.falsevalue))
|
||||
return bexpr
|
||||
}
|
||||
|
||||
private fun transform(srcDefer: Defer): PtDefer {
|
||||
val defer = PtDefer(srcDefer.position)
|
||||
srcDefer.scope.statements.forEach {
|
||||
|
||||
Reference in New Issue
Block a user