class AdLint::Cc1::ControllingExpression
DESCRIPTION¶ ↑
Class
structure¶ ↑
ControllingExpression | +-> ValueDomainManipulator | <-- ValueDomainNarrower | <-- ValueDomainWidener | <-- NilValueDomainNarrower | <-- NilValueDomainWidener | +-> ValueDomainNarrowing <-- ValueComparison <-- LogicalAnd <-- LogicalOr <-- StrictObjectDerivation <-- DelayedObjectDerivation
Public Class Methods
new(interp, branch, target_expr = nil)
click to toggle source
# File lib/adlint/cc1/ctrlexpr.rb, line 62 def initialize(interp, branch, target_expr = nil) @interpreter = interp @branch = branch @target_expr = target_expr @manipulators = [] end
Public Instance Methods
affected_variables()
click to toggle source
# File lib/adlint/cc1/ctrlexpr.rb, line 109 def affected_variables @manipulators.map { |manip| manip.affected_variables }.flatten.uniq end
complexly_compounded?()
click to toggle source
# File lib/adlint/cc1/ctrlexpr.rb, line 121 def complexly_compounded? # NOTE: This method determines whether the controlling expression is too # complex to thin value domains of controlling variables. @target_expr && !collect_logical_and_expressions(@target_expr).empty? end
ensure_true_by_narrowing(alt_expr = nil)
click to toggle source
# File lib/adlint/cc1/ctrlexpr.rb, line 69 def ensure_true_by_narrowing(alt_expr = nil) expr = alt_expr || @target_expr if expr new_manip = ValueDomainNarrower.new(@interpreter, expr) if @branch.implicit_condition? eval_quietly { new_manip.prepare! } else new_manip.prepare! end else new_manip = NilValueDomainNarrower.new(@interpreter, @branch.group) end @manipulators.push(new_manip) new_manip end
ensure_true_by_widening(alt_expr = nil)
click to toggle source
# File lib/adlint/cc1/ctrlexpr.rb, line 87 def ensure_true_by_widening(alt_expr = nil) expr = alt_expr || @target_expr if expr new_manip = ValueDomainWidener.new(@interpreter, expr) if @branch.implicit_condition? eval_quietly { new_manip.prepare! } else new_manip.prepare! end else new_manip = NilValueDomainWidener.new(@interpreter, @branch.group) end @manipulators.push(new_manip) new_manip end
restore_affected_variables()
click to toggle source
# File lib/adlint/cc1/ctrlexpr.rb, line 117 def restore_affected_variables @manipulators.each { |manip| manip.restore! } end
save_affected_variables()
click to toggle source
# File lib/adlint/cc1/ctrlexpr.rb, line 113 def save_affected_variables @manipulators.each { |manip| manip.save! } end
to_expr()
click to toggle source
# File lib/adlint/cc1/ctrlexpr.rb, line 127 def to_expr @target_expr end
undo(path_terminated)
click to toggle source
# File lib/adlint/cc1/ctrlexpr.rb, line 105 def undo(path_terminated) @manipulators.each { |manip| manip.rollback! } if path_terminated end
Private Instance Methods
eval_quietly() { || ... }
click to toggle source
# File lib/adlint/cc1/ctrlexpr.rb, line 132 def eval_quietly(&block) originally_quiet = @interpreter.quiet? if @branch.implicit_condition? && !originally_quiet @interpreter._quiet = true end yield ensure if @branch.implicit_condition? && !originally_quiet @interpreter._quiet = false end end