Class: Idl::UserTypeNameAst
- Defined in:
- lib/idlc/ast.rb,
lib/idlc/passes/gen_adoc.rb
Constant Summary
Constants inherited from AstNode
AstNode::Bits1Type, AstNode::Bits32Type, AstNode::Bits64Type, AstNode::BoolType, AstNode::ConstBoolType, AstNode::PossiblyUnknownBits1Type, AstNode::PossiblyUnknownBits32Type, AstNode::PossiblyUnknownBits64Type, AstNode::ReachableFunctionCacheType, AstNode::StringType, AstNode::VoidType
Instance Attribute Summary
Attributes inherited from AstNode
#children, #input, #interval, #parent
Class Method Summary collapse
Instance Method Summary collapse
- #const_eval?(symtab) ⇒ Boolean
- #gen_adoc(indent, indent_spaces: 2) ⇒ Object
-
#initialize(input, interval, name) ⇒ UserTypeNameAst
constructor
A new instance of UserTypeNameAst.
- #text_value ⇒ Object
- #to_h ⇒ Object
- #to_idl ⇒ Object
- #type(symtab) ⇒ Object
-
#type_check(symtab, strict:) ⇒ void
type check this node and all children.
Methods inherited from AstNode
#always_terminates?, #declaration?, #executable?, extract_base_var_name, #find_ancestor, #find_dst_registers, #find_referenced_csrs, #find_src_registers, #freeze_tree, #gen_option_adoc, #input_file, input_from_source_yaml, #inspect, #internal_error, interval_from_source_yaml, #lineno, #lines_around, #nullify_assignments, #pass_find_return_values, #path, #print_ast, #prune, #reachable_exceptions, #reachable_functions, #set_input_file, #set_input_file_unless_already_set, #source_line_file_offsets, #source_starting_offset, #source_yaml, #starting_line, #truncation_warn, #type_error, #unindent, value_else, #value_else, value_error, #value_error, value_try, #value_try, write_back_nested
Constructor Details
#initialize(input, interval, name) ⇒ UserTypeNameAst
Returns a new instance of UserTypeNameAst.
8019 8020 8021 8022 8023 |
# File 'lib/idlc/ast.rb', line 8019 def initialize(input, interval, name) super(input, interval, EMPTY_ARRAY) @type_cache = {} @name = name end |
Class Method Details
.from_h(yaml, source_mapper) ⇒ Object
8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 |
# File 'lib/idlc/ast.rb', line 8056 def self.from_h(yaml, source_mapper) raise "Bad YAML" unless yaml.key?("kind") && yaml.fetch("kind") == "user_type_reference" input = input_from_source_yaml(yaml.fetch("source"), source_mapper) interval = interval_from_source_yaml(yaml.fetch("source")) UserTypeNameAst.new( input, interval, yaml.fetch("name") ) end |
Instance Method Details
#const_eval?(symtab) ⇒ Boolean
8017 |
# File 'lib/idlc/ast.rb', line 8017 def const_eval?(symtab) = true |
#gen_adoc(indent, indent_spaces: 2) ⇒ Object
71 72 73 |
# File 'lib/idlc/passes/gen_adoc.rb', line 71 def gen_adoc(indent, indent_spaces: 2) "#{' ' * indent}#{text_value}" end |
#text_value ⇒ Object
8025 |
# File 'lib/idlc/ast.rb', line 8025 def text_value = @name |
#to_h ⇒ Object
8049 8050 8051 8052 8053 |
# File 'lib/idlc/ast.rb', line 8049 def to_h = { "kind" => "user_type_reference", "name" => text_value, "source" => source_yaml } |
#to_idl ⇒ Object
8046 |
# File 'lib/idlc/ast.rb', line 8046 def to_idl = text_value |
#type(symtab) ⇒ Object
8037 8038 8039 8040 8041 8042 |
# File 'lib/idlc/ast.rb', line 8037 def type(symtab) t = symtab.get(text_value) type_error "Undefined user type: '#{text_value}'" if t.nil? T.must(t) end |
#type_check(symtab, strict:) ⇒ void
This method returns an undefined value.
type check this node and all children
Calls to #type and/or #value may depend on type_check being called first with the same symtab. If not, those functions may raise an AstNode::InternalError
8028 8029 8030 8031 8032 8033 |
# File 'lib/idlc/ast.rb', line 8028 def type_check(symtab, strict:) type_error "Cannot use reserved word '#{text_value}' as user-defined type name" if ReservedWords::RESERVED.include?(text_value) type = type(symtab) type_error "#{text_value} is not a type" unless type.is_a?(Type) end |