Class: Mirah::JVM::Types::BooleanType
- Inherits:
-
PrimitiveType
- Object
- Type
- PrimitiveType
- Mirah::JVM::Types::BooleanType
- Defined in:
- lib/mirah/jvm/types/boolean.rb
Constant Summary
Constants inherited from PrimitiveType
PrimitiveType::WIDENING_CONVERSIONS
Constants included from Logging::Logged
Instance Attribute Summary
Attributes inherited from Type
#inner_class, #name, #type_system
Instance Method Summary collapse
- #add_intrinsics ⇒ Object
-
#compile_boolean_operator(compiler, op, negated, call, label) ⇒ Object
same as NumberType’s.
- #compile_widen(builder, type) ⇒ Object
- #init_value(builder) ⇒ Object
-
#jump_if(builder, op, label) ⇒ Object
Same as IntegerType’s bools are ints for comparison purposes.
- #math_type ⇒ Object
- #prefix ⇒ Object
Methods inherited from PrimitiveType
#box, #box_type, #convertible_to?, #initialize, #interfaces, #newarray, #primitive?, #primitive_type, #superclass, #wrapper_name
Methods inherited from Type
#abstract?, #add_compiled_macro, #add_enumerable_macros, #add_method, #add_method_listener, #aload, #ancestors_and_interfaces, #array?, #array_type, #assignableFrom, #assignable_from?, #astore, #basic_type, #class_id, #compatible?, #component_type, #constructor, #declared_class_methods, #declared_constructors, #declared_instance_methods, #declared_intrinsics, #declared_macros, #dynamic?, #error?, #expand_each, #field_getter, #field_setter, #find_callable_macros, #find_callable_macros2, #find_callable_methods, #find_callable_methods2, #find_callable_static_methods, #flags, #full_name, #generic, #generic?, #getAsmType, #getDeclaredField, #getDeclaredFields, #get_method, #hasStaticField, #include, #initialize, #inner_class?, #inner_class_getter, #inspect, #interface?, #interfaces, #internal_name, #intrinsics, #isAnnotation, #isArray, #isBlock, #isEnum, #isError, #isGeneric, #isMeta, #isPrimitive, #is_parent, #iterable?, #java_method, #jvm_type, #load, #load_extensions, #macro, #macros, #matchesAnything, #meta, #meta?, #method_listeners, #method_updated, #newarray, #pop, #primitive?, #read_macrodef_annotation, #retention, #return, #store, #superclass, #to_s, #type_parameters, #ungeneric, #unmeta, #void?, #wide?, #widen
Methods included from Logging::Logged
#error, #info, #log, #logger, #logger_name, #logging?, #vlog, #warning
Methods included from MethodLookup
#each_is_exact, #each_is_exact_or_subtype_or_convertible, #field_lookup, #find_jls, #find_jls2, #find_method, #find_method2, #inner_class, #is_more_specific?, #phase1, #phase2, #phase3, #primitive_convertible?
Constructor Details
This class inherits a constructor from Mirah::JVM::Types::PrimitiveType
Instance Method Details
#add_intrinsics ⇒ Object
26 27 28 29 30 |
# File 'lib/mirah/jvm/types/boolean.rb', line 26 def add_intrinsics args = [math_type] add_method('==', args, ComparisonIntrinsic.new(self, '==', :eq, args)) add_method('!=', args, ComparisonIntrinsic.new(self, '!=', :ne, args)) end |
#compile_boolean_operator(compiler, op, negated, call, label) ⇒ Object
same as NumberType’s
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/mirah/jvm/types/boolean.rb', line 47 def compile_boolean_operator(compiler, op, negated, call, label) # Promote the target or the argument if necessary convert_args(compiler, [call.target, *call.parameters], [math_type, math_type]) if negated op = invert_op(op) end if label jump_if(compiler.method, op, label) else compiler.method.op_to_bool do |label| jump_if(compiler.method, op, label) end end end |
#compile_widen(builder, type) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/mirah/jvm/types/boolean.rb', line 36 def compile_widen(builder, type) case type.name when 'boolean' when wrapper_name, 'java.lang.Object' builder.invokestatic @wrapper, "valueOf", [@wrapper, builder.send(name)] else raise ArgumentError, "Invalid widening conversion from #{name} to #{type}" end end |
#init_value(builder) ⇒ Object
18 19 20 |
# File 'lib/mirah/jvm/types/boolean.rb', line 18 def init_value(builder) builder.iconst_0 end |
#jump_if(builder, op, label) ⇒ Object
Same as IntegerType’s bools are ints for comparison purposes
66 67 68 |
# File 'lib/mirah/jvm/types/boolean.rb', line 66 def jump_if(builder, op, label) builder.send "if_icmp#{op}", label end |
#math_type ⇒ Object
32 33 34 |
# File 'lib/mirah/jvm/types/boolean.rb', line 32 def math_type @type_system.type(nil, 'boolean') end |
#prefix ⇒ Object
22 23 24 |
# File 'lib/mirah/jvm/types/boolean.rb', line 22 def prefix 'i' end |