How to use the @effectful/serialization.regOpaqueObject function in @effectful/serialization

To help you get started, we’ve selected a few @effectful/serialization examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github awto / effectfuljs / packages / debugger / src / kit.js View on Github external
}
  });
  function constr($$) {
    const proto = Object.create(FramePrototype);
    proto.$meta = info;
    proto.$$ = $$;
    proto.$run = info.handler;
    proto.$err = info.errHandler;
    const closure = info.func(proto);
    closure[metaDataSymbol] = proto;
    closure[S.descriptorSymbol] = funcDescr;
    // proto[S.descriptorSymbol] = frameDescr;
    proto.constructor = closure;
    return closure;
  }
  S.regOpaqueObject(constr, `c#${info.module.name}#${info.name}`);
  S.regOpaqueObject(info.handler, `h#${info.module.name}#${info.name}`);
  if (info.errHandler)
    S.regOpaqueObject(info.errHandler, `eh#${info.module.name}#${info.name}`);
  return constr;
}
github awto / effectfuljs / packages / debugger / src / kit.js View on Github external
const proto = Object.create(FramePrototype);
    proto.$meta = info;
    proto.$$ = $$;
    proto.$run = info.handler;
    proto.$err = info.errHandler;
    const closure = info.func(proto);
    closure[metaDataSymbol] = proto;
    closure[S.descriptorSymbol] = funcDescr;
    // proto[S.descriptorSymbol] = frameDescr;
    proto.constructor = closure;
    return closure;
  }
  S.regOpaqueObject(constr, `c#${info.module.name}#${info.name}`);
  S.regOpaqueObject(info.handler, `h#${info.module.name}#${info.name}`);
  if (info.errHandler)
    S.regOpaqueObject(info.errHandler, `eh#${info.module.name}#${info.name}`);
  return constr;
}
github awto / effectfuljs / packages / debugger / src / kit.js View on Github external
});
  function constr($$) {
    const proto = Object.create(FramePrototype);
    proto.$meta = info;
    proto.$$ = $$;
    proto.$run = info.handler;
    proto.$err = info.errHandler;
    const closure = info.func(proto);
    closure[metaDataSymbol] = proto;
    closure[S.descriptorSymbol] = funcDescr;
    // proto[S.descriptorSymbol] = frameDescr;
    proto.constructor = closure;
    return closure;
  }
  S.regOpaqueObject(constr, `c#${info.module.name}#${info.name}`);
  S.regOpaqueObject(info.handler, `h#${info.module.name}#${info.name}`);
  if (info.errHandler)
    S.regOpaqueObject(info.errHandler, `eh#${info.module.name}#${info.name}`);
  return constr;
}
github awto / effectfuljs / packages / debugger / src / kit.js View on Github external
export function regModule(exp, name) {
  if (exp[S.descriptorSymbol]) return;
  if (!name) name = "?";
  if (typeof exp === "object" || typeof exp === "function")
    S.regOpaqueObject(exp, `module#${name}`);
  for (const i in exp) {
    const f = exp[i];
    if (!f) continue;
    const ty = typeof f;
    if (ty === "function" || ty === "object")
      S.regOpaqueObject(f, `export#${name}#${i}`);
    else if (ty === "symbol" && !Symbol.keyFor(f))
      S.regOpaquePrim(f, `export#${name}#${i}`);
  }
}
github awto / effectfuljs / packages / debugger / src / kit.js View on Github external
resume() {
    try {
      const arg = context.value;
      context.value = void 0;
      return this.$run(arg);
    } catch (e) {
      this.$state = this.$err(this.$state);
      context.brk = "throw";
      context.error = true;
      context.value = e;
      return token;
    }
  }
};

S.regOpaqueObject(FramePrototype, "debugger#frame");

function defaultErrHandler() {
  return 1;
}

export function frame(proto) {
  const res = Object.create(proto);
  res.$ = {};
  return res;
}

export function constr(v) {
  return v;
}

export function brk(name, descr) {
github awto / effectfuljs / packages / debugger / src / kit.js View on Github external
) {
  if (!name) name = "*";
  if (!errHandler) errHandler = defaultErrHandler;
  const info = {
    module,
    func,
    handler,
    errHandler,
    finHandler,
    name,
    loc,
    parent,
    scope
  };
  const wrap = wrapMeta(info);
  S.regOpaqueObject(info, `i#${info.module.name}#${info.name}`);
  module.functions.push(info);
  return wrap;
}
github awto / effectfuljs / packages / debugger / src / kit.js View on Github external
export const region = func => {
  const ret = function(...args) {
    try {
      context.syncStack.push([context.stack, context.sync]);
      context.stack = null;
      context.sync = true;
      return func.apply(this, args);
    } finally {
      [context.stack, context.sync] = context.syncStack.pop();
    }
  };
  S.regOpaqueObject(ret, `region${func.name || "?"}`);
  return ret;
};
github awto / effectfuljs / packages / debugger / src / main.js View on Github external
import * as Trace from "./trace.js";
Trace.TraceData.prototype[S.descriptorSymbol] = S.NotSerializableDescriptor;
Kit.regModule(RT, "@effectful/debugger/rt");
Kit.regModule(Trace, "@effectful/debugger/trace");
for (const i of Object.values(RT)) {
  const meta = i && i[Kit.metaDataSymbol];
  if (meta) meta.canSkip = true;
}
export const exports = RT.exports;
export const imports = RT.imports;
export const chainM = RT.chainM;
export const Serialization = S;
S.regOpaquePrim(Kit.metaDataSymbol, "@effectful/debugger/metaData");
S.regOpaquePrim(Kit.thunkSymbol, "@effectful/debugger/thunk");
S.regOpaqueObject(Symbol.for, "Symbol.for");
S.regOpaqueObject(Symbol.keyFor, "Symbol.keyFor");
S.regOpaquePrim(Symbol.iterator, "SymbolStatic.iterator");
S.regOpaquePrim(Symbol.asyncIterator, "SymbolStatic.asyncIterator");
S.regOpaquePrim(Symbol.toStringTag, "SymbolStatic.asyncIterator");
github awto / effectfuljs / packages / debugger / main.js View on Github external
exports.Serialization = exports.chainM = exports.imports = exports.exports = void 0;

var S = require("@effectful/serialization");

var Kit = require("./kit.js");

Object.keys(Kit).forEach(function (key) {
  if (key === "default" || key === "__esModule") return;
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
  exports[key] = Kit[key];
});

var RT = require("./instr/rt.js");

Kit.regModule(Kit, "@effectful/debugger/kit");
S.regOpaqueObject(Kit.context.startThread, "@effectful/debugger/defaultStartThread");
Kit.regModule(RT, "@effectful/debugger/rt");
const _exports = RT.exports;
exports.exports = _exports;
const imports = RT.imports;
exports.imports = imports;
const chainM = RT.chainM;
exports.chainM = chainM;
const Serialization = S;
exports.Serialization = Serialization;
S.regOpaquePrim(Kit.metaDataSymbol, "@effectful/debugger/metaData");
S.regOpaquePrim(Kit.thunkSymbol, "@effectful/debugger/thunk");
S.regOpaqueObject(Symbol.for, "Symbol.for");
S.regOpaqueObject(Symbol.keyFor, "Symbol.keyFor");
S.regOpaquePrim(Symbol.iterator, "SymbolStatic.iterator");
S.regOpaquePrim(Symbol.asyncIterator, "SymbolStatic.asyncIterator");
S.regOpaquePrim(Symbol.toStringTag, "SymbolStatic.asyncIterator");