evaluateBytecode method

JsEvalResult evaluateBytecode(
  1. Uint8List bytecode
)
override

Implementation

JsEvalResult evaluateBytecode(Uint8List bytecode) {
  _ensureEngine();
  final ctx = _ctx!;
  final Pointer<Uint8> pointer = calloc<Uint8>(bytecode.length);
  pointer.asTypedList(bytecode.length).setAll(0, bytecode);

  final value = evaluateBytecodeFn(ctx, bytecode.length, pointer);

  calloc.free(pointer);

  if (value.address == 0 || jsIsException(value) != 0) {
    if (value.address != 0) jsFreeValue(ctx, value);
    JSError exception = _parseJSException(ctx);
    return JsEvalResult(exception.toString(), exception, isError: true);
  }

  return _toEvalResult(ctx, value);
}