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 ⇒ Object
readonly
Returns the value of attribute reason.
Instance Method Summary collapse
- #eval(symtab) ⇒ Object
-
#initialize(idl, input_file:, input_line:, cfg_arch:, reason: nil) ⇒ Constraint
constructor
A new instance of Constraint.
- #to_h ⇒ Object
- #to_logic_tree_internal ⇒ Object
- #to_yaml ⇒ Object
Constructor Details
#initialize(idl, input_file:, input_line:, cfg_arch:, reason: nil) ⇒ Constraint
Returns a new instance of Constraint.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/udb/condition.rb', line 53 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, input_file: input_file || "[CONSTRAINT]", input_line: input_line || 0 ) rescue SyntaxError Udb.logger.error "Could not compile IDL constraint: \n#{idl}" raise end symtab.release @reason = reason end |
Instance Attribute Details
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
42 43 44 |
# File 'lib/udb/condition.rb', line 42 def reason @reason end |
Instance Method Details
#eval(symtab) ⇒ Object
71 72 73 |
# File 'lib/udb/condition.rb', line 71 def eval(symtab) @ast.satisfied?(symtab) end |
#to_h ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/udb/condition.rb', line 77 def to_h symtab = @cfg_arch.symtab.global_clone h = @ast.to_udb_h(symtab) symtab.release h end |
#to_logic_tree_internal ⇒ Object
95 96 97 |
# File 'lib/udb/condition.rb', line 95 def to_logic_tree_internal Condition.new(to_h, @cfg_arch).to_logic_tree_internal end |
#to_yaml ⇒ Object
87 88 89 |
# File 'lib/udb/condition.rb', line 87 def to_yaml YAML.dump(to_h) end |