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(bool isAbstract, ClassLevel level) { | 366 int _encodeClassFlags( |
367 int abstactFlag = isAbstract ? 1 : 0; | 367 bool isAbstract, bool isSyntheticMixinImplementation, ClassLevel level) { |
368 int levelFlags = (level.index - 1) << 1; | 368 int abstractFlag = isAbstract ? 1 : 0; |
369 return abstactFlag | levelFlags; | 369 int isSyntheticMixinImplementationFlag = |
| 370 isSyntheticMixinImplementation ? 2 : 0; |
| 371 int levelFlags = (level.index - 1) << 2; |
| 372 return abstractFlag | isSyntheticMixinImplementationFlag | levelFlags; |
370 } | 373 } |
371 | 374 |
372 visitClass(Class node) { | 375 visitClass(Class node) { |
373 int flags = _encodeClassFlags(node.isAbstract, node.level); | 376 int flags = _encodeClassFlags( |
| 377 node.isAbstract, node.isSyntheticMixinImplementation, node.level); |
374 if (node.canonicalName == null) { | 378 if (node.canonicalName == null) { |
375 throw 'Missing canonical name for $node'; | 379 throw 'Missing canonical name for $node'; |
376 } | 380 } |
377 node.binaryOffset = _sink.flushedLength + _sink.length; | 381 node.binaryOffset = _sink.flushedLength + _sink.length; |
378 writeByte(Tag.Class); | 382 writeByte(Tag.Class); |
379 writeCanonicalNameReference(getCanonicalNameOfClass(node)); | 383 writeCanonicalNameReference(getCanonicalNameOfClass(node)); |
380 writeOffset(node.fileOffset); | 384 writeOffset(node.fileOffset); |
381 writeOffset(node.fileEndOffset); | 385 writeOffset(node.fileEndOffset); |
382 writeByte(flags); | 386 writeByte(flags); |
383 writeStringReference(node.name ?? ''); | 387 writeStringReference(node.name ?? ''); |
(...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1505 _sink.add(_buffer.sublist(0, length)); | 1509 _sink.add(_buffer.sublist(0, length)); |
1506 _buffer = new Uint8List(SIZE); | 1510 _buffer = new Uint8List(SIZE); |
1507 flushedLength += length; | 1511 flushedLength += length; |
1508 length = 0; | 1512 length = 0; |
1509 } | 1513 } |
1510 | 1514 |
1511 void flushAndDestroy() { | 1515 void flushAndDestroy() { |
1512 _sink.add(_buffer.sublist(0, length)); | 1516 _sink.add(_buffer.sublist(0, length)); |
1513 } | 1517 } |
1514 } | 1518 } |
OLD | NEW |