visitSource method
Implementation
@override
Uint8List visitSource(ASTSource unit) {
final bytesBuilder = BytesBuilder();
bytesBuilder.addByte(OpCode.file);
// if the relativeName is null then it is the entry file of this module.
bytesBuilder.add(_identifier(unit.fullName));
bytesBuilder.addByte(unit.resourceType.index);
// final convertedNodes = _convertPossibleAwaitedBlockToCallBack(unit.nodes);
// for (final node in convertedNodes) {
// Hoist import & export declarations to the start of the file,
// so that the file namespace's imports are resolved before any
// other statement executes, regardless of their positions in source.
for (final node in unit.nodes) {
if (node is ImportExportDecl) {
final bytes = compileAST(node);
bytesBuilder.add(bytes);
}
}
for (final node in unit.nodes) {
if (node is! ImportExportDecl) {
final bytes = compileAST(node);
bytesBuilder.add(bytes);
}
}
bytesBuilder.addByte(OpCode.endOfFile);
return bytesBuilder.toBytes();
}