Class: Idl::ConstraintBodyAst

Inherits:
AstNode
  • Object
show all
Defined in:
lib/idlc/ast.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 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, stmts) ⇒ ConstraintBodyAst

Returns a new instance of ConstraintBodyAst.



4228
4229
4230
# File 'lib/idlc/ast.rb', line 4228

def initialize(input, interval, stmts)
  super(input, interval, stmts)
end

Class Method Details

.from_h(yaml, source_mapper) ⇒ Object



4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
# File 'lib/idlc/ast.rb', line 4265

def self.from_h(yaml, source_mapper)
  raise "Bad YAML" unless yaml.key?("kind") && yaml.fetch("kind") == "constraint_body"

  input = input_from_source_yaml(yaml.fetch("source"), source_mapper)
  interval = interval_from_source_yaml(yaml.fetch("source"))
  ConstraintBodyAst.new(
    input, interval,
    yaml.fetch("stmts").map { |s| T.cast(AstNode.from_h(s, source_mapper), T.any(ImplicationStatementAst, ForLoopAst)) }
  )
end

Instance Method Details

#const_eval?(symtab) ⇒ Boolean

Returns:

  • (Boolean)


4233
# File 'lib/idlc/ast.rb', line 4233

def const_eval?(symtab) = stmts.all? { |stmt| stmt.const_eval?(symtab) }

#satisfied?(symtab) ⇒ Boolean

Returns:

  • (Boolean)


4246
4247
4248
4249
4250
# File 'lib/idlc/ast.rb', line 4246

def satisfied?(symtab)
  stmts.all? do |stmt|
    stmt.satisfied?(symtab)
  end
end

#stmtsObject



4236
# File 'lib/idlc/ast.rb', line 4236

def stmts = T.cast(@children, T::Array[T.any(ImplicationStatementAst, ForLoopAst)])

#to_hObject



4258
4259
4260
4261
4262
# File 'lib/idlc/ast.rb', line 4258

def to_h = {
  "kind" => "constraint_body",
  "stmts" => stmts.map(&:to_h),
  "source" => source_yaml
}

#to_idlObject



4253
4254
4255
# File 'lib/idlc/ast.rb', line 4253

def to_idl
  stmts.map(&:to_idl).join("\n")
end

#type_check(symtab, strict:) ⇒ Object



4239
4240
4241
4242
4243
# File 'lib/idlc/ast.rb', line 4239

def type_check(symtab, strict:)
  stmts.each do |stmt|
    stmt.type_check(symtab, strict:)
  end
end