Class: Udb::Constraint
- Inherits:
-
Object
- Object
- Udb::Constraint
- Extended by:
- T::Sig
- Defined in:
- lib/udb/condition.rb
Overview
wrapper around an IDL function containing constraints
Instance Attribute Summary collapse
- #reason ⇒ String? readonly
Instance Method Summary collapse
- #eval(symtab) ⇒ Boolean
- #initialize(idl, input_file:, input_line:, cfg_arch:, reason: nil) constructor
-
#to_h ⇒ Hash{String => T.untyped}, Boolean
convert into a pure UDB condition.
- #to_logic_tree_internal ⇒ LogicNode private
-
#to_yaml ⇒ String
convert into a pure UDB condition.
Constructor Details
#initialize(idl, input_file:, input_line:, cfg_arch:, reason: nil)
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/udb/condition.rb', line 54 def initialize(idl, input_file:, input_line:, cfg_arch:, reason: nil) @cfg_arch = cfg_arch symtab = cfg_arch.symtab.global_clone begin @ast = @cfg_arch.idl_compiler.compile_constraint(idl, symtab) rescue SyntaxError Udb.logger.error "Could not compile IDL constraint: \n#{idl}" raise end symtab.release @reason = reason end |
Instance Attribute Details
#reason ⇒ String? (readonly)
43 44 45 |
# File 'lib/udb/condition.rb', line 43 def reason @reason end |
Instance Method Details
#eval(symtab) ⇒ Boolean
68 69 70 |
# File 'lib/udb/condition.rb', line 68 def eval(symtab) @ast.satisfied?(symtab) end |
#to_h ⇒ Hash{String => T.untyped}, Boolean
convert into a pure UDB condition
74 75 76 77 78 79 80 |
# File 'lib/udb/condition.rb', line 74 def to_h symtab = @cfg_arch.symtab.global_clone h = @ast.to_udb_h(symtab) symtab.release h end |
#to_logic_tree_internal ⇒ LogicNode
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
92 93 94 |
# File 'lib/udb/condition.rb', line 92 def to_logic_tree_internal Condition.new(to_h, @cfg_arch).to_logic_tree_internal end |
#to_yaml ⇒ String
convert into a pure UDB condition
84 85 86 |
# File 'lib/udb/condition.rb', line 84 def to_yaml YAML.dump(to_h) end |