OLD | NEW |
1 This file describes the binary format of Dart Kernel. | 1 This file describes the binary format of Dart Kernel. |
2 | 2 |
3 Notation | 3 Notation |
4 -------- | 4 -------- |
5 Bitmasks are described with the syntax: | 5 Bitmasks are described with the syntax: |
6 ```scala | 6 ```scala |
7 Byte flags (flag1, flag2, ..., flagN) | 7 Byte flags (flag1, flag2, ..., flagN) |
8 ``` | 8 ``` |
9 where 'flag<N>' is the N-th least significant bit, | 9 where 'flag<N>' is the N-th least significant bit, |
10 (so flag1 is the least significant bit). | 10 (so flag1 is the least significant bit). |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 Byte tag; | 84 Byte tag; |
85 } | 85 } |
86 type Nothing extends Option<T> { | 86 type Nothing extends Option<T> { |
87 Byte tag = 0; | 87 Byte tag = 0; |
88 } | 88 } |
89 type Something<T> extends Option<T> { | 89 type Something<T> extends Option<T> { |
90 Byte tag = 1; | 90 Byte tag = 1; |
91 T value; | 91 T value; |
92 } | 92 } |
93 | 93 |
| 94 type CanonicalNameReference { |
| 95 UInt biasedIndex; // 0 if null, otherwise N+1 where N is index of parent |
| 96 } |
| 97 |
| 98 type CanonicalName { |
| 99 CanonicalNameReference parent; |
| 100 StringReference name; |
| 101 } |
| 102 |
94 type ProgramFile { | 103 type ProgramFile { |
95 MagicWord magic = 0x90ABCDEF; | 104 MagicWord magic = 0x90ABCDEF; |
96 StringTable strings; | 105 StringTable strings; |
97 UriSource sourceMap; | 106 UriSource sourceMap; |
| 107 List<CanonicalName> canonicalNames; |
98 List<Library> libraries; | 108 List<Library> libraries; |
99 LibraryProcedureReference mainMethod; | 109 ProcedureReference mainMethod; |
100 } | 110 } |
101 | 111 |
102 type LibraryReference { | 112 type LibraryReference { |
103 // Index into the ProgramFile libraries. | 113 // Must be populated by a library (possibly later in the file). |
104 UInt index; | 114 CanonicalNameReference canonicalName; |
105 } | 115 } |
106 | 116 |
107 abstract type ClassReference {} | 117 type ClassReference { |
108 | 118 // Must be populated by a class (possibly later in the file). |
109 type NormalClassReference extends ClassReference { | 119 CanonicalNameReference canonicalName; |
110 Byte tag = 100; | |
111 LibraryReference library; | |
112 UInt classIndex; | |
113 } | 120 } |
114 | 121 |
115 type MixinClassReference extends ClassReference { | 122 type MemberReference { |
116 Byte tag = 101; | 123 // Must be populated by a member (possibly later in the file). |
117 LibraryReference library; | 124 CanonicalNameReference canonicalName; |
118 UInt classIndex; | |
119 } | 125 } |
120 | 126 |
121 abstract type MemberReference { | 127 type FieldReference { |
| 128 // Must be populated by a field (possibly later in the file). |
| 129 CanonicalNameReference canonicalName; |
122 } | 130 } |
123 | 131 |
124 type LibraryFieldReference extends MemberReference { | 132 type ConstructorReference { |
125 Byte tag = 102; | 133 // Must be populated by a constructor (possibly later in the file). |
126 LibraryReference library; | 134 CanonicalNameReference canonicalName; |
127 UInt fieldIndex; // Index in list of fields. | |
128 } | 135 } |
129 | 136 |
130 type ClassFieldReference extends MemberReference { | 137 type ProcedureReference { |
131 Byte tag = 103; | 138 // Must be populated by a procedure (possibly later in the file). |
132 ClassReference class; | 139 CanonicalNameReference canonicalName; |
133 UInt fieldIndex; | |
134 } | |
135 | |
136 type ClassConstructorReference extends MemberReference { | |
137 Byte tag = 104; | |
138 ClassReference class; | |
139 UInt constructorIndex; // Index in list of constructors. | |
140 } | |
141 | |
142 type LibraryProcedureReference extends MemberReference { | |
143 Byte tag = 105; | |
144 LibraryReference library; | |
145 UInt procedureIndex; // Index in list of procedures. | |
146 } | |
147 | |
148 type ClassProcedureReference extends MemberReference { | |
149 Byte tag = 106; | |
150 ClassReference class; | |
151 UInt procedureIndex; | |
152 } | |
153 | |
154 // Can be used as MemberReference or ClassReference *only* if indicated that | |
155 // the given reference may be a NullReference. | |
156 type NullReference extends MemberReference, ClassReference { | |
157 Byte tag = 99; | |
158 } | 140 } |
159 | 141 |
160 type Name { | 142 type Name { |
161 StringReference name; | 143 StringReference name; |
162 if name begins with '_' { | 144 if name begins with '_' { |
163 LibraryReference library; | 145 LibraryReference library; |
164 } | 146 } |
165 } | 147 } |
166 | 148 |
167 type Library { | 149 type Library { |
168 Byte flags (isExternal); | 150 Byte flags (isExternal); |
| 151 CanonicalNameReference canonicalName; |
169 StringReference name; | 152 StringReference name; |
170 // A URI from which the library was created. The URI has the dart, package, | |
171 // file, or app scheme. For file URIs, the path is an absolute path to the | |
172 // .dart file from which the library was created. For app URIs, the path is | |
173 // relative to an application root that was specified when the binary was | |
174 // generated. | |
175 StringReference importUri; | |
176 // An absolute path URI to the .dart file from which the library was created. | 153 // An absolute path URI to the .dart file from which the library was created. |
177 UriReference fileUri; | 154 UriReference fileUri; |
178 List<DeferredImport> deferredImports; | 155 List<DeferredImport> deferredImports; |
179 List<Class> classes; | 156 List<Class> classes; |
180 List<Field> fields; | 157 List<Field> fields; |
181 List<Procedure> procedures; | 158 List<Procedure> procedures; |
182 } | 159 } |
183 | 160 |
184 type DeferredImport { | 161 type DeferredImport { |
185 LibraryReference importedLibrary; | 162 LibraryReference importedLibrary; |
(...skipping 12 matching lines...) Expand all Loading... |
198 enum ClassLevel { Type = 0, Hierarchy = 1, Mixin = 2, Body = 3, } | 175 enum ClassLevel { Type = 0, Hierarchy = 1, Mixin = 2, Body = 3, } |
199 | 176 |
200 // A class can be represented at one of three levels: type, hierarchy, or body. | 177 // A class can be represented at one of three levels: type, hierarchy, or body. |
201 // | 178 // |
202 // If the enclosing library is external, a class is either at type or | 179 // If the enclosing library is external, a class is either at type or |
203 // hierarchy level, depending on its isTypeLevel flag. | 180 // hierarchy level, depending on its isTypeLevel flag. |
204 // If the enclosing library is not external, a class is always at body level. | 181 // If the enclosing library is not external, a class is always at body level. |
205 // | 182 // |
206 // See ClassLevel in ast.dart for the details of each loading level. | 183 // See ClassLevel in ast.dart for the details of each loading level. |
207 | 184 |
208 abstract type Class extends Node {} | 185 abstract type Class extends Node { |
209 | |
210 type NormalClass extends Class { | |
211 Byte tag = 2; | 186 Byte tag = 2; |
| 187 CanonicalNameReference canonicalName; |
212 FileOffset fileOffset; | 188 FileOffset fileOffset; |
213 Byte flags (isAbstract, xx); // Where xx is index into ClassLevel | 189 Byte flags (isAbstract, xx); // Where xx is index into ClassLevel |
214 StringReference name; | 190 StringReference name; |
215 // An absolute path URI to the .dart file from which the class was created. | 191 // An absolute path URI to the .dart file from which the class was created. |
216 UriReference fileUri; | 192 UriReference fileUri; |
217 List<Expression> annotations; | 193 List<Expression> annotations; |
218 List<TypeParameter> typeParameters; | 194 List<TypeParameter> typeParameters; |
219 Option<InterfaceType> superClass; | 195 Option<InterfaceType> superClass; |
| 196 Option<InterfaceType> mixedInType; |
220 List<InterfaceType> implementedClasses; | 197 List<InterfaceType> implementedClasses; |
221 List<Field> fields; | 198 List<Field> fields; |
222 List<Constructor> constructors; | 199 List<Constructor> constructors; |
223 List<Procedure> procedures; | 200 List<Procedure> procedures; |
224 } | 201 } |
225 | 202 |
226 type MixinClass extends Class { | |
227 Byte tag = 3; | |
228 FileOffset fileOffset; | |
229 Byte flags (isAbstract, isTypeLevel); | |
230 StringReference name; | |
231 // An absolute path URI to the .dart file from which the class was created. | |
232 UriReference fileUri; | |
233 List<Expression> annotations; | |
234 List<TypeParameter> typeParameters; | |
235 InterfaceType firstSuperClass; | |
236 InterfaceType secondSuperClass; | |
237 List<InterfaceType> implementedClasses; | |
238 List<Constructor> constructors; | |
239 } | |
240 | |
241 abstract type Member extends Node {} | 203 abstract type Member extends Node {} |
242 | 204 |
243 type Field extends Member { | 205 type Field extends Member { |
244 Byte tag = 4; | 206 Byte tag = 4; |
| 207 CanonicalNameReference canonicalName; |
245 FileOffset fileOffset; | 208 FileOffset fileOffset; |
246 FileOffset fileEndOffset; | 209 FileOffset fileEndOffset; |
247 Byte flags (isFinal, isConst, isStatic); | 210 Byte flags (isFinal, isConst, isStatic); |
248 Name name; | 211 Name name; |
249 // An absolute path URI to the .dart file from which the field was created. | 212 // An absolute path URI to the .dart file from which the field was created. |
250 UriReference fileUri; | 213 UriReference fileUri; |
251 List<Expression> annotations; | 214 List<Expression> annotations; |
252 DartType type; | 215 DartType type; |
253 Option<InferredValue> inferredValue; | 216 Option<InferredValue> inferredValue; |
254 Option<Expression> initializer; | 217 Option<Expression> initializer; |
255 } | 218 } |
256 | 219 |
257 type Constructor extends Member { | 220 type Constructor extends Member { |
258 Byte tag = 5; | 221 Byte tag = 5; |
| 222 CanonicalNameReference canonicalName; |
259 FileOffset fileOffset; | 223 FileOffset fileOffset; |
260 FileOffset fileEndOffset; | 224 FileOffset fileEndOffset; |
261 Byte flags (isConst, isExternal); | 225 Byte flags (isConst, isExternal); |
262 Name name; | 226 Name name; |
263 List<Expression> annotations; | 227 List<Expression> annotations; |
264 FunctionNode function; | 228 FunctionNode function; |
265 List<Initializer> initializers; | 229 List<Initializer> initializers; |
266 } | 230 } |
267 | 231 |
268 /* | 232 /* |
269 enum ProcedureKind { | 233 enum ProcedureKind { |
270 Method, | 234 Method, |
271 Getter, | 235 Getter, |
272 Setter, | 236 Setter, |
273 Operator, | 237 Operator, |
274 Factory, | 238 Factory, |
275 } | 239 } |
276 */ | 240 */ |
277 | 241 |
278 type Procedure extends Member { | 242 type Procedure extends Member { |
279 Byte tag = 6; | 243 Byte tag = 6; |
| 244 CanonicalNameReference canonicalName; |
280 FileOffset fileOffset; | 245 FileOffset fileOffset; |
281 FileOffset fileEndOffset; | 246 FileOffset fileEndOffset; |
282 Byte kind; // Index into the ProcedureKind enum above. | 247 Byte kind; // Index into the ProcedureKind enum above. |
283 Byte flags (isStatic, isAbstract, isExternal, isConst); | 248 Byte flags (isStatic, isAbstract, isExternal, isConst); |
284 Name name; | 249 Name name; |
285 // An absolute path URI to the .dart file from which the class was created. | 250 // An absolute path URI to the .dart file from which the class was created. |
286 UriReference fileUri; | 251 UriReference fileUri; |
287 List<Expression> annotations; | 252 List<Expression> annotations; |
288 // Can only be absent if abstract, but tag is there anyway. | 253 // Can only be absent if abstract, but tag is there anyway. |
289 Option<FunctionNode> function; | 254 Option<FunctionNode> function; |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 | 905 |
941 /* enum BaseClassKind { None, Exact, Subclass, Subtype, } */ | 906 /* enum BaseClassKind { None, Exact, Subclass, Subtype, } */ |
942 | 907 |
943 type InferredValue { | 908 type InferredValue { |
944 ClassReference baseClass; // May be NullReference if kind = None. | 909 ClassReference baseClass; // May be NullReference if kind = None. |
945 Byte kind; // Index into BaseClassKind. | 910 Byte kind; // Index into BaseClassKind. |
946 Byte valueBits; // See lib/type_propagation/type_propagation.dart | 911 Byte valueBits; // See lib/type_propagation/type_propagation.dart |
947 } | 912 } |
948 | 913 |
949 ``` | 914 ``` |
OLD | NEW |