diff options
-rw-r--r-- | source/mod_student/translator.ml | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/source/mod_student/translator.ml b/source/mod_student/translator.ml index 6831038..c755cdb 100644 --- a/source/mod_student/translator.ml +++ b/source/mod_student/translator.ml @@ -202,7 +202,20 @@ module Make() = struct | Ast.EXPR_Bool {value=false; _} -> set_jump current_bb else_bb; allocate_block () - + | Ast.EXPR_Binop {op=Ast.BINOP_And;lhs;rhs;_} -> + let current_bb = translate_condition env current_bb else_bb lhs in + let current_bb = translate_condition env current_bb else_bb rhs in + current_bb + + + + | Ast.EXPR_Binop {op=Ast.BINOP_Or;lhs;rhs;_} -> + let bb = allocate_block() in + let current_bb = translate_condition env current_bb bb lhs in + let current_bb = translate_condition env bb else_bb in + bb + + (* Zaimplementuj dodatkowe przypadki *) | e -> @@ -243,7 +256,14 @@ module Make() = struct append_instruction current_bb @@ I_Move (my_reg, reg); current_bb, (Environment.add_var id my_reg env) | STMT_Call call -> - translate_call env current_bb call [] + translate_call env current_bb call [] + | STMT_If {cond;then_branch;else_branch;_} -> + let end_bb =allocate_block() in + let else_bb = allocate_block() in + let current_bb = translate_condition env current_bb else_bb cond in + set_jump current_bb end_bb; + set_jump else_bb end_bb; + end_bb,env | _ -> failwith "not yet implemented" |