Class: Idl::CommentAst
Overview
represents a comment
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
-
#content ⇒ String
The comment text, with the leading hash and any leading space removed.
-
#initialize(input, interval, text) ⇒ CommentAst
constructor
A new instance of CommentAst.
- #text_value ⇒ Object
- #to_h ⇒ Object
- #to_idl ⇒ 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_adoc, #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, text) ⇒ CommentAst
Returns a new instance of CommentAst.
7119 7120 7121 7122 |
# File 'lib/idlc/ast.rb', line 7119 def initialize(input, interval, text) super(input, interval, EMPTY_ARRAY) @text = text end |
Class Method Details
.from_h(yaml, source_mapper) ⇒ Object
7145 7146 7147 7148 7149 7150 7151 7152 7153 |
# File 'lib/idlc/ast.rb', line 7145 def self.from_h(yaml, source_mapper) raise "Bad YAML" unless yaml.key?("kind") && yaml.fetch("kind") == "comment" input = input_from_source_yaml(yaml.fetch("source"), source_mapper) interval = interval_from_source_yaml(yaml.fetch("source")) CommentAst.new( input, interval, yaml.fetch("content") ) end |
Instance Method Details
#const_eval?(symtab) ⇒ Boolean
7117 |
# File 'lib/idlc/ast.rb', line 7117 def const_eval?(symtab) = true |
#content ⇒ String
Returns The comment text, with the leading hash and any leading space removed.
7132 |
# File 'lib/idlc/ast.rb', line 7132 def content = T.must(text_value[1..]).strip |
#text_value ⇒ Object
7124 |
# File 'lib/idlc/ast.rb', line 7124 def text_value = @text |
#to_h ⇒ Object
7138 7139 7140 7141 7142 |
# File 'lib/idlc/ast.rb', line 7138 def to_h = { "kind" => "comment", "text" => content, "source" => source_yaml } |
#to_idl ⇒ Object
7135 |
# File 'lib/idlc/ast.rb', line 7135 def to_idl = "# #{content}\n" |
#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
7127 |
# File 'lib/idlc/ast.rb', line 7127 def type_check(symtab, strict:); end |