novy-syndicate/src/gen/sturdy.ts

988 lines
36 KiB
TypeScript

import * as _ from "@preserves/core";
import * as _i_Actor from "../actor";
export const $__ = Symbol.for("_");
export const $and = Symbol.for("and");
export const $arr = Symbol.for("arr");
export const $bind = Symbol.for("bind");
export const $compound = Symbol.for("compound");
export const $dict = Symbol.for("dict");
export const $lit = Symbol.for("lit");
export const $not = Symbol.for("not");
export const $or = Symbol.for("or");
export const $rec = Symbol.for("rec");
export const $ref = Symbol.for("ref");
export const $resolve = Symbol.for("resolve");
export const $rewrite = Symbol.for("rewrite");
export const SturdyRef = _.Record.makeConstructor<{"oid": _val, "caveatChain": Array<Attenuation>, "sig": _.Bytes}, _ptr>()($ref, ["oid","caveatChain","sig"]);
export type SturdyRef = _.Record<(typeof $ref), [_val, Array<Attenuation>, _.Bytes], _ptr>;
export type Attenuation = Array<Caveat>;
export type Caveat = (Rewrite | Alts);
export const Rewrite = _.Record.makeConstructor<{"pattern": Pattern, "template": Template}, _ptr>()($rewrite, ["pattern","template"]);
export type Rewrite = _.Record<(typeof $rewrite), [Pattern, Template], _ptr>;
export const Alts = _.Record.makeConstructor<{"alternatives": Array<Rewrite>}, _ptr>()($or, ["alternatives"]);
export type Alts = _.Record<(typeof $or), [Array<Rewrite>], _ptr>;
export const Resolve = _.Record.makeConstructor<{"sturdyref": SturdyRef, "observer": _ptr}, _ptr>()($resolve, ["sturdyref","observer"]);
export type Resolve = _.Record<(typeof $resolve), [SturdyRef, _ptr], _ptr>;
export type ConstructorSpec = (CRec | CArr | CDict);
export const CRec = _.Record.makeConstructor<{"label": _val, "arity": number}, _ptr>()($rec, ["label","arity"]);
export type CRec = _.Record<(typeof $rec), [_val, number], _ptr>;
export const CArr = _.Record.makeConstructor<{"arity": number}, _ptr>()($arr, ["arity"]);
export type CArr = _.Record<(typeof $arr), [number], _ptr>;
export const CDict = _.Record.makeConstructor<{}, _ptr>()($dict, []);
export type CDict = _.Record<(typeof $dict), [], _ptr>;
export const Lit = _.Record.makeConstructor<{"value": _val}, _ptr>()($lit, ["value"]);
export type Lit = _.Record<(typeof $lit), [_val], _ptr>;
export type Pattern = (PDiscard | PBind | PAnd | PNot | Lit | PCompound);
export const PDiscard = _.Record.makeConstructor<{}, _ptr>()($__, []);
export type PDiscard = _.Record<(typeof $__), [], _ptr>;
export const PBind = _.Record.makeConstructor<{"name": symbol, "pattern": Pattern}, _ptr>()($bind, ["name","pattern"]);
export type PBind = _.Record<(typeof $bind), [symbol, Pattern], _ptr>;
export const PAnd = _.Record.makeConstructor<{"patterns": Array<Pattern>}, _ptr>()($and, ["patterns"]);
export type PAnd = _.Record<(typeof $and), [Array<Pattern>], _ptr>;
export const PNot = _.Record.makeConstructor<{"pattern": Pattern}, _ptr>()($not, ["pattern"]);
export type PNot = _.Record<(typeof $not), [Pattern], _ptr>;
export const PCompound = _.Record.makeConstructor<{"ctor": ConstructorSpec, "members": _.KeyedDictionary<_val, Pattern, _ptr>}, _ptr>()($compound, ["ctor","members"]);
export type PCompound = _.Record<
(typeof $compound),
[ConstructorSpec, _.KeyedDictionary<_val, Pattern, _ptr>],
_ptr
>;
export type Template = (TRef | Lit | TCompound);
export const TRef = _.Record.makeConstructor<{"name": symbol}, _ptr>()($ref, ["name"]);
export type TRef = _.Record<(typeof $ref), [symbol], _ptr>;
export const TCompound = _.Record.makeConstructor<{"ctor": ConstructorSpec, "members": _.KeyedDictionary<_val, Template, _ptr>}, _ptr>()($compound, ["ctor","members"]);
export type TCompound = _.Record<
(typeof $compound),
[ConstructorSpec, _.KeyedDictionary<_val, Template, _ptr>],
_ptr
>;
export type _ptr = _i_Actor.Ref;
export type _val = _.Value<_ptr>;
export function isSturdyRef(v: any): v is SturdyRef {
return (
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
_.is(v.label, $ref) &&
(
(v.length === 3) &&
true &&
(
_.Array.isArray(v[1]) &&
!_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[1]) &&
(v[1].length >= 0) &&
v[1].every(v => (isAttenuation(v)))
) &&
_.Bytes.isBytes(v[2])
)
);
}
export function asSturdyRef(v: any): SturdyRef {
if (!isSturdyRef(v)) {throw new TypeError(`Invalid SturdyRef: ${_.stringify(v)}`);} else {return v;};
}
export function decodeSturdyRef(d: _.TypedDecoder<_ptr>): SturdyRef | undefined {
let result;
if (d.openRecord()) {
let _tmp0: any;
_tmp0 = _.asLiteral(d.nextSymbol(), $ref);
if (_tmp0 !== void 0) {
let _tmp1, _tmp2, _tmp3, _tmp4: any;
_tmp2 = d.next();
if (_tmp2 !== void 0) {
if (d.openSequence()) {
let _tmp5: any;
{
let vN: Array<Attenuation> | undefined = [];
while (!d.closeCompound()) {
_tmp5 = void 0;
_tmp5 = decodeAttenuation(d);
if (_tmp5 === void 0) {vN = void 0; break;};
vN.push(_tmp5);
};
_tmp3 = vN;
};
};
if (_tmp3 !== void 0) {
_tmp4 = d.nextByteString();
if (_tmp4 !== void 0) {if (d.closeCompound()) _tmp1 = [_tmp2, _tmp3, _tmp4];};
};
};
if (_tmp1 !== void 0) result = _.Record<(typeof $ref), [_val, Array<Attenuation>, _.Bytes]>(_tmp0 as any, _tmp1 as any);
};
};
return result;
}
export function isAttenuation(v: any): v is Attenuation {
return (
_.Array.isArray(v) &&
!_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
(v.length >= 0) &&
v.every(v => (isCaveat(v)))
);
}
export function asAttenuation(v: any): Attenuation {
if (!isAttenuation(v)) {throw new TypeError(`Invalid Attenuation: ${_.stringify(v)}`);} else {return v;};
}
export function decodeAttenuation(d: _.TypedDecoder<_ptr>): Attenuation | undefined {
let result;
if (d.openSequence()) {
let _tmp6: any;
{
let vN: Array<Caveat> | undefined = [];
while (!d.closeCompound()) {
_tmp6 = void 0;
_tmp6 = decodeCaveat(d);
if (_tmp6 === void 0) {vN = void 0; break;};
vN.push(_tmp6);
};
result = vN;
};
};
return result;
}
export function isCaveat(v: any): v is Caveat {
return _.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) && (
(
(
_.is(v.label, $rewrite) && ((v.length === 2) && isPattern(v[0]) && isTemplate(v[1]))
) ||
(
_.is(v.label, $or) && (
(v.length === 1) &&
(
_.Array.isArray(v[0]) &&
!_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[0]) &&
(v[0].length >= 0) &&
v[0].every(v => (isRewrite(v)))
)
)
)
)
);
}
export function asCaveat(v: any): Caveat {
if (!isCaveat(v)) {throw new TypeError(`Invalid Caveat: ${_.stringify(v)}`);} else {return v;};
}
export function decodeCaveat(d: _.TypedDecoder<_ptr>): Caveat | undefined {
let result;
if (d.openRecord()) {
let _tmp7, _tmp8: any;
_tmp7 = d.next();
_tmp8 = d.mark();
if (_.is(_tmp7, $rewrite)) {
let _tmp9, _tmp10, _tmp11: any;
_tmp10 = decodePattern(d);
if (_tmp10 !== void 0) {
_tmp11 = decodeTemplate(d);
if (_tmp11 !== void 0) {if (d.closeCompound()) _tmp9 = [_tmp10, _tmp11];};
};
if (_tmp9 !== void 0) result = _.Record<(typeof $rewrite), [Pattern, Template]>(_tmp7 as any, _tmp9 as any);
};
if (result === void 0) {
d.restoreMark(_tmp8);
if (_.is(_tmp7, $or)) {
let _tmp12, _tmp13: any;
if (d.openSequence()) {
let _tmp14: any;
{
let vN: Array<Rewrite> | undefined = [];
while (!d.closeCompound()) {
_tmp14 = void 0;
_tmp14 = decodeRewrite(d);
if (_tmp14 === void 0) {vN = void 0; break;};
vN.push(_tmp14);
};
_tmp13 = vN;
};
};
if (_tmp13 !== void 0) {if (d.closeCompound()) _tmp12 = [_tmp13];};
if (_tmp12 !== void 0) result = _.Record<(typeof $or), [Array<Rewrite>]>(_tmp7 as any, _tmp12 as any);
};
};
};
return result;
}
export function isRewrite(v: any): v is Rewrite {
return (
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
_.is(v.label, $rewrite) &&
((v.length === 2) && isPattern(v[0]) && isTemplate(v[1]))
);
}
export function asRewrite(v: any): Rewrite {
if (!isRewrite(v)) {throw new TypeError(`Invalid Rewrite: ${_.stringify(v)}`);} else {return v;};
}
export function decodeRewrite(d: _.TypedDecoder<_ptr>): Rewrite | undefined {
let result;
if (d.openRecord()) {
let _tmp15: any;
_tmp15 = _.asLiteral(d.nextSymbol(), $rewrite);
if (_tmp15 !== void 0) {
let _tmp16, _tmp17, _tmp18: any;
_tmp17 = decodePattern(d);
if (_tmp17 !== void 0) {
_tmp18 = decodeTemplate(d);
if (_tmp18 !== void 0) {if (d.closeCompound()) _tmp16 = [_tmp17, _tmp18];};
};
if (_tmp16 !== void 0) result = _.Record<(typeof $rewrite), [Pattern, Template]>(_tmp15 as any, _tmp16 as any);
};
};
return result;
}
export function isAlts(v: any): v is Alts {
return (
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
_.is(v.label, $or) &&
(
(v.length === 1) &&
(
_.Array.isArray(v[0]) &&
!_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[0]) &&
(v[0].length >= 0) &&
v[0].every(v => (isRewrite(v)))
)
)
);
}
export function asAlts(v: any): Alts {
if (!isAlts(v)) {throw new TypeError(`Invalid Alts: ${_.stringify(v)}`);} else {return v;};
}
export function decodeAlts(d: _.TypedDecoder<_ptr>): Alts | undefined {
let result;
if (d.openRecord()) {
let _tmp19: any;
_tmp19 = _.asLiteral(d.nextSymbol(), $or);
if (_tmp19 !== void 0) {
let _tmp20, _tmp21: any;
if (d.openSequence()) {
let _tmp22: any;
{
let vN: Array<Rewrite> | undefined = [];
while (!d.closeCompound()) {
_tmp22 = void 0;
_tmp22 = decodeRewrite(d);
if (_tmp22 === void 0) {vN = void 0; break;};
vN.push(_tmp22);
};
_tmp21 = vN;
};
};
if (_tmp21 !== void 0) {if (d.closeCompound()) _tmp20 = [_tmp21];};
if (_tmp20 !== void 0) result = _.Record<(typeof $or), [Array<Rewrite>]>(_tmp19 as any, _tmp20 as any);
};
};
return result;
}
export function isResolve(v: any): v is Resolve {
return (
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
_.is(v.label, $resolve) &&
((v.length === 2) && isSturdyRef(v[0]) && _.isPointer(v[1]))
);
}
export function asResolve(v: any): Resolve {
if (!isResolve(v)) {throw new TypeError(`Invalid Resolve: ${_.stringify(v)}`);} else {return v;};
}
export function decodeResolve(d: _.TypedDecoder<_ptr>): Resolve | undefined {
let result;
if (d.openRecord()) {
let _tmp23: any;
_tmp23 = _.asLiteral(d.nextSymbol(), $resolve);
if (_tmp23 !== void 0) {
let _tmp24, _tmp25, _tmp26: any;
_tmp25 = decodeSturdyRef(d);
if (_tmp25 !== void 0) {
_tmp26 = _decodePtr(d);
if (_tmp26 !== void 0) {if (d.closeCompound()) _tmp24 = [_tmp25, _tmp26];};
};
if (_tmp24 !== void 0) result = _.Record<(typeof $resolve), [SturdyRef, _ptr]>(_tmp23 as any, _tmp24 as any);
};
};
return result;
}
export function isConstructorSpec(v: any): v is ConstructorSpec {
return _.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) && (
(
(_.is(v.label, $rec) && ((v.length === 2) && true && typeof v[1] === 'number')) ||
(_.is(v.label, $arr) && ((v.length === 1) && typeof v[0] === 'number')) ||
(_.is(v.label, $dict) && ((v.length === 0)))
)
);
}
export function asConstructorSpec(v: any): ConstructorSpec {
if (!isConstructorSpec(v)) {throw new TypeError(`Invalid ConstructorSpec: ${_.stringify(v)}`);} else {return v;};
}
export function decodeConstructorSpec(d: _.TypedDecoder<_ptr>): ConstructorSpec | undefined {
let result;
if (d.openRecord()) {
let _tmp27, _tmp28: any;
_tmp27 = d.next();
_tmp28 = d.mark();
if (_.is(_tmp27, $rec)) {
let _tmp29, _tmp30, _tmp31: any;
_tmp30 = d.next();
if (_tmp30 !== void 0) {
_tmp31 = d.nextSignedInteger();
if (_tmp31 !== void 0) {if (d.closeCompound()) _tmp29 = [_tmp30, _tmp31];};
};
if (_tmp29 !== void 0) result = _.Record<(typeof $rec), [_val, number]>(_tmp27 as any, _tmp29 as any);
};
if (result === void 0) {
d.restoreMark(_tmp28);
if (_.is(_tmp27, $arr)) {
let _tmp32, _tmp33: any;
_tmp33 = d.nextSignedInteger();
if (_tmp33 !== void 0) {if (d.closeCompound()) _tmp32 = [_tmp33];};
if (_tmp32 !== void 0) result = _.Record<(typeof $arr), [number]>(_tmp27 as any, _tmp32 as any);
};
if (result === void 0) {
d.restoreMark(_tmp28);
if (_.is(_tmp27, $dict)) {
let _tmp34: any;
if (d.closeCompound()) _tmp34 = [];
if (_tmp34 !== void 0) result = _.Record<(typeof $dict), []>(_tmp27 as any, _tmp34 as any);
};
};
};
};
return result;
}
export function isCRec(v: any): v is CRec {
return (
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
_.is(v.label, $rec) &&
((v.length === 2) && true && typeof v[1] === 'number')
);
}
export function asCRec(v: any): CRec {
if (!isCRec(v)) {throw new TypeError(`Invalid CRec: ${_.stringify(v)}`);} else {return v;};
}
export function decodeCRec(d: _.TypedDecoder<_ptr>): CRec | undefined {
let result;
if (d.openRecord()) {
let _tmp35: any;
_tmp35 = _.asLiteral(d.nextSymbol(), $rec);
if (_tmp35 !== void 0) {
let _tmp36, _tmp37, _tmp38: any;
_tmp37 = d.next();
if (_tmp37 !== void 0) {
_tmp38 = d.nextSignedInteger();
if (_tmp38 !== void 0) {if (d.closeCompound()) _tmp36 = [_tmp37, _tmp38];};
};
if (_tmp36 !== void 0) result = _.Record<(typeof $rec), [_val, number]>(_tmp35 as any, _tmp36 as any);
};
};
return result;
}
export function isCArr(v: any): v is CArr {
return (
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
_.is(v.label, $arr) &&
((v.length === 1) && typeof v[0] === 'number')
);
}
export function asCArr(v: any): CArr {
if (!isCArr(v)) {throw new TypeError(`Invalid CArr: ${_.stringify(v)}`);} else {return v;};
}
export function decodeCArr(d: _.TypedDecoder<_ptr>): CArr | undefined {
let result;
if (d.openRecord()) {
let _tmp39: any;
_tmp39 = _.asLiteral(d.nextSymbol(), $arr);
if (_tmp39 !== void 0) {
let _tmp40, _tmp41: any;
_tmp41 = d.nextSignedInteger();
if (_tmp41 !== void 0) {if (d.closeCompound()) _tmp40 = [_tmp41];};
if (_tmp40 !== void 0) result = _.Record<(typeof $arr), [number]>(_tmp39 as any, _tmp40 as any);
};
};
return result;
}
export function isCDict(v: any): v is CDict {
return (
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
_.is(v.label, $dict) &&
((v.length === 0))
);
}
export function asCDict(v: any): CDict {
if (!isCDict(v)) {throw new TypeError(`Invalid CDict: ${_.stringify(v)}`);} else {return v;};
}
export function decodeCDict(d: _.TypedDecoder<_ptr>): CDict | undefined {
let result;
if (d.openRecord()) {
let _tmp42: any;
_tmp42 = _.asLiteral(d.nextSymbol(), $dict);
if (_tmp42 !== void 0) {
let _tmp43: any;
if (d.closeCompound()) _tmp43 = [];
if (_tmp43 !== void 0) result = _.Record<(typeof $dict), []>(_tmp42 as any, _tmp43 as any);
};
};
return result;
}
export function isLit(v: any): v is Lit {
return (
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
_.is(v.label, $lit) &&
((v.length === 1) && true)
);
}
export function asLit(v: any): Lit {
if (!isLit(v)) {throw new TypeError(`Invalid Lit: ${_.stringify(v)}`);} else {return v;};
}
export function decodeLit(d: _.TypedDecoder<_ptr>): Lit | undefined {
let result;
if (d.openRecord()) {
let _tmp44: any;
_tmp44 = _.asLiteral(d.nextSymbol(), $lit);
if (_tmp44 !== void 0) {
let _tmp45, _tmp46: any;
_tmp46 = d.next();
if (_tmp46 !== void 0) {if (d.closeCompound()) _tmp45 = [_tmp46];};
if (_tmp45 !== void 0) result = _.Record<(typeof $lit), [_val]>(_tmp44 as any, _tmp45 as any);
};
};
return result;
}
export function isPattern(v: any): v is Pattern {
return _.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) && (
(
(_.is(v.label, $__) && ((v.length === 0))) ||
(
_.is(v.label, $bind) && ((v.length === 2) && typeof v[0] === 'symbol' && isPattern(v[1]))
) ||
(
_.is(v.label, $and) && (
(v.length === 1) &&
(
_.Array.isArray(v[0]) &&
!_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[0]) &&
(v[0].length >= 0) &&
v[0].every(v => (isPattern(v)))
)
)
) ||
(_.is(v.label, $not) && ((v.length === 1) && isPattern(v[0]))) ||
(_.is(v.label, $lit) && ((v.length === 1) && true)) ||
(
_.is(v.label, $compound) && (
(v.length === 2) &&
isConstructorSpec(v[0]) &&
(
_.Dictionary.isDictionary<_val, _ptr>(v[1]) &&
((() => {
for (const e of v[1]) {if (!(true)) return false; if (!(isPattern(e[1]))) return false;};
return true;
})())
)
)
)
)
);
}
export function asPattern(v: any): Pattern {
if (!isPattern(v)) {throw new TypeError(`Invalid Pattern: ${_.stringify(v)}`);} else {return v;};
}
export function decodePattern(d: _.TypedDecoder<_ptr>): Pattern | undefined {
let result;
if (d.openRecord()) {
let _tmp47, _tmp48: any;
_tmp47 = d.next();
_tmp48 = d.mark();
if (_.is(_tmp47, $__)) {
let _tmp49: any;
if (d.closeCompound()) _tmp49 = [];
if (_tmp49 !== void 0) result = _.Record<(typeof $__), []>(_tmp47 as any, _tmp49 as any);
};
if (result === void 0) {
d.restoreMark(_tmp48);
if (_.is(_tmp47, $bind)) {
let _tmp50, _tmp51, _tmp52: any;
_tmp51 = d.nextSymbol();
if (_tmp51 !== void 0) {
_tmp52 = decodePattern(d);
if (_tmp52 !== void 0) {if (d.closeCompound()) _tmp50 = [_tmp51, _tmp52];};
};
if (_tmp50 !== void 0) result = _.Record<(typeof $bind), [symbol, Pattern]>(_tmp47 as any, _tmp50 as any);
};
if (result === void 0) {
d.restoreMark(_tmp48);
if (_.is(_tmp47, $and)) {
let _tmp53, _tmp54: any;
if (d.openSequence()) {
let _tmp55: any;
{
let vN: Array<Pattern> | undefined = [];
while (!d.closeCompound()) {
_tmp55 = void 0;
_tmp55 = decodePattern(d);
if (_tmp55 === void 0) {vN = void 0; break;};
vN.push(_tmp55);
};
_tmp54 = vN;
};
};
if (_tmp54 !== void 0) {if (d.closeCompound()) _tmp53 = [_tmp54];};
if (_tmp53 !== void 0) result = _.Record<(typeof $and), [Array<Pattern>]>(_tmp47 as any, _tmp53 as any);
};
if (result === void 0) {
d.restoreMark(_tmp48);
if (_.is(_tmp47, $not)) {
let _tmp56, _tmp57: any;
_tmp57 = decodePattern(d);
if (_tmp57 !== void 0) {if (d.closeCompound()) _tmp56 = [_tmp57];};
if (_tmp56 !== void 0) result = _.Record<(typeof $not), [Pattern]>(_tmp47 as any, _tmp56 as any);
};
if (result === void 0) {
d.restoreMark(_tmp48);
if (_.is(_tmp47, $lit)) {
let _tmp58, _tmp59: any;
_tmp59 = d.next();
if (_tmp59 !== void 0) {if (d.closeCompound()) _tmp58 = [_tmp59];};
if (_tmp58 !== void 0) result = _.Record<(typeof $lit), [_val]>(_tmp47 as any, _tmp58 as any);
};
if (result === void 0) {
d.restoreMark(_tmp48);
if (_.is(_tmp47, $compound)) {
let _tmp60, _tmp61, _tmp62: any;
_tmp61 = decodeConstructorSpec(d);
if (_tmp61 !== void 0) {
if (d.openDictionary()) {
let r: _.KeyedDictionary<_val, Pattern, _ptr> | undefined = new _.KeyedDictionary();
while (!d.closeCompound()) {
let K: undefined | _val = void 0;
K = d.next();
if (K === void 0) { r = void 0; break; };
let V: undefined | Pattern = void 0;
V = decodePattern(d);
if (V === void 0) { r = void 0; break; };
r.set(K, V);
};
_tmp62 = r;
};
if (_tmp62 !== void 0) {if (d.closeCompound()) _tmp60 = [_tmp61, _tmp62];};
};
if (_tmp60 !== void 0) result = _.Record<(typeof $compound), [ConstructorSpec, _.KeyedDictionary<_val, Pattern, _ptr>]>(_tmp47 as any, _tmp60 as any);
};
};
};
};
};
};
};
return result;
}
export function isPDiscard(v: any): v is PDiscard {
return (
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
_.is(v.label, $__) &&
((v.length === 0))
);
}
export function asPDiscard(v: any): PDiscard {
if (!isPDiscard(v)) {throw new TypeError(`Invalid PDiscard: ${_.stringify(v)}`);} else {return v;};
}
export function decodePDiscard(d: _.TypedDecoder<_ptr>): PDiscard | undefined {
let result;
if (d.openRecord()) {
let _tmp63: any;
_tmp63 = _.asLiteral(d.nextSymbol(), $__);
if (_tmp63 !== void 0) {
let _tmp64: any;
if (d.closeCompound()) _tmp64 = [];
if (_tmp64 !== void 0) result = _.Record<(typeof $__), []>(_tmp63 as any, _tmp64 as any);
};
};
return result;
}
export function isPBind(v: any): v is PBind {
return (
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
_.is(v.label, $bind) &&
((v.length === 2) && typeof v[0] === 'symbol' && isPattern(v[1]))
);
}
export function asPBind(v: any): PBind {
if (!isPBind(v)) {throw new TypeError(`Invalid PBind: ${_.stringify(v)}`);} else {return v;};
}
export function decodePBind(d: _.TypedDecoder<_ptr>): PBind | undefined {
let result;
if (d.openRecord()) {
let _tmp65: any;
_tmp65 = _.asLiteral(d.nextSymbol(), $bind);
if (_tmp65 !== void 0) {
let _tmp66, _tmp67, _tmp68: any;
_tmp67 = d.nextSymbol();
if (_tmp67 !== void 0) {
_tmp68 = decodePattern(d);
if (_tmp68 !== void 0) {if (d.closeCompound()) _tmp66 = [_tmp67, _tmp68];};
};
if (_tmp66 !== void 0) result = _.Record<(typeof $bind), [symbol, Pattern]>(_tmp65 as any, _tmp66 as any);
};
};
return result;
}
export function isPAnd(v: any): v is PAnd {
return (
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
_.is(v.label, $and) &&
(
(v.length === 1) &&
(
_.Array.isArray(v[0]) &&
!_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[0]) &&
(v[0].length >= 0) &&
v[0].every(v => (isPattern(v)))
)
)
);
}
export function asPAnd(v: any): PAnd {
if (!isPAnd(v)) {throw new TypeError(`Invalid PAnd: ${_.stringify(v)}`);} else {return v;};
}
export function decodePAnd(d: _.TypedDecoder<_ptr>): PAnd | undefined {
let result;
if (d.openRecord()) {
let _tmp69: any;
_tmp69 = _.asLiteral(d.nextSymbol(), $and);
if (_tmp69 !== void 0) {
let _tmp70, _tmp71: any;
if (d.openSequence()) {
let _tmp72: any;
{
let vN: Array<Pattern> | undefined = [];
while (!d.closeCompound()) {
_tmp72 = void 0;
_tmp72 = decodePattern(d);
if (_tmp72 === void 0) {vN = void 0; break;};
vN.push(_tmp72);
};
_tmp71 = vN;
};
};
if (_tmp71 !== void 0) {if (d.closeCompound()) _tmp70 = [_tmp71];};
if (_tmp70 !== void 0) result = _.Record<(typeof $and), [Array<Pattern>]>(_tmp69 as any, _tmp70 as any);
};
};
return result;
}
export function isPNot(v: any): v is PNot {
return (
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
_.is(v.label, $not) &&
((v.length === 1) && isPattern(v[0]))
);
}
export function asPNot(v: any): PNot {
if (!isPNot(v)) {throw new TypeError(`Invalid PNot: ${_.stringify(v)}`);} else {return v;};
}
export function decodePNot(d: _.TypedDecoder<_ptr>): PNot | undefined {
let result;
if (d.openRecord()) {
let _tmp73: any;
_tmp73 = _.asLiteral(d.nextSymbol(), $not);
if (_tmp73 !== void 0) {
let _tmp74, _tmp75: any;
_tmp75 = decodePattern(d);
if (_tmp75 !== void 0) {if (d.closeCompound()) _tmp74 = [_tmp75];};
if (_tmp74 !== void 0) result = _.Record<(typeof $not), [Pattern]>(_tmp73 as any, _tmp74 as any);
};
};
return result;
}
export function isPCompound(v: any): v is PCompound {
return (
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
_.is(v.label, $compound) &&
(
(v.length === 2) &&
isConstructorSpec(v[0]) &&
(
_.Dictionary.isDictionary<_val, _ptr>(v[1]) &&
((() => {
for (const e of v[1]) {if (!(true)) return false; if (!(isPattern(e[1]))) return false;};
return true;
})())
)
)
);
}
export function asPCompound(v: any): PCompound {
if (!isPCompound(v)) {throw new TypeError(`Invalid PCompound: ${_.stringify(v)}`);} else {return v;};
}
export function decodePCompound(d: _.TypedDecoder<_ptr>): PCompound | undefined {
let result;
if (d.openRecord()) {
let _tmp76: any;
_tmp76 = _.asLiteral(d.nextSymbol(), $compound);
if (_tmp76 !== void 0) {
let _tmp77, _tmp78, _tmp79: any;
_tmp78 = decodeConstructorSpec(d);
if (_tmp78 !== void 0) {
if (d.openDictionary()) {
let r: _.KeyedDictionary<_val, Pattern, _ptr> | undefined = new _.KeyedDictionary();
while (!d.closeCompound()) {
let K: undefined | _val = void 0;
K = d.next();
if (K === void 0) { r = void 0; break; };
let V: undefined | Pattern = void 0;
V = decodePattern(d);
if (V === void 0) { r = void 0; break; };
r.set(K, V);
};
_tmp79 = r;
};
if (_tmp79 !== void 0) {if (d.closeCompound()) _tmp77 = [_tmp78, _tmp79];};
};
if (_tmp77 !== void 0) result = _.Record<(typeof $compound), [ConstructorSpec, _.KeyedDictionary<_val, Pattern, _ptr>]>(_tmp76 as any, _tmp77 as any);
};
};
return result;
}
export function isTemplate(v: any): v is Template {
return _.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) && (
(
(_.is(v.label, $ref) && ((v.length === 1) && typeof v[0] === 'symbol')) ||
(_.is(v.label, $lit) && ((v.length === 1) && true)) ||
(
_.is(v.label, $compound) && (
(v.length === 2) &&
isConstructorSpec(v[0]) &&
(
_.Dictionary.isDictionary<_val, _ptr>(v[1]) &&
((() => {
for (const e of v[1]) {if (!(true)) return false; if (!(isTemplate(e[1]))) return false;};
return true;
})())
)
)
)
)
);
}
export function asTemplate(v: any): Template {
if (!isTemplate(v)) {throw new TypeError(`Invalid Template: ${_.stringify(v)}`);} else {return v;};
}
export function decodeTemplate(d: _.TypedDecoder<_ptr>): Template | undefined {
let result;
if (d.openRecord()) {
let _tmp80, _tmp81: any;
_tmp80 = d.next();
_tmp81 = d.mark();
if (_.is(_tmp80, $ref)) {
let _tmp82, _tmp83: any;
_tmp83 = d.nextSymbol();
if (_tmp83 !== void 0) {if (d.closeCompound()) _tmp82 = [_tmp83];};
if (_tmp82 !== void 0) result = _.Record<(typeof $ref), [symbol]>(_tmp80 as any, _tmp82 as any);
};
if (result === void 0) {
d.restoreMark(_tmp81);
if (_.is(_tmp80, $lit)) {
let _tmp84, _tmp85: any;
_tmp85 = d.next();
if (_tmp85 !== void 0) {if (d.closeCompound()) _tmp84 = [_tmp85];};
if (_tmp84 !== void 0) result = _.Record<(typeof $lit), [_val]>(_tmp80 as any, _tmp84 as any);
};
if (result === void 0) {
d.restoreMark(_tmp81);
if (_.is(_tmp80, $compound)) {
let _tmp86, _tmp87, _tmp88: any;
_tmp87 = decodeConstructorSpec(d);
if (_tmp87 !== void 0) {
if (d.openDictionary()) {
let r: _.KeyedDictionary<_val, Template, _ptr> | undefined = new _.KeyedDictionary();
while (!d.closeCompound()) {
let K: undefined | _val = void 0;
K = d.next();
if (K === void 0) { r = void 0; break; };
let V: undefined | Template = void 0;
V = decodeTemplate(d);
if (V === void 0) { r = void 0; break; };
r.set(K, V);
};
_tmp88 = r;
};
if (_tmp88 !== void 0) {if (d.closeCompound()) _tmp86 = [_tmp87, _tmp88];};
};
if (_tmp86 !== void 0) result = _.Record<(typeof $compound), [ConstructorSpec, _.KeyedDictionary<_val, Template, _ptr>]>(_tmp80 as any, _tmp86 as any);
};
};
};
};
return result;
}
export function isTRef(v: any): v is TRef {
return (
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
_.is(v.label, $ref) &&
((v.length === 1) && typeof v[0] === 'symbol')
);
}
export function asTRef(v: any): TRef {
if (!isTRef(v)) {throw new TypeError(`Invalid TRef: ${_.stringify(v)}`);} else {return v;};
}
export function decodeTRef(d: _.TypedDecoder<_ptr>): TRef | undefined {
let result;
if (d.openRecord()) {
let _tmp89: any;
_tmp89 = _.asLiteral(d.nextSymbol(), $ref);
if (_tmp89 !== void 0) {
let _tmp90, _tmp91: any;
_tmp91 = d.nextSymbol();
if (_tmp91 !== void 0) {if (d.closeCompound()) _tmp90 = [_tmp91];};
if (_tmp90 !== void 0) result = _.Record<(typeof $ref), [symbol]>(_tmp89 as any, _tmp90 as any);
};
};
return result;
}
export function isTCompound(v: any): v is TCompound {
return (
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
_.is(v.label, $compound) &&
(
(v.length === 2) &&
isConstructorSpec(v[0]) &&
(
_.Dictionary.isDictionary<_val, _ptr>(v[1]) &&
((() => {
for (const e of v[1]) {if (!(true)) return false; if (!(isTemplate(e[1]))) return false;};
return true;
})())
)
)
);
}
export function asTCompound(v: any): TCompound {
if (!isTCompound(v)) {throw new TypeError(`Invalid TCompound: ${_.stringify(v)}`);} else {return v;};
}
export function decodeTCompound(d: _.TypedDecoder<_ptr>): TCompound | undefined {
let result;
if (d.openRecord()) {
let _tmp92: any;
_tmp92 = _.asLiteral(d.nextSymbol(), $compound);
if (_tmp92 !== void 0) {
let _tmp93, _tmp94, _tmp95: any;
_tmp94 = decodeConstructorSpec(d);
if (_tmp94 !== void 0) {
if (d.openDictionary()) {
let r: _.KeyedDictionary<_val, Template, _ptr> | undefined = new _.KeyedDictionary();
while (!d.closeCompound()) {
let K: undefined | _val = void 0;
K = d.next();
if (K === void 0) { r = void 0; break; };
let V: undefined | Template = void 0;
V = decodeTemplate(d);
if (V === void 0) { r = void 0; break; };
r.set(K, V);
};
_tmp95 = r;
};
if (_tmp95 !== void 0) {if (d.closeCompound()) _tmp93 = [_tmp94, _tmp95];};
};
if (_tmp93 !== void 0) result = _.Record<(typeof $compound), [ConstructorSpec, _.KeyedDictionary<_val, Template, _ptr>]>(_tmp92 as any, _tmp93 as any);
};
};
return result;
}
export const _decodePtr = (d: _.TypedDecoder<_ptr>) => {let result; result = _i_Actor.decodeRef(d); return result;};