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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 | 339 |
340 abstract type Expression extends Node {} | 340 abstract type Expression extends Node {} |
341 | 341 |
342 type InvalidExpression extends Expression { | 342 type InvalidExpression extends Expression { |
343 Byte tag = 19; | 343 Byte tag = 19; |
344 } | 344 } |
345 | 345 |
346 type VariableGet extends Expression { | 346 type VariableGet extends Expression { |
347 Byte tag = 20; | 347 Byte tag = 20; |
348 FileOffset fileOffset; | 348 FileOffset fileOffset; |
349 UInt variableDeclarationPosition; // Byte offset in the binary for the variabl e declaration. | |
349 VariableReference variable; | 350 VariableReference variable; |
350 } | 351 } |
351 | 352 |
352 type SpecializedVariableGet extends Expression { | 353 type SpecializedVariableGet extends Expression { |
353 Byte tag = 128 + N; // Where 0 <= N < 8. | 354 Byte tag = 128 + N; // Where 0 <= N < 8. |
354 // Equivalent to a VariableGet with index N. | 355 // Equivalent to a VariableGet with index N. |
355 FileOffset fileOffset; | 356 FileOffset fileOffset; |
357 UInt variableDeclarationPosition; // Byte offset in the binary for the variabl e declaration. | |
356 } | 358 } |
357 | 359 |
358 type VariableSet extends Expression { | 360 type VariableSet extends Expression { |
359 Byte tag = 21; | 361 Byte tag = 21; |
360 FileOffset fileOffset; | 362 FileOffset fileOffset; |
363 UInt variableDeclarationPosition; // Byte offset in the binary for the variabl e declaration. | |
361 VariableReference variable; | 364 VariableReference variable; |
362 Expression value; | 365 Expression value; |
363 } | 366 } |
364 | 367 |
365 type SpecializedVariableSet extends Expression { | 368 type SpecializedVariableSet extends Expression { |
366 Byte tag = 136 + N; // Where 0 <= N < 8. | 369 Byte tag = 136 + N; // Where 0 <= N < 8. |
367 FileOffset fileOffset; | 370 FileOffset fileOffset; |
371 UInt variableDeclarationPosition; // Byte offset in the binary for the variabl e declaration. | |
368 Expression value; | 372 Expression value; |
369 // Equivalent to VariableSet with index N. | 373 // Equivalent to VariableSet with index N. |
370 } | 374 } |
371 | 375 |
372 type PropertyGet extends Expression { | 376 type PropertyGet extends Expression { |
373 Byte tag = 22; | 377 Byte tag = 22; |
374 FileOffset fileOffset; | 378 FileOffset fileOffset; |
375 Expression receiver; | 379 Expression receiver; |
376 Name name; | 380 Name name; |
377 MemberReference interfaceTarget; // May be NullReference. | 381 MemberReference interfaceTarget; // May be NullReference. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
422 | 426 |
423 type StaticSet extends Expression { | 427 type StaticSet extends Expression { |
424 Byte tag = 27; | 428 Byte tag = 27; |
425 FileOffset fileOffset; | 429 FileOffset fileOffset; |
426 MemberReference target; | 430 MemberReference target; |
427 Expression value; | 431 Expression value; |
428 } | 432 } |
429 | 433 |
430 type Arguments { | 434 type Arguments { |
431 // Note: there is no tag on Arguments. | 435 // Note: there is no tag on Arguments. |
436 UInt numArguments; // equals positional.length + named.length | |
432 List<DartType> types; | 437 List<DartType> types; |
433 List<Expression> positional; | 438 List<Expression> positional; |
434 List<NamedExpression> named; | 439 List<NamedExpression> named; |
435 } | 440 } |
436 | 441 |
437 type NamedExpression { | 442 type NamedExpression { |
438 // Note: there is no tag on NamedExpression. | 443 // Note: there is no tag on NamedExpression. |
439 StringReference name; | 444 StringReference name; |
440 Expression value; | 445 Expression value; |
441 } | 446 } |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
773 Expression iterable; | 778 Expression iterable; |
774 Statement body; | 779 Statement body; |
775 } | 780 } |
776 | 781 |
777 type SwitchStatement extends Statement { | 782 type SwitchStatement extends Statement { |
778 Byte tag = 71; | 783 Byte tag = 71; |
779 Expression expression; | 784 Expression expression; |
780 List<SwitchCase> cases; | 785 List<SwitchCase> cases; |
781 } | 786 } |
782 | 787 |
788 type FileOffsetAndExpressionPair { | |
Kevin Millikin (Google)
2017/05/11 10:38:35
I'd just add at the top of the spec (maybe just be
jensj
2017/05/11 12:59:24
Done.
| |
789 FileOffset offset; | |
790 Expression expression; | |
791 } | |
792 | |
783 type SwitchCase { | 793 type SwitchCase { |
784 // Note: there is no tag on SwitchCase | 794 // Note: there is no tag on SwitchCase |
785 List<Expression> expressions; | 795 List<FileOffsetAndExpressionPair> expressions; |
786 FileOffset[expressions.length] expressionOffsets; // 1-to-1 with expressions. | |
787 Byte isDefault; // 1 if default, 0 is not default. | 796 Byte isDefault; // 1 if default, 0 is not default. |
788 Statement body; | 797 Statement body; |
789 } | 798 } |
790 | 799 |
791 type ContinueSwitchStatement extends Statement { | 800 type ContinueSwitchStatement extends Statement { |
792 Byte tag = 72; | 801 Byte tag = 72; |
793 | 802 |
794 // Reference to the Nth SwitchCase in scope. | 803 // Reference to the Nth SwitchCase in scope. |
795 // | 804 // |
796 // A SwitchCase is in scope everywhere within its enclosing switch, | 805 // A SwitchCase is in scope everywhere within its enclosing switch, |
(...skipping 15 matching lines...) Expand all Loading... | |
812 | 821 |
813 type ReturnStatement extends Statement { | 822 type ReturnStatement extends Statement { |
814 Byte tag = 74; | 823 Byte tag = 74; |
815 FileOffset fileOffset; | 824 FileOffset fileOffset; |
816 Option<Expression> expression; | 825 Option<Expression> expression; |
817 } | 826 } |
818 | 827 |
819 type TryCatch extends Statement { | 828 type TryCatch extends Statement { |
820 Byte tag = 75; | 829 Byte tag = 75; |
821 Statement body; | 830 Statement body; |
831 Byte anyCatchNeedsStackTrace; // 1 if any catch needs a stacktrace (have a sta cktrace variable). | |
822 List<Catch> catches; | 832 List<Catch> catches; |
823 } | 833 } |
824 | 834 |
825 type Catch { | 835 type Catch { |
826 DartType guard; | 836 DartType guard; |
827 Option<VariableDeclaration> exception; | 837 Option<VariableDeclaration> exception; |
828 Option<VariableDeclaration> stackTrace; | 838 Option<VariableDeclaration> stackTrace; |
829 Statement body; | 839 Statement body; |
830 } | 840 } |
831 | 841 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
903 type SimpleInterfaceType extends DartType { | 913 type SimpleInterfaceType extends DartType { |
904 Byte tag = 96; // Note: tag is out of order. | 914 Byte tag = 96; // Note: tag is out of order. |
905 ClassReference class; | 915 ClassReference class; |
906 // Equivalent to InterfaceType with empty list of type arguments. | 916 // Equivalent to InterfaceType with empty list of type arguments. |
907 } | 917 } |
908 | 918 |
909 type FunctionType extends DartType { | 919 type FunctionType extends DartType { |
910 Byte tag = 94; | 920 Byte tag = 94; |
911 List<TypeParameter> typeParameters; | 921 List<TypeParameter> typeParameters; |
912 UInt requiredParameterCount; | 922 UInt requiredParameterCount; |
923 UInt totalParameterCount; // positionalParameters.length + namedParameters.len gth | |
913 List<DartType> positionalParameters; | 924 List<DartType> positionalParameters; |
914 List<NamedDartType> namedParameters; | 925 List<NamedDartType> namedParameters; |
915 DartType returnType; | 926 DartType returnType; |
916 } | 927 } |
917 | 928 |
918 type SimpleFunctionType extends DartType { | 929 type SimpleFunctionType extends DartType { |
919 Byte tag = 97; // Note: tag is out of order. | 930 Byte tag = 97; // Note: tag is out of order. |
920 List<DartType> positionalParameters; | 931 List<DartType> positionalParameters; |
921 DartType returnType; | 932 DartType returnType; |
922 // Equivalent to a FunctionType with no type parameters or named parameters, | 933 // Equivalent to a FunctionType with no type parameters or named parameters, |
(...skipping 19 matching lines...) Expand all Loading... | |
942 // from the definition of scoping, since type parameter N+1 is not "in scope" | 953 // from the definition of scoping, since type parameter N+1 is not "in scope" |
943 // in the bound of type parameter N, but it takes up an index as if it was in | 954 // in the bound of type parameter N, but it takes up an index as if it was in |
944 // scope there. | 955 // scope there. |
945 // | 956 // |
946 // The type parameter can be bound by a Class, FunctionNode, or FunctionType. | 957 // The type parameter can be bound by a Class, FunctionNode, or FunctionType. |
947 // | 958 // |
948 // Note that constructors currently do not declare type parameters. Uses of | 959 // Note that constructors currently do not declare type parameters. Uses of |
949 // the class type parameters in a constructor refer to those declared on the | 960 // the class type parameters in a constructor refer to those declared on the |
950 // class. | 961 // class. |
951 UInt index; | 962 UInt index; |
963 | |
964 // Byte offset in the binary for the type declaration. | |
965 // Note: This can also be 0, which is a 'forward reference' and is not to be u sed. | |
966 UInt typeParameterPosition; | |
952 } | 967 } |
953 | 968 |
954 type VectorType extends DartType { | 969 type VectorType extends DartType { |
955 Byte tag = 88; | 970 Byte tag = 88; |
956 } | 971 } |
957 | 972 |
958 type TypeParameter { | 973 type TypeParameter { |
959 // Note: there is no tag on TypeParameter | 974 // Note: there is no tag on TypeParameter |
960 StringReference name; // Cosmetic, may be empty, not unique. | 975 StringReference name; // Cosmetic, may be empty, not unique. |
961 DartType bound; // 'dynamic' if no explicit bound was given. | 976 DartType bound; // 'dynamic' if no explicit bound was given. |
962 } | 977 } |
963 | 978 |
964 ``` | 979 ``` |
OLD | NEW |