class YAMLScript

def load(ys_code)

Compile and eval a YAMLScript string and return the result
def load(ys_code)
  # Create a new GraalVM isolate thread for each call to load()
  thread = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  raise Error, "Failed to create isolate" unless \
    LibYS.graal_create_isolate(nil, @isolate.ref, thread.ref).zero?
  # Call 'load_ys_to_json' function in libys shared library
  json_data = LibYS.load_ys_to_json(thread, ys_code)
  resp = JSON.parse(json_data.to_s)
  raise Error, "Failed to tear down isolate" unless \
    LibYS.graal_tear_down_isolate(thread).zero?
  raise Error, @error['cause'] if @error = resp['error']
  data = resp.fetch('data') do
    raise Error, "Unexpected response from 'libys'"
  end
  data
end