Pārlūkot izejas kodu

Disabled type pruning because of usefulness in other phases

Taddeus Kroes 12 gadi atpakaļ
vecāks
revīzija
e326a5b132
2 mainītis faili ar 8 papildinājumiem un 3 dzēšanām
  1. 5 0
      phases/bool_op.ml
  2. 3 3
      phases/typecheck.ml

+ 5 - 0
phases/bool_op.ml

@@ -20,6 +20,11 @@ open Ast
 open Util
 
 let rec bool_op = function
+    | Binop (Eq, (Type (_, Bool) as left), (Type (_, Bool) as right), loc) ->
+        let left = Type (TypeCast (Int, left, noloc), Int) in
+        let right = Type (TypeCast (Int, right, noloc), Int) in
+        Binop (Eq, left, right, loc)
+
     | node -> transform_children bool_op node
 
 let rec phase input =

+ 3 - 3
phases/typecheck.ml

@@ -197,12 +197,12 @@ let rec typecheck node = match node with
 
 (* Remove any Type nodes from the tree to allow more convenient matching in
  * later phases *)
-let rec prune_types = function
+(*let rec prune_types = function
     | Type (node, _) -> prune_types node
-    | node -> transform_children prune_types node
+    | node -> transform_children prune_types node*)
 
 let rec phase input =
     prerr_endline "- Type checking";
     match input with
-    | Ast node -> Ast (prune_types (typecheck node))
+    | Ast node -> Ast (typecheck node)
     | _ -> raise (InvalidInput "typecheck")