Class: Furnace::AVM2::Tokens::PackageToken
- Inherits:
-
Code::NonterminalToken
- Object
- Code::NonterminalToken
- Furnace::AVM2::Tokens::PackageToken
- Defined in:
- lib/furnace-avm2/source/declaration_tokens/package_token.rb
Instance Method Summary collapse
-
#initialize(origin, options = {}) ⇒ PackageToken
constructor
A new instance of PackageToken.
Constructor Details
#initialize(origin, options = {}) ⇒ PackageToken
Returns a new instance of PackageToken.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/furnace-avm2/source/declaration_tokens/package_token.rb', line 3 def initialize(origin, ={}) [:ns] = [:ns].reject { |ns| ns.name == "" || ns.name == "*" } import_ns = [:ns].reject { |ns| ns.name == [:package_name].ns.name || ns.name == "__AS3__.vec" || ns.name !~ /^[A-Za-z0-9_$.]+$/ } case [:package_type] when :class, :interface content = ClassToken.new(origin, ) when :script content = ScriptToken.new(origin, ) end scope = nil if content.children.any? scope = ScopeToken.new(origin, [ *import_ns.map { |ns| ImportToken.new(origin, ns.name, ) }, (Furnace::Code::NewlineToken.new(origin, ) if import_ns.any?), content ], ) end super(origin, [ (PackageNameToken.new(origin, [:package_name].ns.name, ) if [:package_name]), scope, ], ) end |