visitParamDecl method

  1. @override
Uint8List visitParamDecl(
  1. ParamDecl stmt
)
override

Implementation

@override
Uint8List visitParamDecl(ParamDecl stmt) {
  final bytesBuilder = BytesBuilder();
  bytesBuilder.add(_parseIdentifier(stmt.id.id));
  bytesBuilder.addByte(stmt.isOptional ? 1 : 0);
  bytesBuilder.addByte(stmt.isVariadic ? 1 : 0);
  bytesBuilder.addByte(stmt.isNamed ? 1 : 0);
  bytesBuilder.addByte(stmt.isInitialization ? 1 : 0);
  Uint8List? typeDecl;
  if (stmt.declType != null) {
    typeDecl = compileAST(stmt.declType!);
  }
  if (typeDecl != null) {
    bytesBuilder.addByte(1); // bool: has type decl
    bytesBuilder.add(typeDecl);
  } else {
    bytesBuilder.addByte(0); // bool: has type decl
  }
  Uint8List? initializer;
  if (stmt.initializer != null) {
    initializer = compileAST(stmt.initializer!, endOfExec: true);
  }
  if (initializer != null) {
    bytesBuilder.addByte(1); // bool: has initializer
    bytesBuilder.add(_uint16(stmt.initializer!.line));
    bytesBuilder.add(_uint16(stmt.initializer!.column));
    bytesBuilder.add(_uint16(initializer.length));
    bytesBuilder.add(initializer);
  } else {
    bytesBuilder.addByte(0); // bool: has initializer
  }
  return bytesBuilder.toBytes();
}