Class: Idl::BuiltinVariableAst
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
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, #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) ⇒ BuiltinVariableAst
Returns a new instance of BuiltinVariableAst.
5749
5750
5751
5752
|
# File 'lib/idlc/ast.rb', line 5749
def initialize(input, interval, name)
@name = name
super(input, interval, EMPTY_ARRAY)
end
|
Class Method Details
.from_h(yaml, source_mapper) ⇒ Object
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
|
# File 'lib/idlc/ast.rb', line 5788
def self.from_h(yaml, source_mapper)
raise "Bad YAML" unless yaml.key?("kind") && yaml.fetch("kind") == "builtin_var_expr"
input = input_from_source_yaml(yaml.fetch("source"), source_mapper)
interval = interval_from_source_yaml(yaml.fetch("source"))
BuiltinVariableAst.new(
input, interval,
yaml.fetch("name")
)
end
|
Instance Method Details
#const_eval?(symtab) ⇒ Boolean
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
|
# File 'lib/idlc/ast.rb', line 5734
def const_eval?(symtab)
case name
when "$encoding"
true
when "$pc"
false
else
raise "TODO"
end
end
|
#gen_adoc(indent = 0, indent_spaces: 2) ⇒ Object
218
219
220
|
# File 'lib/idlc/passes/gen_adoc.rb', line 218
def gen_adoc(indent = 0, indent_spaces: 2)
name
end
|
#name ⇒ Object
5745
|
# File 'lib/idlc/ast.rb', line 5745
def name = @name
|
#text_value ⇒ Object
5746
|
# File 'lib/idlc/ast.rb', line 5746
def text_value = @name
|
#to_h ⇒ Object
5781
5782
5783
5784
5785
|
# File 'lib/idlc/ast.rb', line 5781
def to_h = {
"kind" => "builtin_var_expr",
"name" => name,
"source" => source_yaml
}
|
#to_idl ⇒ Object
5778
|
# File 'lib/idlc/ast.rb', line 5778
def to_idl = name
|
#type(symtab) ⇒ Object
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
|
# File 'lib/idlc/ast.rb', line 5758
def type(symtab)
case name
when "$encoding"
sz = symtab.get("__instruction_encoding_size")
internal_error "Forgot to set __instruction_encoding_size" if sz.nil?
Type.new(:bits, width: sz.value, qualifiers: [:const, :known])
when "$pc"
if symtab.mxlen == 32
Bits32Type
else
Bits64Type
end
end
end
|
#type_check(symtab, strict:) ⇒ Object
5754
5755
5756
|
# File 'lib/idlc/ast.rb', line 5754
def type_check(symtab, strict:)
type_error "Not a builtin variable" unless ["$pc", "$encoding"].include?(name)
end
|
#value(symtab) ⇒ Object
5773
5774
5775
|
# File 'lib/idlc/ast.rb', line 5773
def value(symtab)
value_error "Cannot know the value of pc or encoding"
end
|