Class: Furnace::AVM2::Tokens::ScriptToken

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

Instance Method Summary collapse

Methods included from TokenWithTraits

#transform_trait, #transform_traits

Constructor Details

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

Returns a new instance of ScriptToken.



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

def initialize(origin, options={})
  options = options.merge(environment: :script)

  global_code = Furnace::AVM2::Decompiler.new(origin.initializer_body,
          options.merge(global_code: true)).decompile

  super(origin, [
    *transform_traits(origin, options.merge(static: false)),
    (global_code if global_code.children.any?)
  ], options)

  if options[:debug_funids] && global_code.children.any?
    @children.unshift \
      CommentToken.new(origin,
        "Function ##{origin.initializer_idx}",
      options)
  end
end