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.
829 830 831 |
# File 'lib/idl/ast.rb', line 829 def initialize(input, interval, enum_class_name) super(input, interval, [enum_class_name]) end |
Instance Method Details
#enum_class ⇒ Object
827 |
# File 'lib/idl/ast.rb', line 827 def enum_class = children[0] |
#to_idl ⇒ Object
849 |
# File 'lib/idl/ast.rb', line 849 def to_idl = "$enum_size(#{enum_class.to_idl})" |
#type(symtab) ⇒ Object
837 838 839 840 841 842 843 |
# File 'lib/idl/ast.rb', line 837 def type(symtab) Type.new( :bits, width: enum_class.type(symtab).element_names.size.bit_length, qualifiers: [:const] ) end |
#type_check(symtab) ⇒ Object
833 834 835 |
# File 'lib/idl/ast.rb', line 833 def type_check(symtab) enum_class.type_check(symtab) end |
#value(symtab) ⇒ Object
845 846 847 |
# File 'lib/idl/ast.rb', line 845 def value(symtab) enum_class.type(symtab).element_names.size end |