Class: Idl::EnumRefAst
- Includes:
- Rvalue
- Defined in:
- lib/idl/ast.rb
Overview
represents an enum reference
for example:
ExtensionName::C
PrivilegeMode::M
Instance Method Summary collapse
- #class_name ⇒ Object
-
#freeze_tree(global_symtab) ⇒ Object
freeze the entire tree from further modification This is also an opportunity to pre-calculate anything that only needs global symbols.
-
#initialize(input, interval, class_name, member_name) ⇒ EnumRefAst
constructor
A new instance of EnumRefAst.
- #member_name ⇒ Object
-
#to_idl ⇒ String
Return valid IDL representation of the node (and its subtree).
- #type(symtab) ⇒ Object
-
#type_check(symtab) ⇒ void
type check this node and all children.
- #value(symtab) ⇒ Object
-
#values(symtab) ⇒ Array<Integer>, ...
included
from Rvalue
Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.
Constructor Details
#initialize(input, interval, class_name, member_name) ⇒ EnumRefAst
Returns a new instance of EnumRefAst.
3421 3422 3423 3424 3425 3426 3427 |
# File 'lib/idl/ast.rb', line 3421 def initialize(input, interval, class_name, member_name) super(input, interval, EMPTY_ARRAY) @enum_class_name = class_name @member_name = member_name @enum_def_type = nil end |
Instance Method Details
#class_name ⇒ Object
3418 |
# File 'lib/idl/ast.rb', line 3418 def class_name = @enum_class_name |
#freeze_tree(global_symtab) ⇒ Object
freeze the entire tree from further modification This is also an opportunity to pre-calculate anything that only needs global symbols
3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 |
# File 'lib/idl/ast.rb', line 3430 def freeze_tree(global_symtab) return if frozen? enum_def_ast = global_symtab.archdef.global_ast.enums.find { |e| e.name == @enum_class_name } @enum_def_type = if enum_def_ast.is_a?(BuiltinEnumDefinitionAst) enum_def_ast&.type(global_symtab) else enum_def_ast&.type(nil) end freeze end |
#member_name ⇒ Object
3419 |
# File 'lib/idl/ast.rb', line 3419 def member_name = @member_name |
#to_idl ⇒ String
Return valid IDL representation of the node (and its subtree)
3471 |
# File 'lib/idl/ast.rb', line 3471 def to_idl = "#{@enum_class_name}::#{@member_name}" |
#type(symtab) ⇒ Object
3456 3457 3458 3459 3460 3461 |
# File 'lib/idl/ast.rb', line 3456 def type(symtab) internal_error "Not frozen?" unless frozen? type_error "No enum named #{@enum_class_name}" if @enum_def_type.nil? @enum_def_type.ref_type end |
#type_check(symtab) ⇒ void
3446 3447 3448 3449 3450 3451 3452 3453 |
# File 'lib/idl/ast.rb', line 3446 def type_check(symtab) enum_def_type = @enum_def_type type_error "No symbol #{@enum_class_name} has been defined" if enum_def_type.nil? type_error "#{@enum_class_name} is not an enum type" unless enum_def_type.is_a?(EnumerationType) type_error "#{@enum_class_name} has no member '#{@member_name}'" if enum_def_type.value(@member_name).nil? end |
#value(symtab) ⇒ Object
3464 3465 3466 3467 3468 |
# File 'lib/idl/ast.rb', line 3464 def value(symtab) internal_error "Must call type_check first" if @enum_def_type.nil? @enum_def_type.value(@member_name) end |
#values(symtab) ⇒ Array<Integer>, ... Originally defined in module Rvalue
Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined
For most AstNodes, this will just be a single-entry array