| 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 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 labelStack.add(label); | 1010 labelStack.add(label); |
| 1011 label.body = readStatement()..parent = label; | 1011 label.body = readStatement()..parent = label; |
| 1012 labelStack.removeLast(); | 1012 labelStack.removeLast(); |
| 1013 return label; | 1013 return label; |
| 1014 case Tag.BreakStatement: | 1014 case Tag.BreakStatement: |
| 1015 int offset = readOffset(); | 1015 int offset = readOffset(); |
| 1016 int index = readUInt(); | 1016 int index = readUInt(); |
| 1017 return new BreakStatement(labelStack[labelStackBase + index]) | 1017 return new BreakStatement(labelStack[labelStackBase + index]) |
| 1018 ..fileOffset = offset; | 1018 ..fileOffset = offset; |
| 1019 case Tag.WhileStatement: | 1019 case Tag.WhileStatement: |
| 1020 return new WhileStatement(readExpression(), readStatement()); | 1020 var offset = readOffset(); |
| 1021 return new WhileStatement(readExpression(), readStatement()) |
| 1022 ..fileOffset = offset; |
| 1021 case Tag.DoStatement: | 1023 case Tag.DoStatement: |
| 1022 return new DoStatement(readStatement(), readExpression()); | 1024 var offset = readOffset(); |
| 1025 return new DoStatement(readStatement(), readExpression()) |
| 1026 ..fileOffset = offset; |
| 1023 case Tag.ForStatement: | 1027 case Tag.ForStatement: |
| 1024 int variableStackHeight = variableStack.length; | 1028 int variableStackHeight = variableStack.length; |
| 1029 var offset = readOffset(); |
| 1025 var variables = readAndPushVariableDeclarationList(); | 1030 var variables = readAndPushVariableDeclarationList(); |
| 1026 var condition = readExpressionOption(); | 1031 var condition = readExpressionOption(); |
| 1027 var updates = readExpressionList(); | 1032 var updates = readExpressionList(); |
| 1028 var body = readStatement(); | 1033 var body = readStatement(); |
| 1029 variableStack.length = variableStackHeight; | 1034 variableStack.length = variableStackHeight; |
| 1030 return new ForStatement(variables, condition, updates, body); | 1035 return new ForStatement(variables, condition, updates, body) |
| 1036 ..fileOffset = offset; |
| 1031 case Tag.ForInStatement: | 1037 case Tag.ForInStatement: |
| 1032 case Tag.AsyncForInStatement: | 1038 case Tag.AsyncForInStatement: |
| 1033 bool isAsync = tag == Tag.AsyncForInStatement; | 1039 bool isAsync = tag == Tag.AsyncForInStatement; |
| 1034 int variableStackHeight = variableStack.length; | 1040 int variableStackHeight = variableStack.length; |
| 1035 var offset = readOffset(); | 1041 var offset = readOffset(); |
| 1042 var bodyOffset = readOffset(); |
| 1036 var variable = readAndPushVariableDeclaration(); | 1043 var variable = readAndPushVariableDeclaration(); |
| 1037 var iterable = readExpression(); | 1044 var iterable = readExpression(); |
| 1038 var body = readStatement(); | 1045 var body = readStatement(); |
| 1039 variableStack.length = variableStackHeight; | 1046 variableStack.length = variableStackHeight; |
| 1040 return new ForInStatement(variable, iterable, body, isAsync: isAsync) | 1047 return new ForInStatement(variable, iterable, body, isAsync: isAsync) |
| 1041 ..fileOffset = offset; | 1048 ..fileOffset = offset |
| 1049 ..bodyOffset = bodyOffset; |
| 1042 case Tag.SwitchStatement: | 1050 case Tag.SwitchStatement: |
| 1043 var expression = readExpression(); | 1051 var expression = readExpression(); |
| 1044 int count = readUInt(); | 1052 int count = readUInt(); |
| 1045 List<SwitchCase> cases = | 1053 List<SwitchCase> cases = |
| 1046 new List<SwitchCase>.generate(count, (i) => new SwitchCase.empty()); | 1054 new List<SwitchCase>.generate(count, (i) => new SwitchCase.empty()); |
| 1047 switchCaseStack.addAll(cases); | 1055 switchCaseStack.addAll(cases); |
| 1048 for (int i = 0; i < cases.length; ++i) { | 1056 for (int i = 0; i < cases.length; ++i) { |
| 1049 var caseNode = cases[i]; | 1057 var caseNode = cases[i]; |
| 1050 int length = readUInt(); | 1058 int length = readUInt(); |
| 1051 caseNode.expressions.length = length; | 1059 caseNode.expressions.length = length; |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 ..fileOffset = offset | 1281 ..fileOffset = offset |
| 1274 ..fileEqualsOffset = fileEqualsOffset; | 1282 ..fileEqualsOffset = fileEqualsOffset; |
| 1275 } | 1283 } |
| 1276 | 1284 |
| 1277 int readOffset() { | 1285 int readOffset() { |
| 1278 // Offset is saved as unsigned, | 1286 // Offset is saved as unsigned, |
| 1279 // but actually ranges from -1 and up (thus the -1) | 1287 // but actually ranges from -1 and up (thus the -1) |
| 1280 return readUInt() - 1; | 1288 return readUInt() - 1; |
| 1281 } | 1289 } |
| 1282 } | 1290 } |
| OLD | NEW |