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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 } | 224 } |
225 | 225 |
226 abstract type Member extends Node {} | 226 abstract type Member extends Node {} |
227 | 227 |
228 type Field extends Member { | 228 type Field extends Member { |
229 Byte tag = 4; | 229 Byte tag = 4; |
230 CanonicalNameReference canonicalName; | 230 CanonicalNameReference canonicalName; |
231 FileOffset fileOffset; | 231 FileOffset fileOffset; |
232 FileOffset fileEndOffset; | 232 FileOffset fileEndOffset; |
233 Byte flags (isFinal, isConst, isStatic); | 233 Byte flags (isFinal, isConst, isStatic); |
| 234 // Byte offset in the binary for the parent class, |
| 235 // or 0 if parent is not a class |
| 236 UInt parentPosition; |
234 Name name; | 237 Name name; |
235 // An absolute path URI to the .dart file from which the field was created. | 238 // An absolute path URI to the .dart file from which the field was created. |
236 UriReference fileUri; | 239 UriReference fileUri; |
237 List<Expression> annotations; | 240 List<Expression> annotations; |
238 DartType type; | 241 DartType type; |
239 Option<Expression> initializer; | 242 Option<Expression> initializer; |
240 } | 243 } |
241 | 244 |
242 type Constructor extends Member { | 245 type Constructor extends Member { |
243 Byte tag = 5; | 246 Byte tag = 5; |
244 CanonicalNameReference canonicalName; | 247 CanonicalNameReference canonicalName; |
245 FileOffset fileOffset; | 248 FileOffset fileOffset; |
246 FileOffset fileEndOffset; | 249 FileOffset fileEndOffset; |
247 Byte flags (isConst, isExternal); | 250 Byte flags (isConst, isExternal); |
| 251 UInt parentPosition; // Byte offset in the binary for the parent class. |
248 Name name; | 252 Name name; |
249 List<Expression> annotations; | 253 List<Expression> annotations; |
250 FunctionNode function; | 254 FunctionNode function; |
251 List<Initializer> initializers; | 255 List<Initializer> initializers; |
252 } | 256 } |
253 | 257 |
254 /* | 258 /* |
255 enum ProcedureKind { | 259 enum ProcedureKind { |
256 Method, | 260 Method, |
257 Getter, | 261 Getter, |
258 Setter, | 262 Setter, |
259 Operator, | 263 Operator, |
260 Factory, | 264 Factory, |
261 } | 265 } |
262 */ | 266 */ |
263 | 267 |
264 type Procedure extends Member { | 268 type Procedure extends Member { |
265 Byte tag = 6; | 269 Byte tag = 6; |
266 CanonicalNameReference canonicalName; | 270 CanonicalNameReference canonicalName; |
267 FileOffset fileOffset; | 271 FileOffset fileOffset; |
268 FileOffset fileEndOffset; | 272 FileOffset fileEndOffset; |
269 Byte kind; // Index into the ProcedureKind enum above. | 273 Byte kind; // Index into the ProcedureKind enum above. |
270 Byte flags (isStatic, isAbstract, isExternal, isConst); | 274 Byte flags (isStatic, isAbstract, isExternal, isConst); |
| 275 // Byte offset in the binary for the parent class, |
| 276 // or 0 if parent is not a class. |
| 277 UInt parentPosition; |
271 Name name; | 278 Name name; |
272 // An absolute path URI to the .dart file from which the class was created. | 279 // An absolute path URI to the .dart file from which the class was created. |
273 UriReference fileUri; | 280 UriReference fileUri; |
274 List<Expression> annotations; | 281 List<Expression> annotations; |
275 // Can only be absent if abstract, but tag is there anyway. | 282 // Can only be absent if abstract, but tag is there anyway. |
276 Option<FunctionNode> function; | 283 Option<FunctionNode> function; |
277 } | 284 } |
278 | 285 |
279 abstract type Initializer extends Node {} | 286 abstract type Initializer extends Node {} |
280 | 287 |
(...skipping 28 matching lines...) Expand all Loading... |
309 enum AsyncMarker { | 316 enum AsyncMarker { |
310 Sync, | 317 Sync, |
311 SyncStar, | 318 SyncStar, |
312 Async, | 319 Async, |
313 AsyncStar, | 320 AsyncStar, |
314 SyncYielding | 321 SyncYielding |
315 } | 322 } |
316 */ | 323 */ |
317 | 324 |
318 type FunctionNode { | 325 type FunctionNode { |
319 // Note: there is no tag on FunctionNode. | 326 Byte tag = 3; |
320 FileOffset fileOffset; | 327 FileOffset fileOffset; |
321 FileOffset fileEndOffset; | 328 FileOffset fileEndOffset; |
322 Byte asyncMarker; // Index into AsyncMarker above. | 329 Byte asyncMarker; // Index into AsyncMarker above. |
323 Byte dartAsyncMarker; // Index into AsyncMarker above. | 330 Byte dartAsyncMarker; // Index into AsyncMarker above. |
324 List<TypeParameter> typeParameters; | 331 List<TypeParameter> typeParameters; |
325 UInt requiredParameterCount; | 332 UInt requiredParameterCount; |
326 List<VariableDeclaration> positionalParameters; | 333 List<VariableDeclaration> positionalParameters; |
327 List<VariableDeclaration> namedParameters; | 334 List<VariableDeclaration> namedParameters; |
328 DartType returnType; | 335 DartType returnType; |
329 Option<Statement> body; | 336 Option<Statement> body; |
(...skipping 24 matching lines...) Expand all Loading... |
354 | 361 |
355 abstract type Expression extends Node {} | 362 abstract type Expression extends Node {} |
356 | 363 |
357 type InvalidExpression extends Expression { | 364 type InvalidExpression extends Expression { |
358 Byte tag = 19; | 365 Byte tag = 19; |
359 } | 366 } |
360 | 367 |
361 type VariableGet extends Expression { | 368 type VariableGet extends Expression { |
362 Byte tag = 20; | 369 Byte tag = 20; |
363 FileOffset fileOffset; | 370 FileOffset fileOffset; |
364 UInt variableDeclarationPosition; // Byte offset in the binary for the variabl
e declaration. | 371 // Byte offset in the binary for the variable declaration (without tag). |
| 372 UInt variableDeclarationPosition; |
365 VariableReference variable; | 373 VariableReference variable; |
366 } | 374 } |
367 | 375 |
368 type SpecializedVariableGet extends Expression { | 376 type SpecializedVariableGet extends Expression { |
369 Byte tag = 128 + N; // Where 0 <= N < 8. | 377 Byte tag = 128 + N; // Where 0 <= N < 8. |
370 // Equivalent to a VariableGet with index N. | 378 // Equivalent to a VariableGet with index N. |
371 FileOffset fileOffset; | 379 FileOffset fileOffset; |
372 UInt variableDeclarationPosition; // Byte offset in the binary for the variabl
e declaration. | 380 // Byte offset in the binary for the variable declaration (without tag). |
| 381 UInt variableDeclarationPosition; |
373 } | 382 } |
374 | 383 |
375 type VariableSet extends Expression { | 384 type VariableSet extends Expression { |
376 Byte tag = 21; | 385 Byte tag = 21; |
377 FileOffset fileOffset; | 386 FileOffset fileOffset; |
378 UInt variableDeclarationPosition; // Byte offset in the binary for the variabl
e declaration. | 387 // Byte offset in the binary for the variable declaration (without tag). |
| 388 UInt variableDeclarationPosition; |
379 VariableReference variable; | 389 VariableReference variable; |
380 Expression value; | 390 Expression value; |
381 } | 391 } |
382 | 392 |
383 type SpecializedVariableSet extends Expression { | 393 type SpecializedVariableSet extends Expression { |
384 Byte tag = 136 + N; // Where 0 <= N < 8. | 394 Byte tag = 136 + N; // Where 0 <= N < 8. |
385 FileOffset fileOffset; | 395 FileOffset fileOffset; |
386 UInt variableDeclarationPosition; // Byte offset in the binary for the variabl
e declaration. | 396 // Byte offset in the binary for the variable declaration (without tag). |
| 397 UInt variableDeclarationPosition; |
387 Expression value; | 398 Expression value; |
388 // Equivalent to VariableSet with index N. | 399 // Equivalent to VariableSet with index N. |
389 } | 400 } |
390 | 401 |
391 type PropertyGet extends Expression { | 402 type PropertyGet extends Expression { |
392 Byte tag = 22; | 403 Byte tag = 22; |
393 FileOffset fileOffset; | 404 FileOffset fileOffset; |
394 Expression receiver; | 405 Expression receiver; |
395 Name name; | 406 Name name; |
396 MemberReference interfaceTarget; // May be NullReference. | 407 MemberReference interfaceTarget; // May be NullReference. |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 | 842 |
832 type ReturnStatement extends Statement { | 843 type ReturnStatement extends Statement { |
833 Byte tag = 74; | 844 Byte tag = 74; |
834 FileOffset fileOffset; | 845 FileOffset fileOffset; |
835 Option<Expression> expression; | 846 Option<Expression> expression; |
836 } | 847 } |
837 | 848 |
838 type TryCatch extends Statement { | 849 type TryCatch extends Statement { |
839 Byte tag = 75; | 850 Byte tag = 75; |
840 Statement body; | 851 Statement body; |
841 Byte anyCatchNeedsStackTrace; // 1 if any catch needs a stacktrace (have a sta
cktrace variable). | 852 // 1 if any catch needs a stacktrace (have a stacktrace variable). |
| 853 Byte anyCatchNeedsStackTrace; |
842 List<Catch> catches; | 854 List<Catch> catches; |
843 } | 855 } |
844 | 856 |
845 type Catch { | 857 type Catch { |
846 DartType guard; | 858 DartType guard; |
847 Option<VariableDeclaration> exception; | 859 Option<VariableDeclaration> exception; |
848 Option<VariableDeclaration> stackTrace; | 860 Option<VariableDeclaration> stackTrace; |
849 Statement body; | 861 Statement body; |
850 } | 862 } |
851 | 863 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 type SimpleInterfaceType extends DartType { | 939 type SimpleInterfaceType extends DartType { |
928 Byte tag = 96; // Note: tag is out of order. | 940 Byte tag = 96; // Note: tag is out of order. |
929 ClassReference class; | 941 ClassReference class; |
930 // Equivalent to InterfaceType with empty list of type arguments. | 942 // Equivalent to InterfaceType with empty list of type arguments. |
931 } | 943 } |
932 | 944 |
933 type FunctionType extends DartType { | 945 type FunctionType extends DartType { |
934 Byte tag = 94; | 946 Byte tag = 94; |
935 List<TypeParameter> typeParameters; | 947 List<TypeParameter> typeParameters; |
936 UInt requiredParameterCount; | 948 UInt requiredParameterCount; |
937 UInt totalParameterCount; // positionalParameters.length + namedParameters.len
gth | 949 // positionalParameters.length + namedParameters.length |
| 950 UInt totalParameterCount; |
938 List<DartType> positionalParameters; | 951 List<DartType> positionalParameters; |
939 List<NamedDartType> namedParameters; | 952 List<NamedDartType> namedParameters; |
940 DartType returnType; | 953 DartType returnType; |
941 } | 954 } |
942 | 955 |
943 type SimpleFunctionType extends DartType { | 956 type SimpleFunctionType extends DartType { |
944 Byte tag = 97; // Note: tag is out of order. | 957 Byte tag = 97; // Note: tag is out of order. |
945 List<DartType> positionalParameters; | 958 List<DartType> positionalParameters; |
946 DartType returnType; | 959 DartType returnType; |
947 // Equivalent to a FunctionType with no type parameters or named parameters, | 960 // Equivalent to a FunctionType with no type parameters or named parameters, |
(...skipping 21 matching lines...) Expand all Loading... |
969 // scope there. | 982 // scope there. |
970 // | 983 // |
971 // The type parameter can be bound by a Class, FunctionNode, or FunctionType. | 984 // The type parameter can be bound by a Class, FunctionNode, or FunctionType. |
972 // | 985 // |
973 // Note that constructors currently do not declare type parameters. Uses of | 986 // Note that constructors currently do not declare type parameters. Uses of |
974 // the class type parameters in a constructor refer to those declared on the | 987 // the class type parameters in a constructor refer to those declared on the |
975 // class. | 988 // class. |
976 UInt index; | 989 UInt index; |
977 | 990 |
978 // Byte offset in the binary for the type declaration. | 991 // Byte offset in the binary for the type declaration. |
979 // Note: This can also be 0, which is a 'forward reference' and is not to be u
sed. | 992 // Note: This can also be 0, |
| 993 // which is a 'forward reference' and is not to be used. |
980 UInt typeParameterPosition; | 994 UInt typeParameterPosition; |
981 Option<DartType> bound; | 995 Option<DartType> bound; |
982 } | 996 } |
983 | 997 |
984 type TypeParameter { | 998 type TypeParameter { |
985 // Note: there is no tag on TypeParameter | 999 // Note: there is no tag on TypeParameter |
986 StringReference name; // Cosmetic, may be empty, not unique. | 1000 StringReference name; // Cosmetic, may be empty, not unique. |
987 DartType bound; // 'dynamic' if no explicit bound was given. | 1001 DartType bound; // 'dynamic' if no explicit bound was given. |
988 } | 1002 } |
989 | 1003 |
990 ``` | 1004 ``` |
OLD | NEW |