Class: Idl::EnumSizeAst
Overview
represents the builtin that returns the nymber of elements in an enum class
$enum_size(XRegWidth) #=> 2
Instance Method Summary collapse
- #enum_class ⇒ Object
-
#initialize(input, interval, enum_class_name) ⇒ EnumSizeAst
constructor
A new instance of EnumSizeAst.
- #to_idl ⇒ Object
- #type(symtab) ⇒ Object
- #type_check(symtab) ⇒ Object
- #value(symtab) ⇒ Object
Constructor Details
#initialize(input, interval, enum_class_name) ⇒ EnumSizeAst
Returns a new instance of EnumSizeAst.
827 828 829 |
# File 'lib/idl/ast.rb', line 827 def initialize(input, interval, enum_class_name) super(input, interval, [enum_class_name]) end |
Instance Method Details
#enum_class ⇒ Object
825 |
# File 'lib/idl/ast.rb', line 825 def enum_class = children[0] |
#to_idl ⇒ Object
847 |
# File 'lib/idl/ast.rb', line 847 def to_idl = "$enum_size(#{enum_class.to_idl})" |
#type(symtab) ⇒ Object
835 836 837 838 839 840 841 |
# File 'lib/idl/ast.rb', line 835 def type(symtab) Type.new( :bits, width: enum_class.type(symtab).element_names.size.bit_length, qualifiers: [:const] ) end |
#type_check(symtab) ⇒ Object
831 832 833 |
# File 'lib/idl/ast.rb', line 831 def type_check(symtab) enum_class.type_check(symtab) end |
#value(symtab) ⇒ Object
843 844 845 |
# File 'lib/idl/ast.rb', line 843 def value(symtab) enum_class.type(symtab).element_names.size end |