visitStructObjExpr method

  1. @override
Uint8List visitStructObjExpr(
  1. StructObjExpr obj
)
override

Implementation

@override
Uint8List visitStructObjExpr(StructObjExpr obj) {
  final bytesBuilder = BytesBuilder();
  bytesBuilder.addByte(HTOpCode.local);
  bytesBuilder.addByte(HTValueTypeCode.struct);
  if (obj.id != null) {
    bytesBuilder.addByte(1); // bool: has id
    bytesBuilder.add(_parseIdentifier(obj.id!.id));
  } else {
    bytesBuilder.addByte(0); // bool: has id
  }
  if (obj.prototypeId != null) {
    bytesBuilder.addByte(1); // bool: has prototype
    bytesBuilder.add(_parseIdentifier(obj.prototypeId!.id));
  } else {
    bytesBuilder.addByte(0); // bool: has prototype
  }
  bytesBuilder.addByte(obj.fields.length);
  for (final field in obj.fields) {
    final bytes = visitStructObjField(field);
    bytesBuilder.add(bytes);
  }
  return bytesBuilder.toBytes();
}