Class: Idl::DontCareReturnAst
- Includes:
- Rvalue
- Defined in:
- lib/idlc/ast.rb,
lib/idlc/passes/gen_adoc.rb
Overview
represents a don’t care return value
for example:
return -;
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) ⇒ DontCareReturnAst
constructor
A new instance of DontCareReturnAst.
- #set_expected_type(t) ⇒ Object
- #to_h ⇒ Object
- #to_idl ⇒ Object
-
#type(_symtab) ⇒ Type
Return the type of this node.
- #type_check(_symtab, strict:) ⇒ Object
-
#value(_symtab) ⇒ Integer, Boolean
Return the compile-time-known value of the node.
Methods included from Rvalue
#max_value, #min_value, #truncate, #values
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, #text_value, #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) ⇒ DontCareReturnAst
Returns a new instance of DontCareReturnAst.
6722 6723 6724 |
# File 'lib/idlc/ast.rb', line 6722 def initialize(input, interval) super(input, interval, EMPTY_ARRAY) end |
Class Method Details
.from_h(yaml, source_mapper) ⇒ Object
6764 6765 6766 6767 6768 6769 6770 6771 6772 |
# File 'lib/idlc/ast.rb', line 6764 def self.from_h(yaml, source_mapper) raise "Bad YAML" unless yaml.key?("kind") && yaml.fetch("kind") == "dont_care" input = input_from_source_yaml(yaml.fetch("source"), source_mapper) interval = interval_from_source_yaml(yaml.fetch("source")) DontCareReturnAst.new( input, interval ) end |
Instance Method Details
#const_eval?(symtab) ⇒ Boolean
6720 |
# File 'lib/idlc/ast.rb', line 6720 def const_eval?(symtab) = true |
#gen_adoc(indent, indent_spaces: 2) ⇒ Object
66 67 68 |
# File 'lib/idlc/passes/gen_adoc.rb', line 66 def gen_adoc(indent, indent_spaces: 2) "#{' ' * indent}-" end |
#set_expected_type(t) ⇒ Object
6750 6751 6752 |
# File 'lib/idlc/ast.rb', line 6750 def set_expected_type(t) @expected_type = t end |
#to_h ⇒ Object
6758 6759 6760 6761 |
# File 'lib/idlc/ast.rb', line 6758 def to_h = { "kind" => "dont_care", "source" => source_yaml } |
#to_idl ⇒ Object
6755 |
# File 'lib/idlc/ast.rb', line 6755 def to_idl = "-" |
#type(_symtab) ⇒ Type
Return the type of this node
6732 6733 6734 |
# File 'lib/idlc/ast.rb', line 6732 def type(_symtab) Type.new(:dontcare) end |
#type_check(_symtab, strict:) ⇒ Object
6727 6728 6729 |
# File 'lib/idlc/ast.rb', line 6727 def type_check(_symtab, strict:) # nothing to do! end |
#value(_symtab) ⇒ Integer, Boolean
Return the compile-time-known value of the node
6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 |
# File 'lib/idlc/ast.rb', line 6737 def value(_symtab) internal_error "Must call set_expected_type first" if @expected_type.nil? case @expected_type.kind when :bits 0 when :boolean false else internal_error "Unhandled expected type" end end |