class AdLint::Cc1::ForStatement

Attributes

body_statement[R]
condition_statement[R]
expression[R]
header_terminator[R]
initial_statement[R]

Public Class Methods

new(init_stmt, cond_stmt, expr, body_stmt, header_term) click to toggle source
Calls superclass method AdLint::Cc1::Statement::new
# File lib/adlint/cc1/syntax.rb, line 3833
def initialize(init_stmt, cond_stmt, expr, body_stmt, header_term)
  super()
  @initial_statement   = init_stmt
  @condition_statement = cond_stmt
  @expression          = expr
  @body_statement      = body_stmt
  @header_terminator   = header_term
end

Public Instance Methods

deduct_controlling_expression() click to toggle source
# File lib/adlint/cc1/syntax.rb, line 3852
def deduct_controlling_expression
  sels = collect_loop_breaking_selection_statements(@body_statement)
  if expr = @condition_statement.expression
    rough_cands = [[expr, expr.to_normalized_logical]] + sels.map { |stmt|
      [stmt.expression,
        stmt.expression.to_normalized_logical.to_complemental_logical]
    }
  else
    rough_cands = sels.map { |stmt|
      [stmt.expression,
        stmt.expression.to_normalized_logical.to_complemental_logical]
    }
  end

  # FIXME: When many loop breaking selection-statements are found, how can
  #        I select one selection-statement?
  # FIXME: When the loop breaking selection-statement is a
  #        if-else-statement and the loop breaking is in the else branch,
  #        the controlling expression should be inverted.
  deduct_controlling_expression_candidates(rough_cands).first
end
inspect(indent = 0) click to toggle source
# File lib/adlint/cc1/syntax.rb, line 3874
def inspect(indent = 0)
  " " * indent + "#{short_class_name}\n" +
    @initial_statement.inspect(indent + 1) + "\n" +
    @condition_statement.inspect(indent + 1) +
    (@expression ? "\n#{@expression.inspect(indent + 1)}" : "") +
    "\n" + @body_statement.inspect(indent + 1)
end
location() click to toggle source
# File lib/adlint/cc1/syntax.rb, line 3848
def location
  head_location
end