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.



3023
3024
3025
3026
3027
# File 'lib/adlint/cc1/syntax.rb', line 3023

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

Instance Attribute Details

#expressionObject (readonly)

Returns the value of attribute expression.



3029
3030
3031
# File 'lib/adlint/cc1/syntax.rb', line 3029

def expression
  @expression
end

#type_nameObject (readonly)

Returns the value of attribute type_name.



3030
3031
3032
# File 'lib/adlint/cc1/syntax.rb', line 3030

def type_name
  @type_name
end

Instance Method Details

#inspect(indent = 0) ⇒ Object



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

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

#locationObject



3032
3033
3034
# File 'lib/adlint/cc1/syntax.rb', line 3032

def location
  head_location
end

#to_sObject



3036
3037
3038
3039
3040
3041
3042
# File 'lib/adlint/cc1/syntax.rb', line 3036

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