Class: AdLint::Cc1::TypeofTypeSpecifier

Inherits:
TypeSpecifier 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, type_name) ⇒ TypeofTypeSpecifier

Returns a new instance of TypeofTypeSpecifier.



3042
3043
3044
3045
3046
# File 'lib/adlint/cc1/syntax.rb', line 3042

def initialize(expr, type_name)
  super()
  @expression = expr
  @type_name = type_name
end

Instance Attribute Details

#expressionObject (readonly)

Returns the value of attribute expression.



3048
3049
3050
# File 'lib/adlint/cc1/syntax.rb', line 3048

def expression
  @expression
end

#type_nameObject (readonly)

Returns the value of attribute type_name.



3049
3050
3051
# File 'lib/adlint/cc1/syntax.rb', line 3049

def type_name
  @type_name
end

Instance Method Details

#inspect(indent = 0) ⇒ Object



3063
3064
3065
# File 'lib/adlint/cc1/syntax.rb', line 3063

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

#locationObject



3051
3052
3053
# File 'lib/adlint/cc1/syntax.rb', line 3051

def location
  head_location
end

#to_sObject



3055
3056
3057
3058
3059
3060
3061
# File 'lib/adlint/cc1/syntax.rb', line 3055

def to_s
  if @expression
    "__typeof__(#{@expression.to_s})"
  else
    "__typeof__(#{@type_name.to_s})"
  end
end