@@ -28,5 +28,38 @@ def box(builder)
28
28
builder . invokestatic box_type , "valueOf" , [ box_type , self ]
29
29
end
30
30
31
+ def add_intrinsics
32
+ args = [ math_type ]
33
+ add_method ( '==' , args , ComparisonIntrinsic . new ( self , '==' , :eq , args ) )
34
+ add_method ( '!=' , args , ComparisonIntrinsic . new ( self , '!=' , :ne , args ) )
35
+ end
36
+
37
+ def math_type
38
+ Boolean
39
+ end
40
+
41
+ # same as NumberType's
42
+ def compile_boolean_operator ( compiler , op , negated , call , label )
43
+ # Promote the target or the argument if necessary
44
+ convert_args ( compiler ,
45
+ [ call . target , *call . parameters ] ,
46
+ [ math_type , math_type ] )
47
+ if negated
48
+ op = invert_op ( op )
49
+ end
50
+ if label
51
+ jump_if ( compiler . method , op , label )
52
+ else
53
+ compiler . method . op_to_bool do |label |
54
+ jump_if ( compiler . method , op , label )
55
+ end
56
+ end
57
+ end
58
+
59
+ # Same as IntegerType's
60
+ # bools are ints for comparison purposes
61
+ def jump_if ( builder , op , label )
62
+ builder . send "if_icmp#{ op } " , label
63
+ end
31
64
end
32
65
end
0 commit comments