| 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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 } | 470 } |
| 471 | 471 |
| 472 FunctionNode readFunctionNodeOption() { | 472 FunctionNode readFunctionNodeOption() { |
| 473 return readAndCheckOptionTag() ? readFunctionNode() : null; | 473 return readAndCheckOptionTag() ? readFunctionNode() : null; |
| 474 } | 474 } |
| 475 | 475 |
| 476 FunctionNode readFunctionNode() { | 476 FunctionNode readFunctionNode() { |
| 477 int offset = readOffset(); | 477 int offset = readOffset(); |
| 478 int endOffset = readOffset(); | 478 int endOffset = readOffset(); |
| 479 AsyncMarker asyncMarker = AsyncMarker.values[readByte()]; | 479 AsyncMarker asyncMarker = AsyncMarker.values[readByte()]; |
| 480 bool debuggable = readByte() == 1 ? true : false; | 480 AsyncMarker originalAsyncMarker = AsyncMarker.values[readByte()]; |
| 481 int typeParameterStackHeight = typeParameterStack.length; | 481 int typeParameterStackHeight = typeParameterStack.length; |
| 482 var typeParameters = readAndPushTypeParameterList(); | 482 var typeParameters = readAndPushTypeParameterList(); |
| 483 var requiredParameterCount = readUInt(); | 483 var requiredParameterCount = readUInt(); |
| 484 int variableStackHeight = variableStack.length; | 484 int variableStackHeight = variableStack.length; |
| 485 var positional = readAndPushVariableDeclarationList(); | 485 var positional = readAndPushVariableDeclarationList(); |
| 486 var named = readAndPushVariableDeclarationList(); | 486 var named = readAndPushVariableDeclarationList(); |
| 487 var returnType = readDartType(); | 487 var returnType = readDartType(); |
| 488 var inferredReturnValue = readOptionalInferredValue(); | 488 var inferredReturnValue = readOptionalInferredValue(); |
| 489 int oldLabelStackBase = labelStackBase; | 489 int oldLabelStackBase = labelStackBase; |
| 490 labelStackBase = labelStack.length; | 490 labelStackBase = labelStack.length; |
| 491 var body = readStatementOption(); | 491 var body = readStatementOption(); |
| 492 labelStackBase = oldLabelStackBase; | 492 labelStackBase = oldLabelStackBase; |
| 493 variableStack.length = variableStackHeight; | 493 variableStack.length = variableStackHeight; |
| 494 typeParameterStack.length = typeParameterStackHeight; | 494 typeParameterStack.length = typeParameterStackHeight; |
| 495 return new FunctionNode(body, | 495 return new FunctionNode(body, |
| 496 typeParameters: typeParameters, | 496 typeParameters: typeParameters, |
| 497 requiredParameterCount: requiredParameterCount, | 497 requiredParameterCount: requiredParameterCount, |
| 498 positionalParameters: positional, | 498 positionalParameters: positional, |
| 499 namedParameters: named, | 499 namedParameters: named, |
| 500 returnType: returnType, | 500 returnType: returnType, |
| 501 inferredReturnValue: inferredReturnValue, | 501 inferredReturnValue: inferredReturnValue, |
| 502 asyncMarker: asyncMarker) | 502 asyncMarker: asyncMarker, |
| 503 originalAsyncMarker: originalAsyncMarker) |
| 503 ..fileOffset = offset | 504 ..fileOffset = offset |
| 504 ..fileEndOffset = endOffset | 505 ..fileEndOffset = endOffset; |
| 505 ..debuggable = debuggable; | |
| 506 } | 506 } |
| 507 | 507 |
| 508 void pushVariableDeclaration(VariableDeclaration variable) { | 508 void pushVariableDeclaration(VariableDeclaration variable) { |
| 509 variableStack.add(variable); | 509 variableStack.add(variable); |
| 510 } | 510 } |
| 511 | 511 |
| 512 void pushVariableDeclarations(List<VariableDeclaration> variables) { | 512 void pushVariableDeclarations(List<VariableDeclaration> variables) { |
| 513 variableStack.addAll(variables); | 513 variableStack.addAll(variables); |
| 514 } | 514 } |
| 515 | 515 |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 isFinal: flags & 0x1 != 0, | 988 isFinal: flags & 0x1 != 0, |
| 989 isConst: flags & 0x2 != 0)..fileOffset = offset; | 989 isConst: flags & 0x2 != 0)..fileOffset = offset; |
| 990 } | 990 } |
| 991 | 991 |
| 992 int readOffset() { | 992 int readOffset() { |
| 993 // Offset is saved as unsigned, | 993 // Offset is saved as unsigned, |
| 994 // but actually ranges from -1 and up (thus the -1) | 994 // but actually ranges from -1 and up (thus the -1) |
| 995 return readUInt() - 1; | 995 return readUInt() - 1; |
| 996 } | 996 } |
| 997 } | 997 } |
| OLD | NEW |