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 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
901 return new ForInStatement(variable, iterable, body, isAsync: isAsync); | 901 return new ForInStatement(variable, iterable, body, isAsync: isAsync); |
902 case Tag.SwitchStatement: | 902 case Tag.SwitchStatement: |
903 var expression = readExpression(); | 903 var expression = readExpression(); |
904 int count = readUInt(); | 904 int count = readUInt(); |
905 List<SwitchCase> cases = | 905 List<SwitchCase> cases = |
906 new List<SwitchCase>.generate(count, (i) => new SwitchCase.empty()); | 906 new List<SwitchCase>.generate(count, (i) => new SwitchCase.empty()); |
907 switchCaseStack.addAll(cases); | 907 switchCaseStack.addAll(cases); |
908 for (int i = 0; i < cases.length; ++i) { | 908 for (int i = 0; i < cases.length; ++i) { |
909 var caseNode = cases[i]; | 909 var caseNode = cases[i]; |
910 _fillTreeNodeList(caseNode.expressions, readExpression, caseNode); | 910 _fillTreeNodeList(caseNode.expressions, readExpression, caseNode); |
911 caseNode.expressionsOffsets.length = readUInt(); | |
Kevin Millikin (Google)
2017/03/20 12:29:47
I'd just change _fillNonTreeNodeList so it didn't
jensj
2017/03/21 10:06:19
I've changed it to not encode the size as well so
| |
912 for (int i = 0; i < caseNode.expressionsOffsets.length; ++i) { | |
913 caseNode.expressionsOffsets[i] = readOffset(); | |
914 } | |
911 caseNode.isDefault = readByte() == 1; | 915 caseNode.isDefault = readByte() == 1; |
912 caseNode.body = readStatement()..parent = caseNode; | 916 caseNode.body = readStatement()..parent = caseNode; |
913 } | 917 } |
914 switchCaseStack.length -= count; | 918 switchCaseStack.length -= count; |
915 return new SwitchStatement(expression, cases); | 919 return new SwitchStatement(expression, cases); |
916 case Tag.ContinueSwitchStatement: | 920 case Tag.ContinueSwitchStatement: |
917 int index = readUInt(); | 921 int index = readUInt(); |
918 return new ContinueSwitchStatement(switchCaseStack[index]); | 922 return new ContinueSwitchStatement(switchCaseStack[index]); |
919 case Tag.IfStatement: | 923 case Tag.IfStatement: |
920 return new IfStatement( | 924 return new IfStatement( |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1108 ..fileOffset = offset | 1112 ..fileOffset = offset |
1109 ..fileEqualsOffset = fileEqualsOffset; | 1113 ..fileEqualsOffset = fileEqualsOffset; |
1110 } | 1114 } |
1111 | 1115 |
1112 int readOffset() { | 1116 int readOffset() { |
1113 // Offset is saved as unsigned, | 1117 // Offset is saved as unsigned, |
1114 // but actually ranges from -1 and up (thus the -1) | 1118 // but actually ranges from -1 and up (thus the -1) |
1115 return readUInt() - 1; | 1119 return readUInt() - 1; |
1116 } | 1120 } |
1117 } | 1121 } |
OLD | NEW |