visitFunctionTypeExpr method

  1. @override
Uint8List visitFunctionTypeExpr(
  1. FuncTypeExpr expr
)
override

Implementation

@override
Uint8List visitFunctionTypeExpr(FuncTypeExpr expr) {
  final bytesBuilder = BytesBuilder();
  if (expr.isLocal) {
    bytesBuilder.addByte(HTOpCode.local);
  }
  bytesBuilder.addByte(HTValueTypeCode.functionType);
  bytesBuilder
      .addByte(expr.paramTypes.length); // uint8: length of param types
  for (final param in expr.paramTypes) {
    final bytes = visitParamTypeExpr(param);
    bytesBuilder.add(bytes);
  }
  final returnType = compileAST(expr.returnType);
  bytesBuilder.add(returnType);
  return bytesBuilder.toBytes();
}