Class: Stone::AST::TypeDeclaration

Inherits:
Stone::AST show all
Defined in:
lib/stone/ast/type_declaration.rb

Instance Attribute Summary collapse

Attributes inherited from Stone::AST

#children, #name

Instance Method Summary collapse

Constructor Details

#initialize(identifier, type_annotation, location: nil) ⇒ TypeDeclaration

Returns a new instance of TypeDeclaration.



10
11
12
13
14
15
# File 'lib/stone/ast/type_declaration.rb', line 10

def initialize(identifier, type_annotation, location: nil)
  @identifier = identifier
  @type_annotation = type_annotation
  @location = location
  @name = :type_declaration
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



8
9
10
# File 'lib/stone/ast/type_declaration.rb', line 8

def identifier
  @identifier
end

#locationObject (readonly)

Returns the value of attribute location.



8
9
10
# File 'lib/stone/ast/type_declaration.rb', line 8

def location
  @location
end

#type_annotationObject (readonly)

Returns the value of attribute type_annotation.



8
9
10
# File 'lib/stone/ast/type_declaration.rb', line 8

def type_annotation
  @type_annotation
end

Instance Method Details

#to_sObject



17
18
19
# File 'lib/stone/ast/type_declaration.rb', line 17

def to_s
  "#{identifier} :: #{type_annotation}"
end

#type(_context = nil) ⇒ Object

Type declarations don't produce a value, so they have no type



22
23
24
# File 'lib/stone/ast/type_declaration.rb', line 22

def type(_context = nil)
  nil
end