OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 library kernel.ast_from_binary; | 4 library kernel.ast_from_binary; |
5 | 5 |
6 import '../ast.dart'; | 6 import '../ast.dart'; |
7 import 'tag.dart'; | 7 import 'tag.dart'; |
8 import 'loader.dart'; | 8 import 'loader.dart'; |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 import 'package:kernel/transformations/flags.dart'; | 10 import 'package:kernel/transformations/flags.dart'; |
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 } | 809 } |
810 | 810 |
811 List<Supertype> readSupertypeList() { | 811 List<Supertype> readSupertypeList() { |
812 return new List<Supertype>.generate(readUInt(), (i) => readSupertype()); | 812 return new List<Supertype>.generate(readUInt(), (i) => readSupertype()); |
813 } | 813 } |
814 | 814 |
815 List<DartType> readDartTypeList() { | 815 List<DartType> readDartTypeList() { |
816 return new List<DartType>.generate(readUInt(), (i) => readDartType()); | 816 return new List<DartType>.generate(readUInt(), (i) => readDartType()); |
817 } | 817 } |
818 | 818 |
| 819 List<NamedType> readNamedTypeList() { |
| 820 return new List<NamedType>.generate(readUInt(), (i) => readNamedType()); |
| 821 } |
| 822 |
| 823 NamedType readNamedType() { |
| 824 return new NamedType(readStringReference(), readDartType()); |
| 825 } |
| 826 |
819 DartType readDartTypeOption() { | 827 DartType readDartTypeOption() { |
820 return readAndCheckOptionTag() ? readDartType() : null; | 828 return readAndCheckOptionTag() ? readDartType() : null; |
821 } | 829 } |
822 | 830 |
823 DartType readDartType() { | 831 DartType readDartType() { |
824 int tag = readByte(); | 832 int tag = readByte(); |
825 switch (tag) { | 833 switch (tag) { |
826 case Tag.BottomType: | 834 case Tag.BottomType: |
827 return const BottomType(); | 835 return const BottomType(); |
828 case Tag.InvalidType: | 836 case Tag.InvalidType: |
829 return const InvalidType(); | 837 return const InvalidType(); |
830 case Tag.DynamicType: | 838 case Tag.DynamicType: |
831 return const DynamicType(); | 839 return const DynamicType(); |
832 case Tag.VoidType: | 840 case Tag.VoidType: |
833 return const VoidType(); | 841 return const VoidType(); |
834 case Tag.InterfaceType: | 842 case Tag.InterfaceType: |
835 return new InterfaceType(readClassReference(), readDartTypeList()); | 843 return new InterfaceType(readClassReference(), readDartTypeList()); |
836 case Tag.SimpleInterfaceType: | 844 case Tag.SimpleInterfaceType: |
837 return new InterfaceType(readClassReference(), const <DartType>[]); | 845 return new InterfaceType(readClassReference(), const <DartType>[]); |
838 case Tag.FunctionType: | 846 case Tag.FunctionType: |
839 int typeParameterStackHeight = typeParameterStack.length; | 847 int typeParameterStackHeight = typeParameterStack.length; |
840 var typeParameters = readAndPushTypeParameterList(); | 848 var typeParameters = readAndPushTypeParameterList(); |
841 var requiredParameterCount = readUInt(); | 849 var requiredParameterCount = readUInt(); |
842 var positional = readDartTypeList(); | 850 var positional = readDartTypeList(); |
843 int namedParameterCount = readUInt(); | 851 var named = readNamedTypeList(); |
844 var named = <String, DartType>{}; | |
845 for (int i = 0; i < namedParameterCount; ++i) { | |
846 var name = readStringReference(); | |
847 var type = readDartType(); | |
848 named[name] = type; | |
849 } | |
850 var returnType = readDartType(); | 852 var returnType = readDartType(); |
851 typeParameterStack.length = typeParameterStackHeight; | 853 typeParameterStack.length = typeParameterStackHeight; |
852 return new FunctionType(positional, returnType, | 854 return new FunctionType(positional, returnType, |
853 typeParameters: typeParameters, | 855 typeParameters: typeParameters, |
854 requiredParameterCount: requiredParameterCount, | 856 requiredParameterCount: requiredParameterCount, |
855 namedParameters: named); | 857 namedParameters: named); |
856 case Tag.SimpleFunctionType: | 858 case Tag.SimpleFunctionType: |
857 var positional = readDartTypeList(); | 859 var positional = readDartTypeList(); |
858 var returnType = readDartType(); | 860 var returnType = readDartType(); |
859 return new FunctionType(positional, returnType); | 861 return new FunctionType(positional, returnType); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 isFinal: flags & 0x1 != 0, | 932 isFinal: flags & 0x1 != 0, |
931 isConst: flags & 0x2 != 0); | 933 isConst: flags & 0x2 != 0); |
932 } | 934 } |
933 | 935 |
934 int readOffset() { | 936 int readOffset() { |
935 // Offset is saved as unsigned, | 937 // Offset is saved as unsigned, |
936 // but actually ranges from -1 and up (thus the -1) | 938 // but actually ranges from -1 and up (thus the -1) |
937 return readUInt() - 1; | 939 return readUInt() - 1; |
938 } | 940 } |
939 } | 941 } |
OLD | NEW |