| 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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   408     _variableIndexer = new VariableIndexer(); |   408     _variableIndexer = new VariableIndexer(); | 
|   409     writeByte(Tag.Constructor); |   409     writeByte(Tag.Constructor); | 
|   410     writeCanonicalNameReference(getCanonicalNameOfMember(node)); |   410     writeCanonicalNameReference(getCanonicalNameOfMember(node)); | 
|   411     writeOffset(node.fileOffset); |   411     writeOffset(node.fileOffset); | 
|   412     writeOffset(node.fileEndOffset); |   412     writeOffset(node.fileEndOffset); | 
|   413     writeByte(node.flags); |   413     writeByte(node.flags); | 
|   414     assert(node.parent is Class); |   414     assert(node.parent is Class); | 
|   415     Class parent = node.parent; |   415     Class parent = node.parent; | 
|   416     writeUInt30(parent.binaryOffset); |   416     writeUInt30(parent.binaryOffset); | 
|   417     writeName(node.name ?? _emptyName); |   417     writeName(node.name ?? _emptyName); | 
 |   418     writeStringReference(node.documentationComment ?? ''); | 
|   418     writeAnnotationList(node.annotations); |   419     writeAnnotationList(node.annotations); | 
|   419     assert(node.function.typeParameters.isEmpty); |   420     assert(node.function.typeParameters.isEmpty); | 
|   420     writeNode(node.function); |   421     writeNode(node.function); | 
|   421     // Parameters are in scope in the initializers. |   422     // Parameters are in scope in the initializers. | 
|   422     _variableIndexer.restoreScope(node.function.positionalParameters.length + |   423     _variableIndexer.restoreScope(node.function.positionalParameters.length + | 
|   423         node.function.namedParameters.length); |   424         node.function.namedParameters.length); | 
|   424     writeNodeList(node.initializers); |   425     writeNodeList(node.initializers); | 
|   425     _variableIndexer = null; |   426     _variableIndexer = null; | 
|   426   } |   427   } | 
|   427  |   428  | 
|   428   visitProcedure(Procedure node) { |   429   visitProcedure(Procedure node) { | 
|   429     if (node.canonicalName == null) { |   430     if (node.canonicalName == null) { | 
|   430       throw 'Missing canonical name for $node'; |   431       throw 'Missing canonical name for $node'; | 
|   431     } |   432     } | 
|   432     _variableIndexer = new VariableIndexer(); |   433     _variableIndexer = new VariableIndexer(); | 
|   433     writeByte(Tag.Procedure); |   434     writeByte(Tag.Procedure); | 
|   434     writeCanonicalNameReference(getCanonicalNameOfMember(node)); |   435     writeCanonicalNameReference(getCanonicalNameOfMember(node)); | 
|   435     writeOffset(node.fileOffset); |   436     writeOffset(node.fileOffset); | 
|   436     writeOffset(node.fileEndOffset); |   437     writeOffset(node.fileEndOffset); | 
|   437     writeByte(node.kind.index); |   438     writeByte(node.kind.index); | 
|   438     writeByte(node.flags); |   439     writeByte(node.flags); | 
|   439     if (node.parent is Class) { |   440     if (node.parent is Class) { | 
|   440       Class parent = node.parent; |   441       Class parent = node.parent; | 
|   441       writeUInt30(parent.binaryOffset); |   442       writeUInt30(parent.binaryOffset); | 
|   442     } else { |   443     } else { | 
|   443       writeUInt30(0); // 0 is a valid offset, but not for a class. |   444       writeUInt30(0); // 0 is a valid offset, but not for a class. | 
|   444     } |   445     } | 
|   445     writeName(node.name ?? ''); |   446     writeName(node.name ?? ''); | 
|   446     writeUriReference(node.fileUri ?? ''); |   447     writeUriReference(node.fileUri ?? ''); | 
 |   448     writeStringReference(node.documentationComment ?? ''); | 
|   447     writeAnnotationList(node.annotations); |   449     writeAnnotationList(node.annotations); | 
|   448     writeOptionalNode(node.function); |   450     writeOptionalNode(node.function); | 
|   449     _variableIndexer = null; |   451     _variableIndexer = null; | 
|   450   } |   452   } | 
|   451  |   453  | 
|   452   visitField(Field node) { |   454   visitField(Field node) { | 
|   453     if (node.canonicalName == null) { |   455     if (node.canonicalName == null) { | 
|   454       throw 'Missing canonical name for $node'; |   456       throw 'Missing canonical name for $node'; | 
|   455     } |   457     } | 
|   456     _variableIndexer = new VariableIndexer(); |   458     _variableIndexer = new VariableIndexer(); | 
|   457     writeByte(Tag.Field); |   459     writeByte(Tag.Field); | 
|   458     writeCanonicalNameReference(getCanonicalNameOfMember(node)); |   460     writeCanonicalNameReference(getCanonicalNameOfMember(node)); | 
|   459     writeOffset(node.fileOffset); |   461     writeOffset(node.fileOffset); | 
|   460     writeOffset(node.fileEndOffset); |   462     writeOffset(node.fileEndOffset); | 
|   461     writeByte(node.flags); |   463     writeByte(node.flags); | 
|   462     if (node.parent is Class) { |   464     if (node.parent is Class) { | 
|   463       Class parent = node.parent; |   465       Class parent = node.parent; | 
|   464       writeUInt30(parent.binaryOffset); |   466       writeUInt30(parent.binaryOffset); | 
|   465     } else { |   467     } else { | 
|   466       writeUInt30(0); // 0 is a valid offset, but not for a class. |   468       writeUInt30(0); // 0 is a valid offset, but not for a class. | 
|   467     } |   469     } | 
|   468     writeName(node.name); |   470     writeName(node.name); | 
|   469     writeUriReference(node.fileUri ?? ''); |   471     writeUriReference(node.fileUri ?? ''); | 
 |   472     writeStringReference(node.documentationComment ?? ''); | 
|   470     writeAnnotationList(node.annotations); |   473     writeAnnotationList(node.annotations); | 
|   471     writeNode(node.type); |   474     writeNode(node.type); | 
|   472     writeOptionalNode(node.initializer); |   475     writeOptionalNode(node.initializer); | 
|   473     _variableIndexer = null; |   476     _variableIndexer = null; | 
|   474   } |   477   } | 
|   475  |   478  | 
|   476   visitInvalidInitializer(InvalidInitializer node) { |   479   visitInvalidInitializer(InvalidInitializer node) { | 
|   477     writeByte(Tag.InvalidInitializer); |   480     writeByte(Tag.InvalidInitializer); | 
|   478     writeByte(node.isSynthetic ? 1 : 0); |   481     writeByte(node.isSynthetic ? 1 : 0); | 
|   479   } |   482   } | 
| (...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1363     put(node.name); |  1366     put(node.name); | 
|  1364     node.visitChildren(this); |  1367     node.visitChildren(this); | 
|  1365   } |  1368   } | 
|  1366  |  1369  | 
|  1367   visitClass(Class node) { |  1370   visitClass(Class node) { | 
|  1368     putOptional(node.documentationComment); |  1371     putOptional(node.documentationComment); | 
|  1369     putOptional(node.name); |  1372     putOptional(node.name); | 
|  1370     node.visitChildren(this); |  1373     node.visitChildren(this); | 
|  1371   } |  1374   } | 
|  1372  |  1375  | 
 |  1376   @override | 
 |  1377   visitConstructor(Constructor node) { | 
 |  1378     putOptional(node.documentationComment); | 
 |  1379     super.visitConstructor(node); | 
 |  1380   } | 
 |  1381  | 
 |  1382   @override | 
 |  1383   visitField(Field node) { | 
 |  1384     putOptional(node.documentationComment); | 
 |  1385     super.visitField(node); | 
 |  1386   } | 
 |  1387  | 
