Class: AdLint::Cc1::UnaryArithmeticExpression

Inherits:
UnaryExpression show all
Defined in:
lib/adlint/cc1/syntax.rb

Instance Attribute Summary

Attributes inherited from UnaryExpression

#operand, #operator

Attributes inherited from SyntaxNode

#head_token, #subsequent_sequence_point, #tail_token

Instance Method Summary collapse

Methods inherited from UnaryExpression

#initialize, #inspect, #location, #to_s

Methods inherited from Expression

#constant?, #full=, #initialize, #object_specifiers, #to_s

Methods inherited from SyntaxNode

#head_location, #initialize, #inspect, #location, #short_class_name, #tail_location

Methods included from LocationHolder

#analysis_target?

Methods included from Visitable

#accept

Constructor Details

This class inherits a constructor from AdLint::Cc1::UnaryExpression

Instance Method Details

#arithmetic?Boolean

Returns:

  • (Boolean)


1462
1463
1464
# File 'lib/adlint/cc1/syntax.rb', line 1462

def arithmetic?
  false
end

#bitwise?Boolean

Returns:

  • (Boolean)


1466
1467
1468
# File 'lib/adlint/cc1/syntax.rb', line 1466

def bitwise?
  operator.type == "~"
end

#have_side_effect?Boolean

Returns:

  • (Boolean)


1454
1455
1456
# File 'lib/adlint/cc1/syntax.rb', line 1454

def have_side_effect?
  operand.have_side_effect?
end

#logical?Boolean

Returns:

  • (Boolean)


1458
1459
1460
# File 'lib/adlint/cc1/syntax.rb', line 1458

def logical?
  operator.type == "!"
end

#to_complemental_logicalObject



1484
1485
1486
1487
1488
1489
1490
1491
1492
# File 'lib/adlint/cc1/syntax.rb', line 1484

def to_complemental_logical
  if operator.type == "!"
    # NOTE: `!' expression should be normalized into an equality-expression
    #       before invoking #to_complemental_logical.
    __NOTREACHED__
  else
    self
  end
end

#to_normalized_logical(parent_expr = nil) ⇒ Object



1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
# File 'lib/adlint/cc1/syntax.rb', line 1470

def to_normalized_logical(parent_expr = nil)
  if operator.type == "!"
    normalized_operand = @operand.to_normalized_logical
    GroupedExpression.new(normalized_operand.to_complemental_logical)
  else
    case parent_expr
    when nil, LogicalAndExpression, LogicalOrExpression
      create_normalized_logical_of(self)
    else
      self
    end
  end
end