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
|
# File 'lib/furnace-avm2/source/declaration_tokens/token_with_traits.rb', line 3
def transform_traits(origin, options)
tokens = []
vars, methods = origin.traits.partition do |trait|
[:Class, :Slot, :Const].include? trait.kind
end
tokens += vars.map { |trait| transform_trait trait, options }
if tokens.any?
tokens << Furnace::Code::NewlineToken.new(origin, options)
end
if options[:environment] == :class
if options[:static]
tokens << CommentToken.new(origin, "Static initializer", options)
tokens << CommentToken.new(origin,
ConstructorToken.new(origin, options.merge(commented: true)),
options)
else
tokens << ConstructorToken.new(origin, options)
end
end
tokens += methods.map { |trait| transform_trait trait, options }
tokens
end
|