diff --git a/src/gen/box-protocol.ts b/src/gen/box-protocol.ts index 486369b..04302f3 100644 --- a/src/gen/box-protocol.ts +++ b/src/gen/box-protocol.ts @@ -30,20 +30,18 @@ export function asBoxState(v: any): BoxState { } export function decodeBoxState(d: _.TypedDecoder<_ptr>): BoxState | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $BoxState); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - const v0 = d.nextSignedInteger(); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0] as [number]; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $BoxState), [number]>(L, Fs); - })()); + let result; + if (d.openRecord()) { + let _tmp0: any; + _tmp0 = _.asLiteral(d.nextSymbol(), $BoxState); + if (_tmp0 !== void 0) { + let _tmp1, _tmp2: any; + _tmp2 = d.nextSignedInteger(); + if (_tmp2 !== void 0) {if (d.closeCompound()) _tmp1 = [_tmp2];}; + if (_tmp1 !== void 0) result = _.Record<(typeof $BoxState), [number]>(_tmp0 as any, _tmp1 as any); + }; + }; + return result; } export function isSetBox(v: any): v is SetBox { @@ -59,21 +57,19 @@ export function asSetBox(v: any): SetBox { } export function decodeSetBox(d: _.TypedDecoder<_ptr>): SetBox | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $SetBox); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - const v0 = d.nextSignedInteger(); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0] as [number]; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $SetBox), [number]>(L, Fs); - })()); + let result; + if (d.openRecord()) { + let _tmp3: any; + _tmp3 = _.asLiteral(d.nextSymbol(), $SetBox); + if (_tmp3 !== void 0) { + let _tmp4, _tmp5: any; + _tmp5 = d.nextSignedInteger(); + if (_tmp5 !== void 0) {if (d.closeCompound()) _tmp4 = [_tmp5];}; + if (_tmp4 !== void 0) result = _.Record<(typeof $SetBox), [number]>(_tmp3 as any, _tmp4 as any); + }; + }; + return result; } -export const _decodePtr = (d: _.TypedDecoder<_ptr>) => _i_Actor.decodeRef(d); +export const _decodePtr = (d: _.TypedDecoder<_ptr>) => {let result; result = _i_Actor.decodeRef(d); return result;}; diff --git a/src/gen/dataspace.ts b/src/gen/dataspace.ts index d68cc50..cfd1b62 100644 --- a/src/gen/dataspace.ts +++ b/src/gen/dataspace.ts @@ -25,22 +25,22 @@ export function asObserve(v: any): Observe { } export function decodeObserve(d: _.TypedDecoder<_ptr>): Observe | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $Observe); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - const v0 = d.nextSymbol(); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - const v1 = _decodePtr(d); if (v1 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0, v1] as [symbol, _ptr]; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $Observe), [symbol, _ptr]>(L, Fs); - })()); + let result; + if (d.openRecord()) { + let _tmp0: any; + _tmp0 = _.asLiteral(d.nextSymbol(), $Observe); + if (_tmp0 !== void 0) { + let _tmp1, _tmp2, _tmp3: any; + _tmp2 = d.nextSymbol(); + if (_tmp2 !== void 0) { + _tmp3 = _decodePtr(d); + if (_tmp3 !== void 0) {if (d.closeCompound()) _tmp1 = [_tmp2, _tmp3];}; + }; + if (_tmp1 !== void 0) result = _.Record<(typeof $Observe), [symbol, _ptr]>(_tmp0 as any, _tmp1 as any); + }; + }; + return result; } -export const _decodePtr = (d: _.TypedDecoder<_ptr>) => _i_Actor.decodeRef(d); +export const _decodePtr = (d: _.TypedDecoder<_ptr>) => {let result; result = _i_Actor.decodeRef(d); return result;}; diff --git a/src/gen/protocol.ts b/src/gen/protocol.ts index 094fcb3..1689e56 100644 --- a/src/gen/protocol.ts +++ b/src/gen/protocol.ts @@ -43,7 +43,7 @@ export function asAssertion(v: any): Assertion { if (!isAssertion(v)) {throw new TypeError(`Invalid Assertion: ${_.stringify(v)}`);} else {return v;}; } -export function decodeAssertion(d: _.TypedDecoder<_ptr>): Assertion | undefined {return d.next();} +export function decodeAssertion(d: _.TypedDecoder<_ptr>): Assertion | undefined {let result; result = d.next(); return result;} export function isHandle(v: any): v is Handle {return typeof v === 'number';} @@ -51,16 +51,69 @@ export function asHandle(v: any): Handle { if (!isHandle(v)) {throw new TypeError(`Invalid Handle: ${_.stringify(v)}`);} else {return v;}; } -export function decodeHandle(d: _.TypedDecoder<_ptr>): Handle | undefined {return d.nextSignedInteger();} +export function decodeHandle(d: _.TypedDecoder<_ptr>): Handle | undefined {let result; result = d.nextSignedInteger(); return result;} -export function isEvent(v: any): v is Event {return (isAssert(v) || isRetract(v) || isMessage(v) || isSync(v));} +export function isEvent(v: any): v is Event { + return _.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) && ( + ( + ( + _.is(v.label, $assert) && ((v.length === 2) && isAssertion(v[0]) && isHandle(v[1])) + ) || + (_.is(v.label, $retract) && ((v.length === 1) && isHandle(v[0]))) || + (_.is(v.label, $message) && ((v.length === 1) && isAssertion(v[0]))) || + (_.is(v.label, $sync) && ((v.length === 1) && _.isPointer(v[0]))) + ) + ); +} export function asEvent(v: any): Event { if (!isEvent(v)) {throw new TypeError(`Invalid Event: ${_.stringify(v)}`);} else {return v;}; } export function decodeEvent(d: _.TypedDecoder<_ptr>): Event | undefined { - return (decodeAssert(d) ?? decodeRetract(d) ?? decodeMessage(d) ?? decodeSync(d)); + let result; + if (d.openRecord()) { + let _tmp0, _tmp1: any; + _tmp0 = d.next(); + _tmp1 = d.mark(); + if (_.is(_tmp0, $assert)) { + let _tmp2, _tmp3, _tmp4: any; + _tmp3 = decodeAssertion(d); + if (_tmp3 !== void 0) { + _tmp4 = decodeHandle(d); + if (_tmp4 !== void 0) {if (d.closeCompound()) _tmp2 = [_tmp3, _tmp4];}; + }; + if (_tmp2 !== void 0) result = _.Record<(typeof $assert), [Assertion, Handle]>(_tmp0 as any, _tmp2 as any); + }; + if (result === void 0) { + d.restoreMark(_tmp1); + if (_.is(_tmp0, $retract)) { + let _tmp5, _tmp6: any; + _tmp6 = decodeHandle(d); + if (_tmp6 !== void 0) {if (d.closeCompound()) _tmp5 = [_tmp6];}; + if (_tmp5 !== void 0) result = _.Record<(typeof $retract), [Handle]>(_tmp0 as any, _tmp5 as any); + }; + if (result === void 0) { + d.restoreMark(_tmp1); + if (_.is(_tmp0, $message)) { + let _tmp7, _tmp8: any; + _tmp8 = decodeAssertion(d); + if (_tmp8 !== void 0) {if (d.closeCompound()) _tmp7 = [_tmp8];}; + if (_tmp7 !== void 0) result = _.Record<(typeof $message), [Assertion]>(_tmp0 as any, _tmp7 as any); + }; + if (result === void 0) { + d.restoreMark(_tmp1); + if (_.is(_tmp0, $sync)) { + let _tmp9, _tmp10: any; + _tmp10 = _decodePtr(d); + if (_tmp10 !== void 0) {if (d.closeCompound()) _tmp9 = [_tmp10];}; + if (_tmp9 !== void 0) result = _.Record<(typeof $sync), [_ptr]>(_tmp0 as any, _tmp9 as any); + }; + }; + }; + }; + }; + return result; } export function isOid(v: any): v is Oid {return typeof v === 'number';} @@ -69,14 +122,14 @@ export function asOid(v: any): Oid { if (!isOid(v)) {throw new TypeError(`Invalid Oid: ${_.stringify(v)}`);} else {return v;}; } -export function decodeOid(d: _.TypedDecoder<_ptr>): Oid | undefined {return d.nextSignedInteger();} +export function decodeOid(d: _.TypedDecoder<_ptr>): Oid | undefined {let result; result = d.nextSignedInteger(); return result;} export function isTurn(v: any): v is Turn { return ( _.Array.isArray(v) && !_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) && (v.length >= 0) && - v.slice(0).every(v => ( + v.every(v => ( ( _.Array.isArray(v) && !_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) && @@ -93,22 +146,28 @@ export function asTurn(v: any): Turn { } export function decodeTurn(d: _.TypedDecoder<_ptr>): Turn | undefined { - return ((() => { - const M = d.mark(); - if (!d.openSequence()) return void 0; - const vN: Array<[Oid, Event]> = []; - let tmp: undefined | [Oid, Event]; - while ((tmp = ((() => { - const M = d.mark(); - if (!d.openSequence()) return void 0; - const v0 = decodeOid(d); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - const v1 = decodeEvent(d); if (v1 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0, v1] as [Oid, Event]; - })())) !== void 0) vN.push(tmp); - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return vN; - })()); + let result; + if (d.openSequence()) { + let _tmp11: any; + { + let vN: Array<[Oid, Event]> | undefined = []; + while (!d.closeCompound()) { + let _tmp12, _tmp13: any; + _tmp11 = void 0; + if (d.openSequence()) { + _tmp12 = decodeOid(d); + if (_tmp12 !== void 0) { + _tmp13 = decodeEvent(d); + if (_tmp13 !== void 0) {if (d.closeCompound()) _tmp11 = [_tmp12, _tmp13];}; + }; + }; + if (_tmp11 === void 0) {vN = void 0; break;}; + vN.push(_tmp11); + }; + result = vN; + }; + }; + return result; } export function isAssert(v: any): v is Assert { @@ -124,21 +183,21 @@ export function asAssert(v: any): Assert { } export function decodeAssert(d: _.TypedDecoder<_ptr>): Assert | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $assert); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - const v0 = decodeAssertion(d); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - const v1 = decodeHandle(d); if (v1 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0, v1] as [Assertion, Handle]; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $assert), [Assertion, Handle]>(L, Fs); - })()); + let result; + if (d.openRecord()) { + let _tmp14: any; + _tmp14 = _.asLiteral(d.nextSymbol(), $assert); + if (_tmp14 !== void 0) { + let _tmp15, _tmp16, _tmp17: any; + _tmp16 = decodeAssertion(d); + if (_tmp16 !== void 0) { + _tmp17 = decodeHandle(d); + if (_tmp17 !== void 0) {if (d.closeCompound()) _tmp15 = [_tmp16, _tmp17];}; + }; + if (_tmp15 !== void 0) result = _.Record<(typeof $assert), [Assertion, Handle]>(_tmp14 as any, _tmp15 as any); + }; + }; + return result; } export function isRetract(v: any): v is Retract { @@ -154,20 +213,18 @@ export function asRetract(v: any): Retract { } export function decodeRetract(d: _.TypedDecoder<_ptr>): Retract | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $retract); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - const v0 = decodeHandle(d); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0] as [Handle]; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $retract), [Handle]>(L, Fs); - })()); + let result; + if (d.openRecord()) { + let _tmp18: any; + _tmp18 = _.asLiteral(d.nextSymbol(), $retract); + if (_tmp18 !== void 0) { + let _tmp19, _tmp20: any; + _tmp20 = decodeHandle(d); + if (_tmp20 !== void 0) {if (d.closeCompound()) _tmp19 = [_tmp20];}; + if (_tmp19 !== void 0) result = _.Record<(typeof $retract), [Handle]>(_tmp18 as any, _tmp19 as any); + }; + }; + return result; } export function isMessage(v: any): v is Message { @@ -183,20 +240,18 @@ export function asMessage(v: any): Message { } export function decodeMessage(d: _.TypedDecoder<_ptr>): Message | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $message); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - const v0 = decodeAssertion(d); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0] as [Assertion]; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $message), [Assertion]>(L, Fs); - })()); + let result; + if (d.openRecord()) { + let _tmp21: any; + _tmp21 = _.asLiteral(d.nextSymbol(), $message); + if (_tmp21 !== void 0) { + let _tmp22, _tmp23: any; + _tmp23 = decodeAssertion(d); + if (_tmp23 !== void 0) {if (d.closeCompound()) _tmp22 = [_tmp23];}; + if (_tmp22 !== void 0) result = _.Record<(typeof $message), [Assertion]>(_tmp21 as any, _tmp22 as any); + }; + }; + return result; } export function isSync(v: any): v is Sync { @@ -212,21 +267,19 @@ export function asSync(v: any): Sync { } export function decodeSync(d: _.TypedDecoder<_ptr>): Sync | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $sync); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - const v0 = _decodePtr(d); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0] as [_ptr]; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $sync), [_ptr]>(L, Fs); - })()); + let result; + if (d.openRecord()) { + let _tmp24: any; + _tmp24 = _.asLiteral(d.nextSymbol(), $sync); + if (_tmp24 !== void 0) { + let _tmp25, _tmp26: any; + _tmp26 = _decodePtr(d); + if (_tmp26 !== void 0) {if (d.closeCompound()) _tmp25 = [_tmp26];}; + if (_tmp25 !== void 0) result = _.Record<(typeof $sync), [_ptr]>(_tmp24 as any, _tmp25 as any); + }; + }; + return result; } -export const _decodePtr = (d: _.TypedDecoder<_ptr>) => _i_Protocol.decodeWireRef(d); +export const _decodePtr = (d: _.TypedDecoder<_ptr>) => {let result; result = _i_Protocol.decodeWireRef(d); return result;}; diff --git a/src/gen/sturdy.ts b/src/gen/sturdy.ts index 99ef414..261eadc 100644 --- a/src/gen/sturdy.ts +++ b/src/gen/sturdy.ts @@ -109,7 +109,7 @@ export function isSturdyRef(v: any): v is SturdyRef { _.Array.isArray(v[1]) && !_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[1]) && (v[1].length >= 0) && - v[1].slice(0).every(v => (isAttenuation(v))) + v[1].every(v => (isAttenuation(v))) ) && _.Bytes.isBytes(v[2]) ) @@ -121,30 +121,36 @@ export function asSturdyRef(v: any): SturdyRef { } export function decodeSturdyRef(d: _.TypedDecoder<_ptr>): SturdyRef | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $ref); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - const v0 = d.next(); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - const v1 = ((() => { - const M = d.mark(); - if (!d.openSequence()) return void 0; - const vN: Array = []; - let tmp: undefined | Attenuation; - while ((tmp = decodeAttenuation(d)) !== void 0) vN.push(tmp); - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return vN; - })()); if (v1 === void 0) { d.restoreMark(M); return void 0; }; - const v2 = d.nextByteString(); if (v2 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0, v1, v2] as [_val, Array, _.Bytes]; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $ref), [_val, Array, _.Bytes]>(L, Fs); - })()); + 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 | 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, _.Bytes]>(_tmp0 as any, _tmp1 as any); + }; + }; + return result; } export function isAttenuation(v: any): v is Attenuation { @@ -152,7 +158,7 @@ export function isAttenuation(v: any): v is Attenuation { _.Array.isArray(v) && !_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) && (v.length >= 0) && - v.slice(0).every(v => (isCaveat(v))) + v.every(v => (isCaveat(v))) ); } @@ -161,24 +167,87 @@ export function asAttenuation(v: any): Attenuation { } export function decodeAttenuation(d: _.TypedDecoder<_ptr>): Attenuation | undefined { - return ((() => { - const M = d.mark(); - if (!d.openSequence()) return void 0; - const vN: Array = []; - let tmp: undefined | Caveat; - while ((tmp = decodeCaveat(d)) !== void 0) vN.push(tmp); - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return vN; - })()); + let result; + if (d.openSequence()) { + let _tmp6: any; + { + let vN: Array | 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 (isRewrite(v) || isAlts(v));} +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 {return (decodeRewrite(d) ?? decodeAlts(d));} +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 | 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]>(_tmp7 as any, _tmp12 as any); + }; + }; + }; + return result; +} export function isRewrite(v: any): v is Rewrite { return ( @@ -193,21 +262,21 @@ export function asRewrite(v: any): Rewrite { } export function decodeRewrite(d: _.TypedDecoder<_ptr>): Rewrite | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $rewrite); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - const v0 = decodePattern(d); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - const v1 = decodeTemplate(d); if (v1 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0, v1] as [Pattern, Template]; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $rewrite), [Pattern, Template]>(L, Fs); - })()); + 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 { @@ -220,7 +289,7 @@ export function isAlts(v: any): v is Alts { _.Array.isArray(v[0]) && !_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[0]) && (v[0].length >= 0) && - v[0].slice(0).every(v => (isRewrite(v))) + v[0].every(v => (isRewrite(v))) ) ) ); @@ -231,28 +300,30 @@ export function asAlts(v: any): Alts { } export function decodeAlts(d: _.TypedDecoder<_ptr>): Alts | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $or); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - const v0 = ((() => { - const M = d.mark(); - if (!d.openSequence()) return void 0; - const vN: Array = []; - let tmp: undefined | Rewrite; - while ((tmp = decodeRewrite(d)) !== void 0) vN.push(tmp); - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return vN; - })()); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0] as [Array]; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $or), [Array]>(L, Fs); - })()); + 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 | 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]>(_tmp19 as any, _tmp20 as any); + }; + }; + return result; } export function isResolve(v: any): v is Resolve { @@ -268,30 +339,72 @@ export function asResolve(v: any): Resolve { } export function decodeResolve(d: _.TypedDecoder<_ptr>): Resolve | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $resolve); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - const v0 = decodeSturdyRef(d); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - const v1 = _decodePtr(d); if (v1 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0, v1] as [SturdyRef, _ptr]; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $resolve), [SturdyRef, _ptr]>(L, Fs); - })()); + 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 (isCRec(v) || isCArr(v) || isCDict(v));} +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 {return (decodeCRec(d) ?? decodeCArr(d) ?? decodeCDict(d));} +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 ( @@ -306,21 +419,21 @@ export function asCRec(v: any): CRec { } export function decodeCRec(d: _.TypedDecoder<_ptr>): CRec | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $rec); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - const v0 = d.next(); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - const v1 = d.nextSignedInteger(); if (v1 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0, v1] as [_val, number]; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $rec), [_val, number]>(L, Fs); - })()); + 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 { @@ -336,20 +449,18 @@ export function asCArr(v: any): CArr { } export function decodeCArr(d: _.TypedDecoder<_ptr>): CArr | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $arr); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - const v0 = d.nextSignedInteger(); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0] as [number]; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $arr), [number]>(L, Fs); - })()); + 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 { @@ -365,19 +476,17 @@ export function asCDict(v: any): CDict { } export function decodeCDict(d: _.TypedDecoder<_ptr>): CDict | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $dict); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [] as []; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $dict), []>(L, Fs); - })()); + 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 { @@ -393,30 +502,54 @@ export function asLit(v: any): Lit { } export function decodeLit(d: _.TypedDecoder<_ptr>): Lit | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $lit); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - const v0 = d.next(); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0] as [_val]; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $lit), [_val]>(L, Fs); - })()); + 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 ( - isPDiscard(v) || - isPBind(v) || - isPAnd(v) || - isPNot(v) || - isLit(v) || - isPCompound(v) + 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; + })()) + ) + ) + ) + ) ); } @@ -425,14 +558,93 @@ export function asPattern(v: any): Pattern { } export function decodePattern(d: _.TypedDecoder<_ptr>): Pattern | undefined { - return ( - decodePDiscard(d) ?? - decodePBind(d) ?? - decodePAnd(d) ?? - decodePNot(d) ?? - decodeLit(d) ?? - decodePCompound(d) - ); + 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 | 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]>(_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 { @@ -448,19 +660,17 @@ export function asPDiscard(v: any): PDiscard { } export function decodePDiscard(d: _.TypedDecoder<_ptr>): PDiscard | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $__); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [] as []; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $__), []>(L, Fs); - })()); + 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 { @@ -476,21 +686,21 @@ export function asPBind(v: any): PBind { } export function decodePBind(d: _.TypedDecoder<_ptr>): PBind | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $bind); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - const v0 = d.nextSymbol(); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - const v1 = decodePattern(d); if (v1 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0, v1] as [symbol, Pattern]; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $bind), [symbol, Pattern]>(L, Fs); - })()); + 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 { @@ -503,7 +713,7 @@ export function isPAnd(v: any): v is PAnd { _.Array.isArray(v[0]) && !_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[0]) && (v[0].length >= 0) && - v[0].slice(0).every(v => (isPattern(v))) + v[0].every(v => (isPattern(v))) ) ) ); @@ -514,28 +724,30 @@ export function asPAnd(v: any): PAnd { } export function decodePAnd(d: _.TypedDecoder<_ptr>): PAnd | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $and); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - const v0 = ((() => { - const M = d.mark(); - if (!d.openSequence()) return void 0; - const vN: Array = []; - let tmp: undefined | Pattern; - while ((tmp = decodePattern(d)) !== void 0) vN.push(tmp); - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return vN; - })()); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0] as [Array]; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $and), [Array]>(L, Fs); - })()); + 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 | 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]>(_tmp69 as any, _tmp70 as any); + }; + }; + return result; } export function isPNot(v: any): v is PNot { @@ -551,20 +763,18 @@ export function asPNot(v: any): PNot { } export function decodePNot(d: _.TypedDecoder<_ptr>): PNot | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $not); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - const v0 = decodePattern(d); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0] as [Pattern]; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $not), [Pattern]>(L, Fs); - })()); + 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 { @@ -590,42 +800,109 @@ export function asPCompound(v: any): PCompound { } export function decodePCompound(d: _.TypedDecoder<_ptr>): PCompound | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $compound); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - const v0 = decodeConstructorSpec(d); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - const v1 = ((() => { - const M = d.mark(); - if (!d.openDictionary()) return void 0; - const r: _.KeyedDictionary<_val, Pattern, _ptr> = new _.KeyedDictionary(); - let K: undefined | _val; - while ((K = d.next()) !== void 0) { - const V = decodePattern(d); - if (V === void 0) { d.restoreMark(M); return void 0; }; - r.set(K, V); + 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 (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return r; - })()); if (v1 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0, v1] as [ConstructorSpec, _.KeyedDictionary<_val, Pattern, _ptr>]; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $compound), [ConstructorSpec, _.KeyedDictionary<_val, Pattern, _ptr>]>(L, Fs); - })()); + 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 (isTRef(v) || isLit(v) || isTCompound(v));} +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 {return (decodeTRef(d) ?? decodeLit(d) ?? decodeTCompound(d));} +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 ( @@ -640,20 +917,18 @@ export function asTRef(v: any): TRef { } export function decodeTRef(d: _.TypedDecoder<_ptr>): TRef | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $ref); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - const v0 = d.nextSymbol(); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0] as [symbol]; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $ref), [symbol]>(L, Fs); - })()); + 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 { @@ -679,34 +954,34 @@ export function asTCompound(v: any): TCompound { } export function decodeTCompound(d: _.TypedDecoder<_ptr>): TCompound | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $compound); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - const v0 = decodeConstructorSpec(d); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - const v1 = ((() => { - const M = d.mark(); - if (!d.openDictionary()) return void 0; - const r: _.KeyedDictionary<_val, Template, _ptr> = new _.KeyedDictionary(); - let K: undefined | _val; - while ((K = d.next()) !== void 0) { - const V = decodeTemplate(d); - if (V === void 0) { d.restoreMark(M); return void 0; }; - r.set(K, V); + 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 (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return r; - })()); if (v1 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0, v1] as [ConstructorSpec, _.KeyedDictionary<_val, Template, _ptr>]; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $compound), [ConstructorSpec, _.KeyedDictionary<_val, Template, _ptr>]>(L, Fs); - })()); + 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>) => _i_Actor.decodeRef(d); +export const _decodePtr = (d: _.TypedDecoder<_ptr>) => {let result; result = _i_Actor.decodeRef(d); return result;}; diff --git a/src/gen/worker.ts b/src/gen/worker.ts index c9f6825..92f2a43 100644 --- a/src/gen/worker.ts +++ b/src/gen/worker.ts @@ -24,21 +24,21 @@ export function asInstance(v: any): Instance { } export function decodeInstance(d: _.TypedDecoder<_ptr>): Instance | undefined { - return ((() => { - const M = d.mark(); - if (!d.openRecord()) return void 0; - const L = _.checkIs(d.nextSymbol(), $Instance); - if (L === void 0) { d.restoreMark(M); return void 0; }; - const Fs = (((() => { - const M = d.mark(); - const v0 = d.nextString(); if (v0 === void 0) { d.restoreMark(M); return void 0; }; - const v1 = d.next(); if (v1 === void 0) { d.restoreMark(M); return void 0; }; - if (!d.closeCompound()) { d.restoreMark(M); return void 0; }; - return [v0, v1] as [string, _val]; - })())) as any; - if (Fs === void 0) { d.restoreMark(M); return void 0; }; - return _.Record<(typeof $Instance), [string, _val]>(L, Fs); - })()); + let result; + if (d.openRecord()) { + let _tmp0: any; + _tmp0 = _.asLiteral(d.nextSymbol(), $Instance); + if (_tmp0 !== void 0) { + let _tmp1, _tmp2, _tmp3: any; + _tmp2 = d.nextString(); + if (_tmp2 !== void 0) { + _tmp3 = d.next(); + if (_tmp3 !== void 0) {if (d.closeCompound()) _tmp1 = [_tmp2, _tmp3];}; + }; + if (_tmp1 !== void 0) result = _.Record<(typeof $Instance), [string, _val]>(_tmp0 as any, _tmp1 as any); + }; + }; + return result; } export const _decodePtr = () => { throw new _.DecodeError("Pointers forbidden"); }; diff --git a/src/protocol.ts b/src/protocol.ts index 3ba1cda..b0281df 100644 --- a/src/protocol.ts +++ b/src/protocol.ts @@ -18,7 +18,6 @@ export function yourRef(oid: IO.Oid, attenuation: Attenuation): WireRef & { loc: } export function decodeWireRef(d: TypedDecoder): WireRef | undefined { - const M = d.mark(); if (d.openSequence()) { switch (d.nextSignedInteger()) { case 0: { @@ -46,6 +45,5 @@ export function decodeWireRef(d: TypedDecoder): WireRef | undefined { break; } } - d.restoreMark(M); return void 0; } diff --git a/src/relay.ts b/src/relay.ts index c2ba01f..6aef43a 100644 --- a/src/relay.ts +++ b/src/relay.ts @@ -1,10 +1,10 @@ import { Actor, Assertion, Entity, Handle, Ref, Turn } from './actor.js'; -import { Bytes, BytesLike, canonicalString, Decoder, encode, FlexMap, IdentityMap, mapPointers, underlying, Value } from '@preserves/core'; +import { BytesLike, canonicalString, Decoder, encode, FlexMap, IdentityMap, mapPointers, underlying, Value } from '@preserves/core'; import * as IO from './gen/protocol.js'; import { decodeWireRef, myRef, WireRef, WireSymbol, yourRef } from './protocol.js'; import { queueTask } from './task.js'; import { attenuate } from './rewrite.js'; -import { asAttenuation, Attenuation } from './gen/sturdy.js'; +import { Attenuation } from './gen/sturdy.js'; import { pointerNotAllowed } from './sturdy.js'; export class SyncPeerEntity implements Entity {