Class: AdLint::Cc1::Initializer

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

Instance Attribute Summary collapse

Attributes inherited from SyntaxNode

#head_token, #subsequent_sequence_point, #tail_token

Instance Method Summary collapse

Methods inherited from SyntaxNode

#head_location, #short_class_name, #tail_location

Methods included from LocationHolder

#analysis_target?

Methods included from Visitable

#accept

Constructor Details

#initialize(expr, inits) ⇒ Initializer

Returns a new instance of Initializer.



4418
4419
4420
4421
4422
# File 'lib/adlint/cc1/syntax.rb', line 4418

def initialize(expr, inits)
  super()
  @expression = expr
  @initializers = inits
end

Instance Attribute Details

#expressionObject (readonly)

Returns the value of attribute expression.



4424
4425
4426
# File 'lib/adlint/cc1/syntax.rb', line 4424

def expression
  @expression
end

#initializersObject (readonly)

Returns the value of attribute initializers.



4425
4426
4427
# File 'lib/adlint/cc1/syntax.rb', line 4425

def initializers
  @initializers
end

Instance Method Details

#inspect(indent = 0) ⇒ Object



4442
4443
4444
# File 'lib/adlint/cc1/syntax.rb', line 4442

def inspect(indent = 0)
  " " * indent + short_class_name
end

#locationObject



4427
4428
4429
# File 'lib/adlint/cc1/syntax.rb', line 4427

def location
  head_location
end

#to_sObject



4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
# File 'lib/adlint/cc1/syntax.rb', line 4431

def to_s
  case
  when @expression
    @expression.to_s
  when @initializers
    "{#{@initializers.map { |ini| ini.to_s }.join(",")}}"
  else
    "{}"
  end
end