Class: Furnace::AVM2::ABC::File
- Inherits:
-
Record
show all
- Defined in:
- lib/furnace-avm2/abc/metadata/file.rb
Constant Summary
collapse
- AS3_KEYWORDS =
%w(as break case catch class const continue default delete
do else extends false finally for function if implements
import in instanceof interface internal is native new
null package private protected public return super switch
this throw to true try typeof use var void while with) +
%w(each get set namespace include dynamic final native
override static) +
%w(abstract boolean byte cast char debugger double enum export
float goto intrinsic long prototype short synchronized throws
to transient type virtual volatile)
Instance Method Summary
collapse
Methods inherited from Record
abc_array_of, flag, pool_array, pool_array_of, pool_ref, subset, xlat_direct, xlat_field, xlat_inverse
#byte_length, codegen, codegen_each, inherited, #inspect, method_missing, register, #to_hash, trace, trace_scope, trace_value
Instance Method Details
#clean_name_part(part) ⇒ Object
97
98
99
100
|
# File 'lib/furnace-avm2/abc/metadata/file.rb', line 97
def clean_name_part(part)
part = part.gsub(/^[^a-zA-Z_$]+/, '').
gsub(/[^a-zA-Z_$0-9:]+/, '')
end
|
#fix_name!(name_idx, options = {}) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/furnace-avm2/abc/metadata/file.rb', line 62
def fix_name!(name_idx, options={})
old_name = constant_pool.strings[name_idx - 1]
return if ["", "*"].include? old_name
fixed_name = sanitize_name(old_name, options)
if old_name != fixed_name || AS3_KEYWORDS.include?(fixed_name)
index = 0
indexed_name = fixed_name
while AS3_KEYWORDS.include?(indexed_name) ||
@name_set.include?(indexed_name)
indexed_name = "#{fixed_name}_i#{index}"
index += 1
end
@name_set.add indexed_name
constant_pool.strings[name_idx - 1] = indexed_name
end
end
|
#fix_names! ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/furnace-avm2/abc/metadata/file.rb', line 31
def fix_names!
@name_set = Set.new(constant_pool.strings)
constant_pool.namespaces.each do |ns|
fix_name!(ns.name_idx, ns: true)
end
constant_pool.multinames.each do |multiname|
if [:QName, :QNameA,
:Multiname, :MultinameA,
:RTQName, :RTQMameA].include? multiname.kind
fix_name!(multiname.data.name_idx)
end
end
end
|
#method_body_at(index) ⇒ Object
27
28
29
|
# File 'lib/furnace-avm2/abc/metadata/file.rb', line 27
def method_body_at(index)
@method_body_indexes[index]
end
|
#root ⇒ Object
23
24
25
|
# File 'lib/furnace-avm2/abc/metadata/file.rb', line 23
def root
self
end
|
#sanitize_name(name, options = {}) ⇒ Object
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/furnace-avm2/abc/metadata/file.rb', line 83
def sanitize_name(name, options={})
if options[:ns]
return name if name.start_with? "http://"
name.split('.').map do |part|
clean_name_part(part)
end.reject do |part|
part.empty?
end.join('.')
else
clean_name_part(name)
end
end
|