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.
5734
5735
5736
5737
|
# File 'lib/idlc/ast.rb', line 5734
def initialize(input, interval, name)
@name = name
super(input, interval, EMPTY_ARRAY)
end
|
Class Method Details
.from_h(yaml, source_mapper) ⇒ Object
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
|
# File 'lib/idlc/ast.rb', line 5773
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
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
|
# File 'lib/idlc/ast.rb', line 5719
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
5730
|
# File 'lib/idlc/ast.rb', line 5730
def name = @name
|
#text_value ⇒ Object
5731
|
# File 'lib/idlc/ast.rb', line 5731
def text_value = @name
|
#to_h ⇒ Object
5766
5767
5768
5769
5770
|
# File 'lib/idlc/ast.rb', line 5766
def to_h = {
"kind" => "builtin_var_expr",
"name" => name,
"source" => source_yaml
}
|
#to_idl ⇒ Object
5763
|
# File 'lib/idlc/ast.rb', line 5763
def to_idl = name
|
#type(symtab) ⇒ Object
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
|
# File 'lib/idlc/ast.rb', line 5743
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
5739
5740
5741
|
# File 'lib/idlc/ast.rb', line 5739
def type_check(symtab, strict:)
type_error "Not a builtin variable" unless ["$pc", "$encoding"].include?(name)
end
|
#value(symtab) ⇒ Object
5758
5759
5760
|
# File 'lib/idlc/ast.rb', line 5758
def value(symtab)
value_error "Cannot know the value of pc or encoding"
end
|