Class: Furnace::AVM2::Tokens::ClassToken

Inherits:
Code::NonterminalToken
  • Object
show all
Includes:
TokenWithTraits
Defined in:
lib/furnace-avm2/source/declaration_tokens/class_token.rb

Instance Method Summary collapse

Methods included from TokenWithTraits

#transform_trait, #transform_traits

Constructor Details

#initialize(origin, options = {}) ⇒ ClassToken

Returns a new instance of ClassToken.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/furnace-avm2/source/declaration_tokens/class_token.rb', line 5

def initialize(origin, options={})
  if origin.interface?
    options = options.merge(environment: :interface)
  else
    options = options.merge(environment: :class)
  end

  super(origin, [
    ClassSpecifiersToken.new(origin, options),
    ClassNameToken.new(origin, options),
    (ClassInheritanceToken.new(origin, options) if origin.super_name),
    (ClassImplementationsToken.new(origin, options) if origin.interfaces.any?),
    ScopeToken.new(origin, [
      *transform_traits(origin.klass, options.merge(static: true, instance: origin)),
      (Furnace::Code::NewlineToken.new(origin, options) if origin.klass.traits.any?),
      *transform_traits(origin, options.merge(static: false, instance: origin)),
    ], options)
  ], options)
end