| 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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 | 276 |
| 277 void writeAnnotation(Expression annotation) { | 277 void writeAnnotation(Expression annotation) { |
| 278 _variableIndexer ??= new VariableIndexer(); | 278 _variableIndexer ??= new VariableIndexer(); |
| 279 writeNode(annotation); | 279 writeNode(annotation); |
| 280 } | 280 } |
| 281 | 281 |
| 282 void writeAnnotationList(List<Expression> annotations) { | 282 void writeAnnotationList(List<Expression> annotations) { |
| 283 writeList(annotations, writeAnnotation); | 283 writeList(annotations, writeAnnotation); |
| 284 } | 284 } |
| 285 | 285 |
| 286 int _encodeClassFlags(bool isAbstract, ClassLevel level) { |
| 287 int abstactFlag = isAbstract ? 1 : 0; |
| 288 int levelFlags = (level.index - 1) << 1; |
| 289 return abstactFlag | levelFlags; |
| 290 } |
| 291 |
| 286 visitClass(Class node) { | 292 visitClass(Class node) { |
| 287 int flags = node.isAbstract ? 1 : 0; | 293 int flags = _encodeClassFlags(node.isAbstract, node.level); |
| 288 if (node.level == ClassLevel.Type) { | |
| 289 flags |= 0x2; | |
| 290 } | |
| 291 if (node.isMixinApplication) { | 294 if (node.isMixinApplication) { |
| 292 writeByte(Tag.MixinClass); | 295 writeByte(Tag.MixinClass); |
| 293 writeOffset(node, node.fileOffset); | 296 writeOffset(node, node.fileOffset); |
| 294 writeByte(flags); | 297 writeByte(flags); |
| 295 writeStringReference(node.name ?? ''); | 298 writeStringReference(node.name ?? ''); |
| 296 writeUriReference(node.fileUri ?? ''); | 299 writeUriReference(node.fileUri ?? ''); |
| 297 writeAnnotationList(node.annotations); | 300 writeAnnotationList(node.annotations); |
| 298 _typeParameterIndexer.enter(node.typeParameters); | 301 _typeParameterIndexer.enter(node.typeParameters); |
| 299 writeNodeList(node.typeParameters); | 302 writeNodeList(node.typeParameters); |
| 300 writeNode(node.supertype); | 303 writeNode(node.supertype); |
| (...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1241 void flush() { | 1244 void flush() { |
| 1242 _sink.add(_buffer.sublist(0, length)); | 1245 _sink.add(_buffer.sublist(0, length)); |
| 1243 _buffer = new Uint8List(SIZE); | 1246 _buffer = new Uint8List(SIZE); |
| 1244 length = 0; | 1247 length = 0; |
| 1245 } | 1248 } |
| 1246 | 1249 |
| 1247 void flushAndDestroy() { | 1250 void flushAndDestroy() { |
| 1248 _sink.add(_buffer.sublist(0, length)); | 1251 _sink.add(_buffer.sublist(0, length)); |
| 1249 } | 1252 } |
| 1250 } | 1253 } |
| OLD | NEW |