Regenerate from schema with better compiler

This commit is contained in:
Tony Garnock-Jones 2021-03-14 21:18:49 +01:00
parent a9c9def067
commit 346218f26a
7 changed files with 763 additions and 441 deletions

View File

@ -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;};

View File

@ -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;};

View File

@ -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;};

File diff suppressed because it is too large Load Diff

View File

@ -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"); };

View File

@ -18,7 +18,6 @@ export function yourRef(oid: IO.Oid, attenuation: Attenuation): WireRef & { loc:
}
export function decodeWireRef(d: TypedDecoder<WireRef>): WireRef | undefined {
const M = d.mark();
if (d.openSequence()) {
switch (d.nextSignedInteger()) {
case 0: {
@ -46,6 +45,5 @@ export function decodeWireRef(d: TypedDecoder<WireRef>): WireRef | undefined {
break;
}
}
d.restoreMark(M);
return void 0;
}

View File

@ -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 {