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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 | 356 |
357 void writeAnnotation(Expression annotation) { | 357 void writeAnnotation(Expression annotation) { |
358 _variableIndexer ??= new VariableIndexer(); | 358 _variableIndexer ??= new VariableIndexer(); |
359 writeNode(annotation); | 359 writeNode(annotation); |
360 } | 360 } |
361 | 361 |
362 void writeAnnotationList(List<Expression> annotations) { | 362 void writeAnnotationList(List<Expression> annotations) { |
363 writeList(annotations, writeAnnotation); | 363 writeList(annotations, writeAnnotation); |
364 } | 364 } |
365 | 365 |
366 int _encodeClassFlags( | 366 int _encodeClassFlags(bool isAbstract, bool isEnum, |
367 bool isAbstract, bool isSyntheticMixinImplementation, ClassLevel level) { | 367 bool isSyntheticMixinImplementation, ClassLevel level) { |
368 int abstractFlag = isAbstract ? 1 : 0; | 368 int abstractFlag = isAbstract ? 1 : 0; |
| 369 int isEnumFlag = isSyntheticMixinImplementation ? 2 : 0; |
369 int isSyntheticMixinImplementationFlag = | 370 int isSyntheticMixinImplementationFlag = |
370 isSyntheticMixinImplementation ? 2 : 0; | 371 isSyntheticMixinImplementation ? 4 : 0; |
371 int levelFlags = (level.index - 1) << 2; | 372 int levelFlags = (level.index - 1) << 3; |
372 return abstractFlag | isSyntheticMixinImplementationFlag | levelFlags; | 373 return abstractFlag | |
| 374 isEnumFlag | |
| 375 isSyntheticMixinImplementationFlag | |
| 376 levelFlags; |
373 } | 377 } |
374 | 378 |
375 visitClass(Class node) { | 379 visitClass(Class node) { |
376 int flags = _encodeClassFlags( | 380 int flags = _encodeClassFlags(node.isAbstract, node.isEnum, |
377 node.isAbstract, node.isSyntheticMixinImplementation, node.level); | 381 node.isSyntheticMixinImplementation, node.level); |
378 if (node.canonicalName == null) { | 382 if (node.canonicalName == null) { |
379 throw 'Missing canonical name for $node'; | 383 throw 'Missing canonical name for $node'; |
380 } | 384 } |
381 node.binaryOffset = _sink.flushedLength + _sink.length; | 385 node.binaryOffset = _sink.flushedLength + _sink.length; |
382 writeByte(Tag.Class); | 386 writeByte(Tag.Class); |
383 writeCanonicalNameReference(getCanonicalNameOfClass(node)); | 387 writeCanonicalNameReference(getCanonicalNameOfClass(node)); |
384 writeOffset(node.fileOffset); | 388 writeOffset(node.fileOffset); |
385 writeOffset(node.fileEndOffset); | 389 writeOffset(node.fileEndOffset); |
386 writeByte(flags); | 390 writeByte(flags); |
387 writeStringReference(node.name ?? ''); | 391 writeStringReference(node.name ?? ''); |
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1536 _sink.add(_buffer.sublist(0, length)); | 1540 _sink.add(_buffer.sublist(0, length)); |
1537 _buffer = new Uint8List(SIZE); | 1541 _buffer = new Uint8List(SIZE); |
1538 flushedLength += length; | 1542 flushedLength += length; |
1539 length = 0; | 1543 length = 0; |
1540 } | 1544 } |
1541 | 1545 |
1542 void flushAndDestroy() { | 1546 void flushAndDestroy() { |
1543 _sink.add(_buffer.sublist(0, length)); | 1547 _sink.add(_buffer.sublist(0, length)); |
1544 } | 1548 } |
1545 } | 1549 } |
OLD | NEW |