Class: Idl::EnumElementSizeAst

Inherits:
AstNode
  • Object
show all
Defined in:
lib/idl/ast.rb

Overview

represents the builtin that returns the bitwidth of an element in an enum class

$enum_element_size(PrivilegeMode) #=> 3

Instance Method Summary collapse

Constructor Details

#initialize(input, interval, enum_class_name) ⇒ EnumElementSizeAst

Returns a new instance of EnumElementSizeAst.



862
863
864
# File 'lib/idl/ast.rb', line 862

def initialize(input, interval, enum_class_name)
  super(input, interval, [enum_class_name])
end

Instance Method Details

#enum_classObject



860
# File 'lib/idl/ast.rb', line 860

def enum_class = children[0]

#to_idlObject



878
# File 'lib/idl/ast.rb', line 878

def to_idl = "$enum_element_size(#{enum_class.to_idl})"

#type(symtab) ⇒ Object



870
871
872
# File 'lib/idl/ast.rb', line 870

def type(symtab)
  Type.new(:bits, width: enum_class.type(symtab).width, qualifiers: [:const])
end

#type_check(symtab) ⇒ Object



866
867
868
# File 'lib/idl/ast.rb', line 866

def type_check(symtab)
  enum_class.type_check(symtab)
end

#value(symtab) ⇒ Object



874
875
876
# File 'lib/idl/ast.rb', line 874

def value(symtab)
  enum_class.type(symtab).width
end