Class: Idl::BitfieldType
Constant Summary
Constants inherited from Type
Type::KINDS, Type::QUALIFIERS, Type::TYPE_FROM_KIND
Instance Attribute Summary
Attributes inherited from Type
#kind, #max_width, #qualifiers, #width_ast
Instance Method Summary collapse
- #clone ⇒ Object
- #field_names ⇒ Object
-
#initialize(type_name, width, field_names, field_ranges) ⇒ BitfieldType
constructor
A new instance of BitfieldType.
- #range(field_name) ⇒ Object
- #width ⇒ Object
Methods inherited from Type
#==, #ary?, #ary_type, #comparable_to?, #const?, #convertable_to?, #default, #enum_class, #equal_to?, from_json_schema, from_typename, #global?, #integral?, #known?, #make_const, #make_const!, #make_global, #make_known, #make_signed, #mutable?, #name, #qualify, #runtime?, #signed?, #sub_type, #to_idl, #to_s, #tuple_types
Constructor Details
#initialize(type_name, width, field_names, field_ranges) ⇒ BitfieldType
Returns a new instance of BitfieldType.
726 727 728 729 730 731 732 733 |
# File 'lib/idlc/type.rb', line 726 def initialize(type_name, width, field_names, field_ranges) super(:bitfield, name: type_name, width:) @field_names = field_names @field_ranges = field_ranges raise "unexpected" unless field_names.is_a?(Array) raise "unexpected" unless field_ranges.is_a?(Array) && field_names.length == field_ranges.length end |
Instance Method Details
#clone ⇒ Object
746 747 748 749 750 751 752 753 |
# File 'lib/idlc/type.rb', line 746 def clone BitfieldType.new( name, width, field_names, @field_ranges ) end |
#field_names ⇒ Object
742 743 744 |
# File 'lib/idlc/type.rb', line 742 def field_names @field_names end |
#range(field_name) ⇒ Object
735 736 737 738 739 740 |
# File 'lib/idlc/type.rb', line 735 def range(field_name) i = @field_names.index(field_name) raise "Could not find #{field_name} in #{@name}" if i.nil? @field_ranges[i] end |
#width ⇒ Object
725 |
# File 'lib/idlc/type.rb', line 725 def width = @field_ranges.map(&:size).reduce(&:+) |