|  1373   visitNamedExpression(NamedExpression node) { |  1388   visitNamedExpression(NamedExpression node) { | 
|  1374     put(node.name); |  1389     put(node.name); | 
|  1375     node.visitChildren(this); |  1390     node.visitChildren(this); | 
|  1376   } |  1391   } | 
|  1377  |  1392  | 
 |  1393   @override | 
 |  1394   visitProcedure(Procedure node) { | 
 |  1395     putOptional(node.documentationComment); | 
 |  1396     super.visitProcedure(node); | 
 |  1397   } | 
 |  1398  | 
|  1378   visitStringLiteral(StringLiteral node) { |  1399   visitStringLiteral(StringLiteral node) { | 
|  1379     put(node.value); |  1400     put(node.value); | 
|  1380   } |  1401   } | 
|  1381  |  1402  | 
|  1382   visitIntLiteral(IntLiteral node) { |  1403   visitIntLiteral(IntLiteral node) { | 
|  1383     if (node.value.abs() >> 30 != 0) { |  1404     if (node.value.abs() >> 30 != 0) { | 
|  1384       put('${node.value}'); |  1405       put('${node.value}'); | 
|  1385     } |  1406     } | 
|  1386   } |  1407   } | 
|  1387  |  1408  | 
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1515     _sink.add(_buffer.sublist(0, length)); |  1536     _sink.add(_buffer.sublist(0, length)); | 
|  1516     _buffer = new Uint8List(SIZE); |  1537     _buffer = new Uint8List(SIZE); | 
|  1517     flushedLength += length; |  1538     flushedLength += length; | 
|  1518     length = 0; |  1539     length = 0; | 
|  1519   } |  1540   } | 
|  1520  |  1541  | 
|  1521   void flushAndDestroy() { |  1542   void flushAndDestroy() { | 
|  1522     _sink.add(_buffer.sublist(0, length)); |  1543     _sink.add(_buffer.sublist(0, length)); | 
|  1523   } |  1544   } | 
|  1524 } |  1545 } | 
| OLD | NEW |