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.



864
865
866
# File 'lib/idl/ast.rb', line 864

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

Instance Method Details

#enum_classObject



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

def enum_class = children[0]

#to_idlObject



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

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

#type(symtab) ⇒ Object



872
873
874
# File 'lib/idl/ast.rb', line 872

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

#type_check(symtab) ⇒ Object



868
869
870
# File 'lib/idl/ast.rb', line 868

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

#value(symtab) ⇒ Object



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

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