-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabc-format-46-16.txt
More file actions
218 lines (190 loc) · 8.05 KB
/
abc-format-46-16.txt
File metadata and controls
218 lines (190 loc) · 8.05 KB
1
2
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
ABC content is versioned. As the format evolves, the version number is updated and
derivative documents are created - THERE IS ONE FILE PER ABC VERSION NUMBER.
This document pertains to major version 46, minor version 16, the initial version.
NOTE, it is believed that this file does not capture all the details of the ABC format
as of 12 January, 2011.
U30 - This is a 30 bit integer value encoded with a variable number of bytes to save space.
All U30's are encoded as 1-5 bytes depending on the value (larger values need more space).
The encoding method is if the hi bit in the current byte is set, then the next byte is also
part of the value. Each bit in a byte contributes 7 bits to the value, with the hi bit telling
us whether to use the next byte, or if this is the last byte for the value. This enables us to
use 30 bit numbers for everything, but still not take up enormous amounts of space.
If more than 30 nonzero bits are present for a U30 field, a verify error will occur.
S32,U32 - same as U30 but 32 bits are allowed instead of being capped at 30.
The "0" entry of each constant pool is not used. If the count for a given pool says there are
"n" entries in the pool, there are "n-1" entries in the file, corresponding to indices 1..(n-1).
AbcFile {
U16 minor_version // = 16
U16 major_version // = 46
U30 constant_int_pool_count
ConstantInteger[constant_int_pool_count] // Cpool entries for integers
U30 constant_uint_pool_count
ConstantUInteger[constant_uint_pool_count] // Cpool entries for uints
U30 constant_double_pool_count
ConstantDouble[constant_double_pool_count] // Cpool entries for doubles
U30 constant_string_pool_count
ConstantString[constant_string_pool_count] // Cpool entries for strings
U30 constant_namespace_pool_count
ConstantNamespace[constant_namespace_pool_count] // Cpool entries for namespaces
U30 constant_namespace_set_pool_count
ConstantNamespaceSet[constant_namespace_set_pool_count] //Cpool entries for namespace sets
U30 constant_multiname_pool_count
ConstantMultiname[constant_multiname_pool_count] //Cpool entries for Multinames, Qnames, RTQnames, and RTQnamesLate
U30 methods_count
MethodInfo[methods_count]
U30 metadata_count
MetadataInfo[metadata_count]
U30 class_count
InstanceInfo[class_count]
ClassInfo[class_count]
U30 script_count
ScriptInfo[script_count] // ScriptInfo[script_count-1] is main entry point
U30 bodies_count
MethodBody[bodies_count]
}
ConstantInteger {
S32 value
}
ConstantUInteger {
U32 value
}
ConstantDouble {
U64 doublebits (little endian)
}
ConstantString {
U30 length
U8[length] // UTF-8 encoded string
}
ConstantNamespace {
U8 kind
union {
kind=8,5,22,23,24,25,26 { // CONSTANT_Namespace, CONSTANT_PrivateNamespace, CONSTANT_PackageNamespace, CONSTANT_PacakgeInternalNamespace, CONSTANT_ProtectedNamespace, CONSTANT_ExplicitNamespace, CONSTANT_StaticProtectedNamespace
U30 name_index // CONSTANT_Utf8 uri (maybe 0)
}
}
}
ConstantNamespaceSet {
U30 namespace_count
U30[namespace_count] // CONSTANT_Namespace
}
ConstantMultiname {
U8 kind
union {
kind=7,13 { // CONSTANT_Qname + CONSTANT_QnameA
U30 namespace_index // CONSTANT_Namespace, 0=AnyNamespace wildcard
U30 name_index // CONSTANT_Utf8, 0=AnyName wildcard
}
kind=9,14 { // CONSTANT_Multiname, CONSTANT_MultinameA
U30 name_index // CONSTANT_Utf8 simple name. 0=AnyName wildcard
U30 namespace_set_index
}
kind=15,16 { // CONSTANT_RTQname + CONSTANT_RTQnameA
U30 name_index // CONSTANT_utf8, 0=AnyName wildcard
}
kind=27 { // CONSTANT_MultinameL
U30 namespace_set_index
}
kind=17,18 // CONSTANT_RTQnameL + CONSTANT_RTQnameLA
}
}
Traits {
U30 count
Trait[count] {
U30 name_index // CONSTANT_QName
U8 kind // hi 4 bits are flags, 0x04: (1=has_metadata, 0=no metadata)
union {
kind=0,6 { // slot, const
U30 slot_id // 0=autoassign
U30 type_index // CONSTANT_Multiname, 0=Object
U30 value_index // CONSTANT_<kind> or 0 for undefined - <kind> depends on the value of value_kind
U8 value_kind // cpool kind the value is, only present if value_index != 0
}
kind=1,2,3 { // method, getter, setter
U30 disp_id // 0=autoassign
U30 method_info // method must be parsed already
// attrs are stored in the hi 4 bits of the kind byte
// 0x01: (1=final,0=virtual), 0x02: (1=override,0=new)
}
kind=4 { // class
U30 slot_id // 0=autoassign
U30 class_info // class must have been parsed already
}
kind=5 { // function
U30 slot_index // 0=autoassign
U30 method_info // method_info of function residing in this slot
}
}
if ( (kind >> 4) & 0x04 ) // these are only present when the kind contains the has_metadata flag
{
U30 metadata_count // Number of metadata
U30 metadata[count] // MetadataInfo indices
}
}
}
MetadataInfo {
U30 name_index // CONSTANT_utf8
U30 values_count // # of values in this metadata
U30 keys[values_count] // CONSTANT_utf8, 0 = keyless
U30 values[values_count] // CONSTANT_utf8
}
InstanceInfo {
U30 name_index // CONSTANT_QName (definition)
U30 super_index // CONSTANT_Multiname (reference)
U8 flags // 1 = sealed, 0 = dynamic
// 2 = final
// 4 = interface
// 8 = protected
U30 protectedNS // if flags & 8
U30 interfaces_count
U30 interfaces[interfaces_count] // CONSTANT_Multiname (references)
U30 iinit_index // MethodInfo
Traits instance_traits
}
ClassInfo {
U30 cinit_index // MethodInfo
Traits static_traits
}
ScriptInfo {
U30 init_index // MethodInfo
Traits traits
}
// A MethodInfo describes the method signature
MethodInfo {
U30 param_count
U30 ret_type // CONSTANT_Multiname, 0=any type (*)
U30 param_types[param_count] // CONSTANT_Multiname, 0=any type (*)
U30 name_index // 0=no name.
// 1=need_arguments, 2=need_activation, 4=need_rest 8=has_optional 16=ignore_rest, 32=explicit, 64=setsdxns, 128=has_paramnames
U8 flags
U30 optional_count // if has_optional
ValueKind[optional_count] // if has_optional
U30 param_names[param_count] // if has_paramnames
}
ValueKind {
U30 value_index // the index for the value in the cpool
U8 value_kind // the kind indicating which cpool the value is in
}
// A MethodBody describes the method implementation.
// not required for native methods or interface methods.
MethodBody {
U30 method_info
U30 max_stack
U30 max_regs
U30 scope_depth
U30 max_scope
U30 code_length
U8 code[code_length]
U30 ex_count
Exception[ex_count]
Traits traits // activation traits
}
Exception {
U30 start // Offsets of beginning and
U30 end // end of the try block
U30 target // Target PC to transfer control to (catch)
U30 type_index // Type matched by this exception handler
U30 name_index // Name of the exception variable
}