| 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_to_binary; | 4 library kernel.ast_to_binary; |
| 5 | 5 |
| 6 import '../ast.dart'; | 6 import '../ast.dart'; |
| 7 import '../import_table.dart'; | 7 import '../import_table.dart'; |
| 8 import 'tag.dart'; | 8 import 'tag.dart'; |
| 9 import 'dart:convert'; | 9 import 'dart:convert'; |
| 10 import 'dart:typed_data'; | 10 import 'dart:typed_data'; |
| (...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 } | 1137 } |
| 1138 | 1138 |
| 1139 visitNamedType(NamedType node) { | 1139 visitNamedType(NamedType node) { |
| 1140 writeStringReference(node.name); | 1140 writeStringReference(node.name); |
| 1141 writeNode(node.type); | 1141 writeNode(node.type); |
| 1142 } | 1142 } |
| 1143 | 1143 |
| 1144 visitTypeParameterType(TypeParameterType node) { | 1144 visitTypeParameterType(TypeParameterType node) { |
| 1145 writeByte(Tag.TypeParameterType); | 1145 writeByte(Tag.TypeParameterType); |
| 1146 writeUInt30(_typeParameterIndexer[node.parameter]); | 1146 writeUInt30(_typeParameterIndexer[node.parameter]); |
| 1147 List<TypeParameter> typeParameters = | |
| 1148 _typeParameterIndexer.indexList[node.parameter]; | |
| 1149 writeUInt30(typeParameters[0].binaryOffset); | |
| 1150 writeUInt30(typeParameters.indexOf(node.parameter)); | |
| 1151 writeOptionalNode(node.promotedBound); | 1147 writeOptionalNode(node.promotedBound); |
| 1152 } | 1148 } |
| 1153 | 1149 |
| 1154 visitVectorType(VectorType node) { | 1150 visitVectorType(VectorType node) { |
| 1155 writeByte(Tag.VectorType); | 1151 writeByte(Tag.VectorType); |
| 1156 } | 1152 } |
| 1157 | 1153 |
| 1158 visitTypedefType(TypedefType node) { | 1154 visitTypedefType(TypedefType node) { |
| 1159 writeByte(Tag.TypedefType); | 1155 writeByte(Tag.TypedefType); |
| 1160 writeReference(node.typedefReference); | 1156 writeReference(node.typedefReference); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1256 | 1252 |
| 1257 void exit(SwitchStatement node) { | 1253 void exit(SwitchStatement node) { |
| 1258 stackHeight -= node.cases.length; | 1254 stackHeight -= node.cases.length; |
| 1259 } | 1255 } |
| 1260 | 1256 |
| 1261 int operator [](SwitchCase node) => index[node]; | 1257 int operator [](SwitchCase node) => index[node]; |
| 1262 } | 1258 } |
| 1263 | 1259 |
| 1264 class TypeParameterIndexer { | 1260 class TypeParameterIndexer { |
| 1265 final Map<TypeParameter, int> index = <TypeParameter, int>{}; | 1261 final Map<TypeParameter, int> index = <TypeParameter, int>{}; |
| 1266 final Map<TypeParameter, List<TypeParameter>> indexList = | |
| 1267 <TypeParameter, List<TypeParameter>>{}; | |
| 1268 int stackHeight = 0; | 1262 int stackHeight = 0; |
| 1269 | 1263 |
| 1270 void enter(List<TypeParameter> typeParameters) { | 1264 void enter(List<TypeParameter> typeParameters) { |
| 1271 for (var parameter in typeParameters) { | 1265 for (var parameter in typeParameters) { |
| 1272 index[parameter] = stackHeight; | 1266 index[parameter] = stackHeight; |
| 1273 indexList[parameter] = typeParameters; | |
| 1274 ++stackHeight; | 1267 ++stackHeight; |
| 1275 } | 1268 } |
| 1276 } | 1269 } |
| 1277 | 1270 |
| 1278 void exit(List<TypeParameter> typeParameters) { | 1271 void exit(List<TypeParameter> typeParameters) { |
| 1279 stackHeight -= typeParameters.length; | 1272 stackHeight -= typeParameters.length; |
| 1280 } | 1273 } |
| 1281 | 1274 |
| 1282 int operator [](TypeParameter parameter) => index[parameter]; | 1275 int operator [](TypeParameter parameter) => index[parameter]; |
| 1283 } | 1276 } |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1548 _sink.add(_buffer.sublist(0, length)); | 1541 _sink.add(_buffer.sublist(0, length)); |
| 1549 _buffer = new Uint8List(SIZE); | 1542 _buffer = new Uint8List(SIZE); |
| 1550 flushedLength += length; | 1543 flushedLength += length; |
| 1551 length = 0; | 1544 length = 0; |
| 1552 } | 1545 } |
| 1553 | 1546 |
| 1554 void flushAndDestroy() { | 1547 void flushAndDestroy() { |
| 1555 _sink.add(_buffer.sublist(0, length)); | 1548 _sink.add(_buffer.sublist(0, length)); |
| 1556 } | 1549 } |
| 1557 } | 1550 } |
| OLD | NEW |