Class: Udb::ParamCondition

Inherits:
Condition show all
Extended by:
T::Sig
Defined in:
lib/udb/condition.rb

Constant Summary

Constants inherited from Condition

Condition::EvalCallbackType, Condition::Xlen32, Condition::Xlen64

Instance Method Summary collapse

Methods inherited from Condition

#&, #-@, conjunction, disjunction, #empty?, #expand_term_requirements, #expand_to_enforce_single_ext_ver, #failing_conjuncts, #has_extension_requirement?, #has_param?, #implied_extension_conflicts, #implied_extension_requirements, join, #make_cb_proc, #minimize, not, one_of, #partial_eval, #partially_evaluate_for_params, #sat_arch_model, #satisfiability_depends_on_ext_req?, #satisfiable?, #satisfiable_by_arch?, #satisfiable_by_cfg_arch?, #satisfied_by_cfg_arch?, #satisfied_by_ext_req?, solver, #solver, solver_for_arch, solver_for_cfg_arch, #to_asciidoc, #to_expanded_logic_tree_shallow, #to_h, #to_idl, #to_logic_tree, #to_s, #to_s_pretty, #to_s_with_value, #unsat_arch_core, #unsatisfiable?, #unsatisfiable_by_arch?, #unsatisfiable_by_cfg_arch?, #z3_assertions, #|

Methods inherited from AbstractCondition

#&, #-@, #always_implies?, #compatible?, #could_be_satisfied_by_cfg_arch?, #covered_by?, #empty?, #equivalent?, #ext_req_terms, #failing_conjuncts, #has_extension_requirement?, #has_param?, #implied_extension_conflicts, #implied_extension_requirements, #implies, #mentions?, #mentions_xlen?, #minimize, #param_terms, #partial_eval, #partially_evaluate_for_params, #rv32_only?, #rv64_only?, #satisfiability_depends_on_ext_req?, #satisfiable?, #satisfiable_by_arch?, #satisfiable_by_cfg_arch?, #satisfied_by_cfg_arch?, #satisfied_by_ext_req?, #to_asciidoc, #to_h, #to_idl, #to_logic_tree, #to_s, #to_s_pretty, #to_s_with_value, #to_yaml, #unsatisfiable?, #unsatisfiable_by_arch?, #unsatisfiable_by_cfg_arch?, #|

Constructor Details

#initialize(yaml, cfg_arch) ⇒ ParamCondition

Returns a new instance of ParamCondition.



1906
1907
1908
# File 'lib/udb/condition.rb', line 1906

def initialize(yaml, cfg_arch)
  super(yaml, cfg_arch)
end

Instance Method Details

#to_logic_tree_internalObject



1955
1956
1957
# File 'lib/udb/condition.rb', line 1955

def to_logic_tree_internal
  @logic_tree ||= to_param_logic_tree_helper(@yaml)
end

#to_param_logic_tree_helper(yaml) ⇒ Object



1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
# File 'lib/udb/condition.rb', line 1916

def to_param_logic_tree_helper(yaml)
  if yaml == true
    LogicNode::True
  elsif yaml == false
    LogicNode::False
  elsif yaml.key?("name")
    LogicNode.new(LogicNodeType::Term, [ParameterTerm.new(yaml)])
  elsif yaml.key?("allOf")
    LogicNode.new(LogicNodeType::And, yaml.fetch("allOf").map { |y| to_param_logic_tree_helper(y) })
  elsif yaml.key?("anyOf")
    LogicNode.new(LogicNodeType::Or, yaml.fetch("anyOf").map { |y| to_param_logic_tree_helper(y) })
  elsif yaml.key?("oneOf")
    LogicNode.new(LogicNodeType::Xor, yaml.fetch("oneOf").map { |y| to_param_logic_tree_helper(y) })
  elsif yaml.key?("noneOf")
    LogicNode.new(LogicNodeType::Not,
      [
        LogicNode.new(LogicNodeType::Or, yaml.fetch("noneOf").map { |y| to_param_logic_tree_helper(y) })
      ]
    )
  elsif yaml.key?("not")
    LogicNode.new(LogicNodeType::Not, [to_param_logic_tree_helper(yaml.fetch("not"))])
  elsif yaml.key?("if")
    LogicNode.new(LogicNodeType::If,
      [
        Condition.new(yaml.fetch("if"), @cfg_arch).to_logic_tree_internal,
        to_param_logic_tree_helper(yaml.fetch("then"))
      ]
    )
  elsif yaml.key?("param")
    to_param_logic_tree_helper(yaml.fetch("param"))
  else
    raise "unexpected key #{yaml.keys}"
  end
end