Class: Idl::CsrFieldAssignmentAst
- Inherits:
-
AstNode
- Object
- AstNode
- Idl::CsrFieldAssignmentAst
show all
- Includes:
- Executable
- Defined in:
- lib/idlc/ast.rb,
lib/idlc/passes/prune.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
Methods included from Executable
#executable?
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, #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, csr_field, write_value) ⇒ CsrFieldAssignmentAst
Returns a new instance of CsrFieldAssignmentAst.
3367
3368
3369
|
# File 'lib/idlc/ast.rb', line 3367
def initialize(input, interval, csr_field, write_value)
super(input, interval, [csr_field, write_value])
end
|
Class Method Details
.from_h(yaml, source_mapper) ⇒ Object
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
|
# File 'lib/idlc/ast.rb', line 3404
def self.from_h(yaml, source_mapper)
raise "Bad YAML" unless yaml.key?("kind") && yaml.fetch("kind") == "csr_field_assignment"
input = input_from_source_yaml(yaml.fetch("source"), source_mapper)
interval = interval_from_source_yaml(yaml.fetch("source"))
CsrFieldAssignmentAst.new(
input, interval,
T.cast(AstNode.from_h(yaml.fetch("csr_field"), source_mapper), CsrFieldReadExpressionAst),
T.cast(AstNode.from_h(yaml.fetch("value"), source_mapper), RvalueAst)
)
end
|
Instance Method Details
#const_eval?(symtab) ⇒ Boolean
3361
|
# File 'lib/idlc/ast.rb', line 3361
def const_eval?(symtab) = false
|
#execute(symtab) ⇒ void
This method returns an undefined value.
“execute” the statement by updating the variables in the symbol table
3388
3389
3390
|
# File 'lib/idlc/ast.rb', line 3388
def execute(symtab)
value_error "CSR field writes are never compile-time-executable"
end
|
#field(symtab) ⇒ Object
3376
3377
3378
|
# File 'lib/idlc/ast.rb', line 3376
def field(symtab)
csr_field.field_def(symtab)
end
|
#gen_adoc(indent, indent_spaces: 2) ⇒ Object
117
118
119
|
# File 'lib/idlc/passes/gen_adoc.rb', line 117
def gen_adoc(indent, indent_spaces: 2)
"#{' ' * indent}#{csr_field.gen_adoc(indent, indent_spaces:)} = #{write_value.gen_adoc(0, indent_spaces:)}"
end
|
#prune(symtab, forced_type: nil) ⇒ Object
726
727
728
|
# File 'lib/idlc/passes/prune.rb', line 726
def prune(symtab, forced_type: nil)
CsrFieldAssignmentAst.new(input, interval, csr_field.dup, write_value.prune(symtab))
end
|
#to_h ⇒ Object
3396
3397
3398
3399
3400
3401
|
# File 'lib/idlc/ast.rb', line 3396
def to_h = {
"kind" => "csr_field_assignment",
"csr_field" => csr_field.to_h,
"value" => write_value.to_h,
"source" => source_yaml
}
|
#to_idl ⇒ Object
3393
|
# File 'lib/idlc/ast.rb', line 3393
def to_idl = "#{csr_field.to_idl} = #{write_value.to_idl}"
|
#type(symtab) ⇒ Object
3372
3373
3374
|
# File 'lib/idlc/ast.rb', line 3372
def type(symtab)
csr_field.type(symtab)
end
|
#type_check(symtab, strict:) ⇒ Object
3380
3381
3382
3383
3384
3385
|
# File 'lib/idlc/ast.rb', line 3380
def type_check(symtab, strict:)
csr_field.type_check(symtab, strict:)
write_value.type_check(symtab, strict:)
type_error "Incompatible type in assignment" unless write_value.type(symtab).convertable_to?(type(symtab))
end
|
#write_value ⇒ Object
3364
|
# File 'lib/idlc/ast.rb', line 3364
def write_value = T.cast(@children[1], RvalueAst)
|