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 'dart:convert'; | 6 import 'dart:convert'; |
7 import 'dart:typed_data'; | 7 import 'dart:typed_data'; |
8 | 8 |
9 import '../ast.dart'; | 9 import '../ast.dart'; |
10 import '../transformations/flags.dart'; | 10 import '../transformations/flags.dart'; |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 | 336 |
337 Reference readMemberReference({bool allowNull: false}) { | 337 Reference readMemberReference({bool allowNull: false}) { |
338 var name = readCanonicalNameReference(); | 338 var name = readCanonicalNameReference(); |
339 if (name == null && !allowNull) { | 339 if (name == null && !allowNull) { |
340 throw 'Expected a member reference to be valid but was `null`.'; | 340 throw 'Expected a member reference to be valid but was `null`.'; |
341 } | 341 } |
342 return name?.getReference(); | 342 return name?.getReference(); |
343 } | 343 } |
344 | 344 |
345 Reference readTypedefReference() { | 345 Reference readTypedefReference() { |
346 return readCanonicalNameReference().getReference(); | 346 return readCanonicalNameReference()?.getReference(); |
347 } | 347 } |
348 | 348 |
349 Name readName() { | 349 Name readName() { |
350 String text = readStringReference(); | 350 String text = readStringReference(); |
351 if (text.isNotEmpty && text[0] == '_') { | 351 if (text.isNotEmpty && text[0] == '_') { |
352 return new Name.byReference(text, readLibraryReference()); | 352 return new Name.byReference(text, readLibraryReference()); |
353 } else { | 353 } else { |
354 return new Name(text); | 354 return new Name(text); |
355 } | 355 } |
356 } | 356 } |
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 return new InterfaceType.byReference( | 1169 return new InterfaceType.byReference( |
1170 readClassReference(), const <DartType>[]); | 1170 readClassReference(), const <DartType>[]); |
1171 case Tag.FunctionType: | 1171 case Tag.FunctionType: |
1172 int typeParameterStackHeight = typeParameterStack.length; | 1172 int typeParameterStackHeight = typeParameterStack.length; |
1173 var typeParameters = readAndPushTypeParameterList(); | 1173 var typeParameters = readAndPushTypeParameterList(); |
1174 var requiredParameterCount = readUInt(); | 1174 var requiredParameterCount = readUInt(); |
1175 var totalParameterCount = readUInt(); | 1175 var totalParameterCount = readUInt(); |
1176 var positional = readDartTypeList(); | 1176 var positional = readDartTypeList(); |
1177 var named = readNamedTypeList(); | 1177 var named = readNamedTypeList(); |
1178 var positionalNames = readStringReferenceList(); | 1178 var positionalNames = readStringReferenceList(); |
| 1179 var typedefReference = readTypedefReference(); |
1179 assert(positional.length + named.length == totalParameterCount); | 1180 assert(positional.length + named.length == totalParameterCount); |
1180 var returnType = readDartType(); | 1181 var returnType = readDartType(); |
1181 typeParameterStack.length = typeParameterStackHeight; | 1182 typeParameterStack.length = typeParameterStackHeight; |
1182 return new FunctionType(positional, returnType, | 1183 return new FunctionType(positional, returnType, |
1183 typeParameters: typeParameters, | 1184 typeParameters: typeParameters, |
1184 requiredParameterCount: requiredParameterCount, | 1185 requiredParameterCount: requiredParameterCount, |
1185 namedParameters: named, | 1186 namedParameters: named, |
1186 positionalParameterNames: positionalNames); | 1187 positionalParameterNames: positionalNames, |
| 1188 typedefReference: typedefReference); |
1187 case Tag.SimpleFunctionType: | 1189 case Tag.SimpleFunctionType: |
1188 var positional = readDartTypeList(); | 1190 var positional = readDartTypeList(); |
1189 var positionalNames = readStringReferenceList(); | 1191 var positionalNames = readStringReferenceList(); |
1190 var returnType = readDartType(); | 1192 var returnType = readDartType(); |
1191 return new FunctionType(positional, returnType, | 1193 return new FunctionType(positional, returnType, |
1192 positionalParameterNames: positionalNames); | 1194 positionalParameterNames: positionalNames); |
1193 case Tag.TypeParameterType: | 1195 case Tag.TypeParameterType: |
1194 int index = readUInt(); | 1196 int index = readUInt(); |
1195 readUInt(); // offset of parameter list in the binary. | 1197 readUInt(); // offset of parameter list in the binary. |
1196 readUInt(); // index in the list. | 1198 readUInt(); // index in the list. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 ..fileOffset = offset | 1273 ..fileOffset = offset |
1272 ..fileEqualsOffset = fileEqualsOffset; | 1274 ..fileEqualsOffset = fileEqualsOffset; |
1273 } | 1275 } |
1274 | 1276 |
1275 int readOffset() { | 1277 int readOffset() { |
1276 // Offset is saved as unsigned, | 1278 // Offset is saved as unsigned, |
1277 // but actually ranges from -1 and up (thus the -1) | 1279 // but actually ranges from -1 and up (thus the -1) |
1278 return readUInt() - 1; | 1280 return readUInt() - 1; |
1279 } | 1281 } |
1280 } | 1282 } |
OLD | NEW |