| 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 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 } | 1114 } |
| 1115 | 1115 |
| 1116 visitNamedType(NamedType node) { | 1116 visitNamedType(NamedType node) { |
| 1117 writeStringReference(node.name); | 1117 writeStringReference(node.name); |
| 1118 writeNode(node.type); | 1118 writeNode(node.type); |
| 1119 } | 1119 } |
| 1120 | 1120 |
| 1121 visitTypeParameterType(TypeParameterType node) { | 1121 visitTypeParameterType(TypeParameterType node) { |
| 1122 writeByte(Tag.TypeParameterType); | 1122 writeByte(Tag.TypeParameterType); |
| 1123 writeUInt30(_typeParameterIndexer[node.parameter]); | 1123 writeUInt30(_typeParameterIndexer[node.parameter]); |
| 1124 List<TypeParameter> typeParameters = | |
| 1125 _typeParameterIndexer.indexList[node.parameter]; | |
| 1126 writeUInt30(typeParameters[0].binaryOffset); | |
| 1127 writeUInt30(typeParameters.indexOf(node.parameter)); | |
| 1128 writeOptionalNode(node.promotedBound); | 1124 writeOptionalNode(node.promotedBound); |
| 1129 } | 1125 } |
| 1130 | 1126 |
| 1131 visitVectorType(VectorType node) { | 1127 visitVectorType(VectorType node) { |
| 1132 writeByte(Tag.VectorType); | 1128 writeByte(Tag.VectorType); |
| 1133 } | 1129 } |
| 1134 | 1130 |
| 1135 visitTypedefType(TypedefType node) { | 1131 visitTypedefType(TypedefType node) { |
| 1136 writeByte(Tag.TypedefType); | 1132 writeByte(Tag.TypedefType); |
| 1137 writeReference(node.typedefReference); | 1133 writeReference(node.typedefReference); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 | 1229 |
| 1234 void exit(SwitchStatement node) { | 1230 void exit(SwitchStatement node) { |
| 1235 stackHeight -= node.cases.length; | 1231 stackHeight -= node.cases.length; |
| 1236 } | 1232 } |
| 1237 | 1233 |
| 1238 int operator [](SwitchCase node) => index[node]; | 1234 int operator [](SwitchCase node) => index[node]; |
| 1239 } | 1235 } |
| 1240 | 1236 |
| 1241 class TypeParameterIndexer { | 1237 class TypeParameterIndexer { |
| 1242 final Map<TypeParameter, int> index = <TypeParameter, int>{}; | 1238 final Map<TypeParameter, int> index = <TypeParameter, int>{}; |
| 1243 final Map<TypeParameter, List<TypeParameter>> indexList = | |
| 1244 <TypeParameter, List<TypeParameter>>{}; | |
| 1245 int stackHeight = 0; | 1239 int stackHeight = 0; |
| 1246 | 1240 |
| 1247 void enter(List<TypeParameter> typeParameters) { | 1241 void enter(List<TypeParameter> typeParameters) { |
| 1248 for (var parameter in typeParameters) { | 1242 for (var parameter in typeParameters) { |
| 1249 index[parameter] = stackHeight; | 1243 index[parameter] = stackHeight; |
| 1250 indexList[parameter] = typeParameters; | |
| 1251 ++stackHeight; | 1244 ++stackHeight; |
| 1252 } | 1245 } |
| 1253 } | 1246 } |
| 1254 | 1247 |
| 1255 void exit(List<TypeParameter> typeParameters) { | 1248 void exit(List<TypeParameter> typeParameters) { |
| 1256 stackHeight -= typeParameters.length; | 1249 stackHeight -= typeParameters.length; |
| 1257 } | 1250 } |
| 1258 | 1251 |
| 1259 int operator [](TypeParameter parameter) => index[parameter]; | 1252 int operator [](TypeParameter parameter) => index[parameter]; |
| 1260 } | 1253 } |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1500 _sink.add(_buffer.sublist(0, length)); | 1493 _sink.add(_buffer.sublist(0, length)); |
| 1501 _buffer = new Uint8List(SIZE); | 1494 _buffer = new Uint8List(SIZE); |
| 1502 flushedLength += length; | 1495 flushedLength += length; |
| 1503 length = 0; | 1496 length = 0; |
| 1504 } | 1497 } |
| 1505 | 1498 |
| 1506 void flushAndDestroy() { | 1499 void flushAndDestroy() { |
| 1507 _sink.add(_buffer.sublist(0, length)); | 1500 _sink.add(_buffer.sublist(0, length)); |
| 1508 } | 1501 } |
| 1509 } | 1502 } |
| OLD | NEW |