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.



4399
4400
4401
4402
4403
# File 'lib/adlint/cc1/syntax.rb', line 4399

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

Instance Attribute Details

#expressionObject (readonly)

Returns the value of attribute expression.



4405
4406
4407
# File 'lib/adlint/cc1/syntax.rb', line 4405

def expression
  @expression
end

#initializersObject (readonly)

Returns the value of attribute initializers.



4406
4407
4408
# File 'lib/adlint/cc1/syntax.rb', line 4406

def initializers
  @initializers
end

Instance Method Details

#inspect(indent = 0) ⇒ Object



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

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

#locationObject



4408
4409
4410
# File 'lib/adlint/cc1/syntax.rb', line 4408

def location
  head_location
end

#to_sObject



4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
# File 'lib/adlint/cc1/syntax.rb', line 4412

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