Class: Idl::ImplicationExpressionAst
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 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, #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, antecedent, consequent) ⇒ ImplicationExpressionAst
Returns a new instance of ImplicationExpressionAst.
4097
4098
4099
|
# File 'lib/idlc/ast.rb', line 4097
def initialize(input, interval, antecedent, consequent)
super(input, interval, [antecedent, consequent])
end
|
Class Method Details
.from_h(yaml, source_mapper) ⇒ Object
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
|
# File 'lib/idlc/ast.rb', line 4137
def self.from_h(yaml, source_mapper)
raise "Bad YAML" unless yaml.key?("kind") && yaml.fetch("kind") == "implication_expr"
input = input_from_source_yaml(yaml.fetch("source"), source_mapper)
interval = interval_from_source_yaml(yaml.fetch("source"))
ImplicationExpressionAst.new(
input, interval,
T.cast(AstNode.from_h(yaml.fetch("antecedent"), source_mapper), IdAst),
T.cast(AstNode.from_h(yaml.fetch("consequent"), source_mapper), IdAst)
)
end
|
Instance Method Details
#antecedent ⇒ Object
4108
|
# File 'lib/idlc/ast.rb', line 4108
def antecedent = T.cast(@children.fetch(0), RvalueAst)
|
#consequent ⇒ Object
4111
|
# File 'lib/idlc/ast.rb', line 4111
def consequent = T.cast(@children.fetch(1), RvalueAst)
|
#const_eval?(symtab) ⇒ Boolean
4103
4104
4105
|
# File 'lib/idlc/ast.rb', line 4103
def const_eval?(symtab)
antecedent.const_eval?(symtab) && consequent.const_eval?(symtab)
end
|
#satisfied?(symtab) ⇒ Boolean
4120
4121
4122
4123
|
# File 'lib/idlc/ast.rb', line 4120
def satisfied?(symtab)
return true if antecedent.value(symtab) == false
T.cast(consequent.value(symtab), T::Boolean)
end
|
#to_h ⇒ Object
4129
4130
4131
4132
4133
4134
|
# File 'lib/idlc/ast.rb', line 4129
def to_h = {
"kind" => "implication_expr",
"antecedent" => antecedent.to_h,
"consequent" => consequent.to_h,
"source" => source_yaml
}
|
#to_idl ⇒ Object
4126
|
# File 'lib/idlc/ast.rb', line 4126
def to_idl = "#{antecedent.to_idl} -> #{consequent.to_idl}"
|
#type_check(symtab, strict:) ⇒ Object
4114
4115
4116
4117
|
# File 'lib/idlc/ast.rb', line 4114
def type_check(symtab, strict:)
antecedent.type_error "Antecedent must a boolean" unless antecedent.type(symtab).kind == :boolean
consequent.type_error "Consequent must a boolean" unless consequent.type(symtab).kind == :boolean
end
|