Class: AdLint::Cpp::BinaryExpression

Inherits:
Expression show all
Defined in:
lib/adlint/cpp/syntax.rb

Instance Attribute Summary collapse

Attributes inherited from Expression

#value

Instance Method Summary collapse

Methods inherited from SyntaxNode

#short_class_name

Methods included from LocationHolder

#analysis_target?

Methods included from Visitable

#accept

Constructor Details

#initialize(val, op, lhs_expr, rhs_expr) ⇒ BinaryExpression

Returns a new instance of BinaryExpression.



837
838
839
840
841
842
# File 'lib/adlint/cpp/syntax.rb', line 837

def initialize(val, op, lhs_expr, rhs_expr)
  super(val)
  @operator = op
  @lhs_expression = lhs_expr
  @rhs_expression = rhs_expr
end

Instance Attribute Details

#lhs_expressionObject (readonly)

Returns the value of attribute lhs_expression.



845
846
847
# File 'lib/adlint/cpp/syntax.rb', line 845

def lhs_expression
  @lhs_expression
end

#operatorObject (readonly)

Returns the value of attribute operator.



844
845
846
# File 'lib/adlint/cpp/syntax.rb', line 844

def operator
  @operator
end

#rhs_expressionObject (readonly)

Returns the value of attribute rhs_expression.



846
847
848
# File 'lib/adlint/cpp/syntax.rb', line 846

def rhs_expression
  @rhs_expression
end

Instance Method Details

#inspect(indent = 0) ⇒ Object



856
857
858
859
860
# File 'lib/adlint/cpp/syntax.rb', line 856

def inspect(indent = 0)
  " " * indent + "#{short_class_name} (#{@operator.inspect})\n" +
    @lhs_expression.inspect(indent + 1) + "\n" +
      @rhs_expression.inspect(indent + 1)
end

#locationObject



848
849
850
# File 'lib/adlint/cpp/syntax.rb', line 848

def location
  @lhs_expression.location
end

#to_sObject



852
853
854
# File 'lib/adlint/cpp/syntax.rb', line 852

def to_s
  "#{@lhs_expression.to_s} #{@operator.value} #{@rhs_expression.to_s}"
end