2021-03-10 22:15:53 +00:00
|
|
|
import * as _ from "@preserves/core";
|
|
|
|
|
|
|
|
export const $1 = 1;
|
|
|
|
export const $Boolean = Symbol.for("Boolean");
|
|
|
|
export const $ByteString = Symbol.for("ByteString");
|
|
|
|
export const $Double = Symbol.for("Double");
|
|
|
|
export const $Float = Symbol.for("Float");
|
|
|
|
export const $SignedInteger = Symbol.for("SignedInteger");
|
|
|
|
export const $String = Symbol.for("String");
|
|
|
|
export const $Symbol = Symbol.for("Symbol");
|
|
|
|
export const $and = Symbol.for("and");
|
|
|
|
export const $atom = Symbol.for("atom");
|
|
|
|
export const $definitions = Symbol.for("definitions");
|
|
|
|
export const $dict = Symbol.for("dict");
|
|
|
|
export const $dictof = Symbol.for("dictof");
|
|
|
|
export const $lit = Symbol.for("lit");
|
|
|
|
export const $named = Symbol.for("named");
|
|
|
|
export const $or = Symbol.for("or");
|
|
|
|
export const $pointer = Symbol.for("pointer");
|
|
|
|
export const $rec = Symbol.for("rec");
|
|
|
|
export const $ref = Symbol.for("ref");
|
|
|
|
export const $schema = Symbol.for("schema");
|
|
|
|
export const $setof = Symbol.for("setof");
|
|
|
|
export const $tuple = Symbol.for("tuple");
|
|
|
|
export const $tuple_STAR_ = Symbol.for("tuple*");
|
|
|
|
export const $version = Symbol.for("version");
|
2021-03-11 16:59:40 +00:00
|
|
|
export const __lit5 = false;
|
2021-03-10 22:15:53 +00:00
|
|
|
|
|
|
|
export const Schema = _.Record.makeConstructor<{
|
|
|
|
"details": (
|
|
|
|
{
|
|
|
|
get(k: typeof $version): Version;
|
2021-03-11 16:59:40 +00:00
|
|
|
get(k: typeof $pointer): PointerName;
|
2021-03-12 10:14:39 +00:00
|
|
|
get(k: typeof $definitions): _.KeyedDictionary<symbol, Pattern, _ptr>;
|
2021-03-10 22:15:53 +00:00
|
|
|
has(k: typeof $version): true;
|
2021-03-11 16:59:40 +00:00
|
|
|
has(k: typeof $pointer): true;
|
2021-03-10 22:15:53 +00:00
|
|
|
has(k: typeof $definitions): true;
|
2021-03-11 16:59:40 +00:00
|
|
|
} & _.Dictionary<_val, _ptr>
|
2021-03-10 22:15:53 +00:00
|
|
|
)
|
2021-03-11 16:59:40 +00:00
|
|
|
}, _ptr>()($schema, ["details"]);
|
2021-03-10 22:15:53 +00:00
|
|
|
|
|
|
|
export type Schema = _.Record<
|
|
|
|
(typeof $schema),
|
|
|
|
[
|
|
|
|
(
|
|
|
|
{
|
|
|
|
get(k: typeof $version): Version;
|
2021-03-11 16:59:40 +00:00
|
|
|
get(k: typeof $pointer): PointerName;
|
2021-03-12 10:14:39 +00:00
|
|
|
get(k: typeof $definitions): _.KeyedDictionary<symbol, Pattern, _ptr>;
|
2021-03-10 22:15:53 +00:00
|
|
|
has(k: typeof $version): true;
|
2021-03-11 16:59:40 +00:00
|
|
|
has(k: typeof $pointer): true;
|
2021-03-10 22:15:53 +00:00
|
|
|
has(k: typeof $definitions): true;
|
2021-03-11 16:59:40 +00:00
|
|
|
} & _.Dictionary<_val, _ptr>
|
2021-03-10 22:15:53 +00:00
|
|
|
)
|
2021-03-11 16:59:40 +00:00
|
|
|
],
|
|
|
|
_ptr
|
2021-03-10 22:15:53 +00:00
|
|
|
>;
|
|
|
|
|
|
|
|
export type Version = (typeof $1);
|
|
|
|
|
2021-03-11 16:59:40 +00:00
|
|
|
export type PointerName = (Ref | (typeof __lit5));
|
|
|
|
|
2021-03-10 22:15:53 +00:00
|
|
|
export type Pattern = (
|
|
|
|
_.Record<
|
|
|
|
(typeof $atom),
|
|
|
|
[
|
|
|
|
(
|
|
|
|
(typeof $Boolean) |
|
|
|
|
(typeof $Float) |
|
|
|
|
(typeof $Double) |
|
|
|
|
(typeof $SignedInteger) |
|
|
|
|
(typeof $String) |
|
|
|
|
(typeof $ByteString) |
|
|
|
|
(typeof $Symbol)
|
|
|
|
)
|
2021-03-11 16:59:40 +00:00
|
|
|
],
|
|
|
|
_ptr
|
2021-03-10 22:15:53 +00:00
|
|
|
> |
|
2021-03-11 16:59:40 +00:00
|
|
|
_.Record<(typeof $pointer), [], _ptr> |
|
|
|
|
_.Record<(typeof $lit), [_val], _ptr> |
|
2021-03-11 09:56:49 +00:00
|
|
|
Ref |
|
2021-03-11 16:59:40 +00:00
|
|
|
_.Record<(typeof $or), [Array<Pattern>], _ptr> |
|
|
|
|
_.Record<(typeof $and), [Array<Pattern>], _ptr> |
|
|
|
|
_.Record<(typeof $rec), [Pattern, Pattern], _ptr> |
|
|
|
|
_.Record<(typeof $tuple), [Array<NamedPattern>], _ptr> |
|
|
|
|
_.Record<(typeof $tuple_STAR_), [Array<NamedPattern>, NamedPattern], _ptr> |
|
|
|
|
_.Record<(typeof $setof), [Pattern], _ptr> |
|
|
|
|
_.Record<(typeof $dictof), [Pattern, Pattern], _ptr> |
|
2021-03-12 10:14:39 +00:00
|
|
|
_.Record<(typeof $dict), [_.KeyedDictionary<_val, Pattern, _ptr>], _ptr>
|
2021-03-10 22:15:53 +00:00
|
|
|
);
|
|
|
|
|
2021-03-11 16:59:40 +00:00
|
|
|
export type NamedPattern = (_.Record<(typeof $named), [symbol, Pattern], _ptr> | Pattern);
|
2021-03-10 22:15:53 +00:00
|
|
|
|
2021-03-14 21:59:53 +00:00
|
|
|
export const Ref = _.Record.makeConstructor<{"module": ModulePath, "name": symbol}, _ptr>()($ref, ["module","name"]);
|
2021-03-11 09:56:49 +00:00
|
|
|
|
2021-03-14 21:59:53 +00:00
|
|
|
export type Ref = _.Record<(typeof $ref), [ModulePath, symbol], _ptr>;
|
2021-03-11 09:56:49 +00:00
|
|
|
|
|
|
|
export type ModulePath = Array<symbol>;
|
2021-03-12 10:14:39 +00:00
|
|
|
|
|
|
|
export type _ptr = never;
|
|
|
|
|
|
|
|
export type _val = _.Value<_ptr>;
|
2021-03-11 09:56:49 +00:00
|
|
|
|
2021-03-10 22:15:53 +00:00
|
|
|
|
|
|
|
export function isSchema(v: any): v is Schema {
|
2021-03-11 16:59:40 +00:00
|
|
|
let _tmp0, _tmp1, _tmp2: any;
|
2021-03-10 22:15:53 +00:00
|
|
|
return (
|
2021-03-11 16:59:40 +00:00
|
|
|
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
|
2021-03-14 20:13:40 +00:00
|
|
|
_.is(v.label, $schema) &&
|
2021-03-10 22:15:53 +00:00
|
|
|
(
|
|
|
|
(v.length === 1) &&
|
|
|
|
(
|
2021-03-11 16:59:40 +00:00
|
|
|
_.Dictionary.isDictionary<_val, _ptr>(v[0]) &&
|
2021-03-10 22:15:53 +00:00
|
|
|
((_tmp0 = v[0].get($version)) !== void 0 && isVersion(_tmp0)) &&
|
2021-03-11 16:59:40 +00:00
|
|
|
((_tmp1 = v[0].get($pointer)) !== void 0 && isPointerName(_tmp1)) &&
|
2021-03-10 22:15:53 +00:00
|
|
|
(
|
2021-03-11 16:59:40 +00:00
|
|
|
(_tmp2 = v[0].get($definitions)) !== void 0 && (
|
|
|
|
_.Dictionary.isDictionary<_val, _ptr>(_tmp2) &&
|
2021-03-10 22:15:53 +00:00
|
|
|
((() => {
|
2021-03-11 16:59:40 +00:00
|
|
|
for (const e of _tmp2) {
|
2021-03-10 22:15:53 +00:00
|
|
|
if (!(typeof e[0] === 'symbol')) return false;
|
|
|
|
if (!(isPattern(e[1]))) return false;
|
|
|
|
};
|
|
|
|
return true;
|
|
|
|
})())
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-03-11 16:59:40 +00:00
|
|
|
export function asSchema(v: any): Schema {
|
|
|
|
if (!isSchema(v)) {throw new TypeError(`Invalid Schema: ${_.stringify(v)}`);} else {return v;};
|
|
|
|
}
|
2021-03-11 08:25:17 +00:00
|
|
|
|
2021-03-12 19:41:35 +00:00
|
|
|
export function decodeSchema(d: _.TypedDecoder<_ptr>): Schema | undefined {
|
2021-03-14 20:10:47 +00:00
|
|
|
let result;
|
|
|
|
if (d.openRecord()) {
|
|
|
|
let _tmp3: any;
|
|
|
|
_tmp3 = _.asLiteral(d.nextSymbol(), $schema);
|
|
|
|
if (_tmp3 !== void 0) {
|
|
|
|
let _tmp4, _tmp5, _tmp6, _tmp7, _tmp8: any;
|
|
|
|
_tmp5 = d.next();
|
|
|
|
if (_tmp5 !== void 0 && !((
|
|
|
|
_.Dictionary.isDictionary<_val, _ptr>(_tmp5) &&
|
|
|
|
((_tmp6 = _tmp5.get($version)) !== void 0 && isVersion(_tmp6)) &&
|
|
|
|
((_tmp7 = _tmp5.get($pointer)) !== void 0 && isPointerName(_tmp7)) &&
|
2021-03-12 19:41:35 +00:00
|
|
|
(
|
2021-03-14 20:10:47 +00:00
|
|
|
(_tmp8 = _tmp5.get($definitions)) !== void 0 && (
|
|
|
|
_.Dictionary.isDictionary<_val, _ptr>(_tmp8) &&
|
|
|
|
((() => {
|
|
|
|
for (const e of _tmp8) {
|
|
|
|
if (!(typeof e[0] === 'symbol')) return false;
|
|
|
|
if (!(isPattern(e[1]))) return false;
|
|
|
|
};
|
|
|
|
return true;
|
|
|
|
})())
|
|
|
|
)
|
2021-03-12 19:41:35 +00:00
|
|
|
)
|
2021-03-14 20:10:47 +00:00
|
|
|
))) _tmp5 = void 0;
|
|
|
|
if (_tmp5 !== void 0) {if (d.closeCompound()) _tmp4 = [_tmp5];};
|
|
|
|
if (_tmp4 !== void 0) result = _.Record<
|
|
|
|
(typeof $schema),
|
|
|
|
[
|
|
|
|
(
|
|
|
|
{
|
|
|
|
get(k: typeof $version): Version;
|
|
|
|
get(k: typeof $pointer): PointerName;
|
|
|
|
get(k: typeof $definitions): _.KeyedDictionary<symbol, Pattern, _ptr>;
|
|
|
|
has(k: typeof $version): true;
|
|
|
|
has(k: typeof $pointer): true;
|
|
|
|
has(k: typeof $definitions): true;
|
|
|
|
} & _.Dictionary<_val, _ptr>
|
|
|
|
)
|
|
|
|
]
|
|
|
|
>(_tmp3 as any, _tmp4 as any);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
return result;
|
2021-03-12 19:41:35 +00:00
|
|
|
}
|
|
|
|
|
2021-03-14 20:13:40 +00:00
|
|
|
export function isVersion(v: any): v is Version {return _.is(v, $1);}
|
2021-03-10 22:15:53 +00:00
|
|
|
|
2021-03-11 16:59:40 +00:00
|
|
|
export function asVersion(v: any): Version {
|
|
|
|
if (!isVersion(v)) {throw new TypeError(`Invalid Version: ${_.stringify(v)}`);} else {return v;};
|
|
|
|
}
|
|
|
|
|
2021-03-14 20:10:47 +00:00
|
|
|
export function decodeVersion(d: _.TypedDecoder<_ptr>): Version | undefined {let result; result = _.asLiteral(d.nextSignedInteger(), $1); return result;}
|
2021-03-12 19:41:35 +00:00
|
|
|
|
2021-03-14 20:13:40 +00:00
|
|
|
export function isPointerName(v: any): v is PointerName {return (isRef(v) || _.is(v, __lit5));}
|
2021-03-11 16:59:40 +00:00
|
|
|
|
|
|
|
export function asPointerName(v: any): PointerName {
|
|
|
|
if (!isPointerName(v)) {throw new TypeError(`Invalid PointerName: ${_.stringify(v)}`);} else {return v;};
|
|
|
|
}
|
2021-03-11 08:25:17 +00:00
|
|
|
|
2021-03-14 20:10:47 +00:00
|
|
|
export function decodePointerName(d: _.TypedDecoder<_ptr>): PointerName | undefined {
|
|
|
|
let _tmp9: any;
|
|
|
|
let result;
|
|
|
|
_tmp9 = d.mark();
|
|
|
|
result = decodeRef(d);
|
|
|
|
if (result === void 0) {d.restoreMark(_tmp9); result = _.asLiteral(d.nextBoolean(), __lit5);};
|
|
|
|
return result;
|
|
|
|
}
|
2021-03-12 19:41:35 +00:00
|
|
|
|
2021-03-10 22:15:53 +00:00
|
|
|
export function isPattern(v: any): v is Pattern {
|
2021-03-14 20:10:47 +00:00
|
|
|
return _.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) && (
|
2021-03-10 22:15:53 +00:00
|
|
|
(
|
|
|
|
(
|
2021-03-14 20:13:40 +00:00
|
|
|
_.is(v.label, $atom) && (
|
2021-03-14 20:10:47 +00:00
|
|
|
(v.length === 1) &&
|
|
|
|
(
|
2021-03-14 20:13:40 +00:00
|
|
|
_.is(v[0], $Boolean) ||
|
|
|
|
_.is(v[0], $Float) ||
|
|
|
|
_.is(v[0], $Double) ||
|
|
|
|
_.is(v[0], $SignedInteger) ||
|
|
|
|
_.is(v[0], $String) ||
|
|
|
|
_.is(v[0], $ByteString) ||
|
|
|
|
_.is(v[0], $Symbol)
|
2021-03-14 20:10:47 +00:00
|
|
|
)
|
2021-03-10 22:15:53 +00:00
|
|
|
)
|
2021-03-14 20:10:47 +00:00
|
|
|
) ||
|
2021-03-14 20:13:40 +00:00
|
|
|
(_.is(v.label, $pointer) && ((v.length === 0))) ||
|
|
|
|
(_.is(v.label, $lit) && ((v.length === 1) && true)) ||
|
2021-03-10 22:15:53 +00:00
|
|
|
(
|
2021-03-14 21:59:53 +00:00
|
|
|
_.is(v.label, $ref) && ((v.length === 2) && isModulePath(v[0]) && typeof v[1] === 'symbol')
|
2021-03-14 20:10:47 +00:00
|
|
|
) ||
|
|
|
|
(
|
2021-03-14 20:13:40 +00:00
|
|
|
_.is(v.label, $or) && (
|
2021-03-14 20:10:47 +00:00
|
|
|
(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)))
|
|
|
|
)
|
2021-03-10 22:15:53 +00:00
|
|
|
)
|
2021-03-14 20:10:47 +00:00
|
|
|
) ||
|
2021-03-10 22:15:53 +00:00
|
|
|
(
|
2021-03-14 20:13:40 +00:00
|
|
|
_.is(v.label, $and) && (
|
2021-03-14 20:10:47 +00:00
|
|
|
(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)))
|
|
|
|
)
|
2021-03-10 22:15:53 +00:00
|
|
|
)
|
2021-03-14 20:10:47 +00:00
|
|
|
) ||
|
2021-03-10 22:15:53 +00:00
|
|
|
(
|
2021-03-14 20:13:40 +00:00
|
|
|
_.is(v.label, $rec) && ((v.length === 2) && isPattern(v[0]) && isPattern(v[1]))
|
2021-03-14 20:10:47 +00:00
|
|
|
) ||
|
|
|
|
(
|
2021-03-14 20:13:40 +00:00
|
|
|
_.is(v.label, $tuple) && (
|
2021-03-14 20:10:47 +00:00
|
|
|
(v.length === 1) &&
|
|
|
|
(
|
|
|
|
_.Array.isArray(v[0]) &&
|
|
|
|
!_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[0]) &&
|
|
|
|
(v[0].length >= 0) &&
|
|
|
|
v[0].every(v => (isNamedPattern(v)))
|
|
|
|
)
|
2021-03-10 22:15:53 +00:00
|
|
|
)
|
2021-03-14 20:10:47 +00:00
|
|
|
) ||
|
2021-03-10 22:15:53 +00:00
|
|
|
(
|
2021-03-14 20:13:40 +00:00
|
|
|
_.is(v.label, $tuple_STAR_) && (
|
2021-03-14 20:10:47 +00:00
|
|
|
(v.length === 2) &&
|
|
|
|
(
|
|
|
|
_.Array.isArray(v[0]) &&
|
|
|
|
!_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v[0]) &&
|
|
|
|
(v[0].length >= 0) &&
|
|
|
|
v[0].every(v => (isNamedPattern(v)))
|
|
|
|
) &&
|
|
|
|
isNamedPattern(v[1])
|
|
|
|
)
|
|
|
|
) ||
|
2021-03-14 20:13:40 +00:00
|
|
|
(_.is(v.label, $setof) && ((v.length === 1) && isPattern(v[0]))) ||
|
2021-03-10 22:15:53 +00:00
|
|
|
(
|
2021-03-14 20:13:40 +00:00
|
|
|
_.is(v.label, $dictof) && ((v.length === 2) && isPattern(v[0]) && isPattern(v[1]))
|
2021-03-14 20:10:47 +00:00
|
|
|
) ||
|
|
|
|
(
|
2021-03-14 20:13:40 +00:00
|
|
|
_.is(v.label, $dict) && (
|
2021-03-14 20:10:47 +00:00
|
|
|
(v.length === 1) &&
|
|
|
|
(
|
|
|
|
_.Dictionary.isDictionary<_val, _ptr>(v[0]) &&
|
|
|
|
((() => {
|
|
|
|
for (const e of v[0]) {if (!(true)) return false; if (!(isPattern(e[1]))) return false;};
|
|
|
|
return true;
|
|
|
|
})())
|
|
|
|
)
|
2021-03-10 22:15:53 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-03-11 16:59:40 +00:00
|
|
|
export function asPattern(v: any): Pattern {
|
|
|
|
if (!isPattern(v)) {throw new TypeError(`Invalid Pattern: ${_.stringify(v)}`);} else {return v;};
|
|
|
|
}
|
2021-03-11 08:25:17 +00:00
|
|
|
|
2021-03-12 19:41:35 +00:00
|
|
|
export function decodePattern(d: _.TypedDecoder<_ptr>): Pattern | undefined {
|
2021-03-14 20:10:47 +00:00
|
|
|
let result;
|
|
|
|
if (d.openRecord()) {
|
|
|
|
let _tmp10, _tmp11: any;
|
|
|
|
_tmp10 = d.next();
|
|
|
|
_tmp11 = d.mark();
|
2021-03-14 20:13:40 +00:00
|
|
|
if (_.is(_tmp10, $atom)) {
|
2021-03-14 20:10:47 +00:00
|
|
|
let _tmp12, _tmp13, _tmp14: any;
|
|
|
|
_tmp14 = d.mark();
|
|
|
|
_tmp13 = _.asLiteral(d.nextSymbol(), $Boolean);
|
|
|
|
if (_tmp13 === void 0) {
|
|
|
|
d.restoreMark(_tmp14);
|
|
|
|
_tmp13 = _.asLiteral(d.nextSymbol(), $Float);
|
|
|
|
if (_tmp13 === void 0) {
|
|
|
|
d.restoreMark(_tmp14);
|
|
|
|
_tmp13 = _.asLiteral(d.nextSymbol(), $Double);
|
|
|
|
if (_tmp13 === void 0) {
|
|
|
|
d.restoreMark(_tmp14);
|
|
|
|
_tmp13 = _.asLiteral(d.nextSymbol(), $SignedInteger);
|
|
|
|
if (_tmp13 === void 0) {
|
|
|
|
d.restoreMark(_tmp14);
|
|
|
|
_tmp13 = _.asLiteral(d.nextSymbol(), $String);
|
|
|
|
if (_tmp13 === void 0) {
|
|
|
|
d.restoreMark(_tmp14);
|
|
|
|
_tmp13 = _.asLiteral(d.nextSymbol(), $ByteString);
|
|
|
|
if (_tmp13 === void 0) {d.restoreMark(_tmp14); _tmp13 = _.asLiteral(d.nextSymbol(), $Symbol);};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if (_tmp13 !== void 0) {if (d.closeCompound()) _tmp12 = [_tmp13];};
|
|
|
|
if (_tmp12 !== void 0) result = _.Record<
|
2021-03-12 19:41:35 +00:00
|
|
|
(typeof $atom),
|
|
|
|
[
|
|
|
|
(
|
|
|
|
(typeof $Boolean) |
|
|
|
|
(typeof $Float) |
|
|
|
|
(typeof $Double) |
|
|
|
|
(typeof $SignedInteger) |
|
|
|
|
(typeof $String) |
|
|
|
|
(typeof $ByteString) |
|
|
|
|
(typeof $Symbol)
|
|
|
|
)
|
|
|
|
]
|
2021-03-14 20:10:47 +00:00
|
|
|
>(_tmp10 as any, _tmp12 as any);
|
|
|
|
};
|
|
|
|
if (result === void 0) {
|
|
|
|
d.restoreMark(_tmp11);
|
2021-03-14 20:13:40 +00:00
|
|
|
if (_.is(_tmp10, $pointer)) {
|
2021-03-14 20:10:47 +00:00
|
|
|
let _tmp15: any;
|
|
|
|
if (d.closeCompound()) _tmp15 = [];
|
|
|
|
if (_tmp15 !== void 0) result = _.Record<(typeof $pointer), []>(_tmp10 as any, _tmp15 as any);
|
|
|
|
};
|
|
|
|
if (result === void 0) {
|
|
|
|
d.restoreMark(_tmp11);
|
2021-03-14 20:13:40 +00:00
|
|
|
if (_.is(_tmp10, $lit)) {
|
2021-03-14 20:10:47 +00:00
|
|
|
let _tmp16, _tmp17: any;
|
|
|
|
_tmp17 = d.next();
|
|
|
|
if (_tmp17 !== void 0) {if (d.closeCompound()) _tmp16 = [_tmp17];};
|
|
|
|
if (_tmp16 !== void 0) result = _.Record<(typeof $lit), [_val]>(_tmp10 as any, _tmp16 as any);
|
|
|
|
};
|
|
|
|
if (result === void 0) {
|
|
|
|
d.restoreMark(_tmp11);
|
2021-03-14 20:13:40 +00:00
|
|
|
if (_.is(_tmp10, $ref)) {
|
2021-03-14 20:10:47 +00:00
|
|
|
let _tmp18, _tmp19, _tmp20: any;
|
2021-03-14 21:59:53 +00:00
|
|
|
_tmp19 = decodeModulePath(d);
|
2021-03-14 20:10:47 +00:00
|
|
|
if (_tmp19 !== void 0) {
|
|
|
|
_tmp20 = d.nextSymbol();
|
|
|
|
if (_tmp20 !== void 0) {if (d.closeCompound()) _tmp18 = [_tmp19, _tmp20];};
|
|
|
|
};
|
2021-03-14 21:59:53 +00:00
|
|
|
if (_tmp18 !== void 0) result = _.Record<(typeof $ref), [ModulePath, symbol]>(_tmp10 as any, _tmp18 as any);
|
2021-03-12 19:41:35 +00:00
|
|
|
};
|
2021-03-14 20:10:47 +00:00
|
|
|
if (result === void 0) {
|
|
|
|
d.restoreMark(_tmp11);
|
2021-03-14 20:13:40 +00:00
|
|
|
if (_.is(_tmp10, $or)) {
|
2021-03-14 20:10:47 +00:00
|
|
|
let _tmp21, _tmp22: any;
|
|
|
|
if (d.openSequence()) {
|
|
|
|
let _tmp23: any;
|
|
|
|
{
|
|
|
|
let vN: Array<Pattern> | undefined = [];
|
|
|
|
while (!d.closeCompound()) {
|
|
|
|
_tmp23 = void 0;
|
|
|
|
_tmp23 = decodePattern(d);
|
|
|
|
if (_tmp23 === void 0) {vN = void 0; break;};
|
|
|
|
vN.push(_tmp23);
|
|
|
|
};
|
|
|
|
_tmp22 = vN;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if (_tmp22 !== void 0) {if (d.closeCompound()) _tmp21 = [_tmp22];};
|
|
|
|
if (_tmp21 !== void 0) result = _.Record<(typeof $or), [Array<Pattern>]>(_tmp10 as any, _tmp21 as any);
|
|
|
|
};
|
|
|
|
if (result === void 0) {
|
|
|
|
d.restoreMark(_tmp11);
|
2021-03-14 20:13:40 +00:00
|
|
|
if (_.is(_tmp10, $and)) {
|
2021-03-14 20:10:47 +00:00
|
|
|
let _tmp24, _tmp25: any;
|
|
|
|
if (d.openSequence()) {
|
|
|
|
let _tmp26: any;
|
|
|
|
{
|
|
|
|
let vN: Array<Pattern> | undefined = [];
|
|
|
|
while (!d.closeCompound()) {
|
|
|
|
_tmp26 = void 0;
|
|
|
|
_tmp26 = decodePattern(d);
|
|
|
|
if (_tmp26 === void 0) {vN = void 0; break;};
|
|
|
|
vN.push(_tmp26);
|
|
|
|
};
|
|
|
|
_tmp25 = vN;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if (_tmp25 !== void 0) {if (d.closeCompound()) _tmp24 = [_tmp25];};
|
|
|
|
if (_tmp24 !== void 0) result = _.Record<(typeof $and), [Array<Pattern>]>(_tmp10 as any, _tmp24 as any);
|
|
|
|
};
|
|
|
|
if (result === void 0) {
|
|
|
|
d.restoreMark(_tmp11);
|
2021-03-14 20:13:40 +00:00
|
|
|
if (_.is(_tmp10, $rec)) {
|
2021-03-14 20:10:47 +00:00
|
|
|
let _tmp27, _tmp28, _tmp29: any;
|
|
|
|
_tmp28 = decodePattern(d);
|
|
|
|
if (_tmp28 !== void 0) {
|
|
|
|
_tmp29 = decodePattern(d);
|
|
|
|
if (_tmp29 !== void 0) {if (d.closeCompound()) _tmp27 = [_tmp28, _tmp29];};
|
|
|
|
};
|
|
|
|
if (_tmp27 !== void 0) result = _.Record<(typeof $rec), [Pattern, Pattern]>(_tmp10 as any, _tmp27 as any);
|
|
|
|
};
|
|
|
|
if (result === void 0) {
|
|
|
|
d.restoreMark(_tmp11);
|
2021-03-14 20:13:40 +00:00
|
|
|
if (_.is(_tmp10, $tuple)) {
|
2021-03-14 20:10:47 +00:00
|
|
|
let _tmp30, _tmp31: any;
|
|
|
|
if (d.openSequence()) {
|
|
|
|
let _tmp32: any;
|
|
|
|
{
|
|
|
|
let vN: Array<NamedPattern> | undefined = [];
|
|
|
|
while (!d.closeCompound()) {
|
|
|
|
_tmp32 = void 0;
|
|
|
|
_tmp32 = decodeNamedPattern(d);
|
|
|
|
if (_tmp32 === void 0) {vN = void 0; break;};
|
|
|
|
vN.push(_tmp32);
|
|
|
|
};
|
|
|
|
_tmp31 = vN;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if (_tmp31 !== void 0) {if (d.closeCompound()) _tmp30 = [_tmp31];};
|
|
|
|
if (_tmp30 !== void 0) result = _.Record<(typeof $tuple), [Array<NamedPattern>]>(_tmp10 as any, _tmp30 as any);
|
|
|
|
};
|
|
|
|
if (result === void 0) {
|
|
|
|
d.restoreMark(_tmp11);
|
2021-03-14 20:13:40 +00:00
|
|
|
if (_.is(_tmp10, $tuple_STAR_)) {
|
2021-03-14 20:10:47 +00:00
|
|
|
let _tmp33, _tmp34, _tmp35: any;
|
|
|
|
if (d.openSequence()) {
|
|
|
|
let _tmp36: any;
|
|
|
|
{
|
|
|
|
let vN: Array<NamedPattern> | undefined = [];
|
|
|
|
while (!d.closeCompound()) {
|
|
|
|
_tmp36 = void 0;
|
|
|
|
_tmp36 = decodeNamedPattern(d);
|
|
|
|
if (_tmp36 === void 0) {vN = void 0; break;};
|
|
|
|
vN.push(_tmp36);
|
|
|
|
};
|
|
|
|
_tmp34 = vN;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if (_tmp34 !== void 0) {
|
|
|
|
_tmp35 = decodeNamedPattern(d);
|
|
|
|
if (_tmp35 !== void 0) {if (d.closeCompound()) _tmp33 = [_tmp34, _tmp35];};
|
|
|
|
};
|
|
|
|
if (_tmp33 !== void 0) result = _.Record<(typeof $tuple_STAR_), [Array<NamedPattern>, NamedPattern]>(_tmp10 as any, _tmp33 as any);
|
|
|
|
};
|
|
|
|
if (result === void 0) {
|
|
|
|
d.restoreMark(_tmp11);
|
2021-03-14 20:13:40 +00:00
|
|
|
if (_.is(_tmp10, $setof)) {
|
2021-03-14 20:10:47 +00:00
|
|
|
let _tmp37, _tmp38: any;
|
|
|
|
_tmp38 = decodePattern(d);
|
|
|
|
if (_tmp38 !== void 0) {if (d.closeCompound()) _tmp37 = [_tmp38];};
|
|
|
|
if (_tmp37 !== void 0) result = _.Record<(typeof $setof), [Pattern]>(_tmp10 as any, _tmp37 as any);
|
|
|
|
};
|
|
|
|
if (result === void 0) {
|
|
|
|
d.restoreMark(_tmp11);
|
2021-03-14 20:13:40 +00:00
|
|
|
if (_.is(_tmp10, $dictof)) {
|
2021-03-14 20:10:47 +00:00
|
|
|
let _tmp39, _tmp40, _tmp41: any;
|
|
|
|
_tmp40 = decodePattern(d);
|
|
|
|
if (_tmp40 !== void 0) {
|
|
|
|
_tmp41 = decodePattern(d);
|
|
|
|
if (_tmp41 !== void 0) {if (d.closeCompound()) _tmp39 = [_tmp40, _tmp41];};
|
|
|
|
};
|
|
|
|
if (_tmp39 !== void 0) result = _.Record<(typeof $dictof), [Pattern, Pattern]>(_tmp10 as any, _tmp39 as any);
|
|
|
|
};
|
|
|
|
if (result === void 0) {
|
|
|
|
d.restoreMark(_tmp11);
|
2021-03-14 20:13:40 +00:00
|
|
|
if (_.is(_tmp10, $dict)) {
|
2021-03-14 20:10:47 +00:00
|
|
|
let _tmp42, _tmp43: any;
|
|
|
|
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);
|
|
|
|
};
|
|
|
|
_tmp43 = r;
|
|
|
|
};
|
|
|
|
if (_tmp43 !== void 0) {if (d.closeCompound()) _tmp42 = [_tmp43];};
|
|
|
|
if (_tmp42 !== void 0) result = _.Record<(typeof $dict), [_.KeyedDictionary<_val, Pattern, _ptr>]>(_tmp10 as any, _tmp42 as any);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
return result;
|
2021-03-12 19:41:35 +00:00
|
|
|
}
|
|
|
|
|
2021-03-10 22:15:53 +00:00
|
|
|
export function isNamedPattern(v: any): v is NamedPattern {
|
|
|
|
return (
|
|
|
|
(
|
2021-03-11 16:59:40 +00:00
|
|
|
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
|
2021-03-14 20:13:40 +00:00
|
|
|
_.is(v.label, $named) &&
|
2021-03-10 22:15:53 +00:00
|
|
|
((v.length === 2) && typeof v[0] === 'symbol' && isPattern(v[1]))
|
|
|
|
) ||
|
|
|
|
isPattern(v)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-03-11 08:25:17 +00:00
|
|
|
export function asNamedPattern(v: any): NamedPattern {
|
2021-03-11 16:59:40 +00:00
|
|
|
if (!isNamedPattern(v)) {throw new TypeError(`Invalid NamedPattern: ${_.stringify(v)}`);} else {return v;};
|
2021-03-11 08:25:17 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 19:41:35 +00:00
|
|
|
export function decodeNamedPattern(d: _.TypedDecoder<_ptr>): NamedPattern | undefined {
|
2021-03-14 20:10:47 +00:00
|
|
|
let _tmp44: any;
|
|
|
|
let result;
|
|
|
|
_tmp44 = d.mark();
|
|
|
|
if (d.openRecord()) {
|
|
|
|
let _tmp45: any;
|
|
|
|
_tmp45 = _.asLiteral(d.nextSymbol(), $named);
|
|
|
|
if (_tmp45 !== void 0) {
|
|
|
|
let _tmp46, _tmp47, _tmp48: any;
|
|
|
|
_tmp47 = d.nextSymbol();
|
|
|
|
if (_tmp47 !== void 0) {
|
|
|
|
_tmp48 = decodePattern(d);
|
|
|
|
if (_tmp48 !== void 0) {if (d.closeCompound()) _tmp46 = [_tmp47, _tmp48];};
|
|
|
|
};
|
|
|
|
if (_tmp46 !== void 0) result = _.Record<(typeof $named), [symbol, Pattern]>(_tmp45 as any, _tmp46 as any);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if (result === void 0) {d.restoreMark(_tmp44); result = decodePattern(d);};
|
|
|
|
return result;
|
2021-03-12 19:41:35 +00:00
|
|
|
}
|
|
|
|
|
2021-03-11 09:56:49 +00:00
|
|
|
export function isRef(v: any): v is Ref {
|
|
|
|
return (
|
2021-03-11 16:59:40 +00:00
|
|
|
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
|
2021-03-14 20:13:40 +00:00
|
|
|
_.is(v.label, $ref) &&
|
2021-03-14 21:59:53 +00:00
|
|
|
((v.length === 2) && isModulePath(v[0]) && typeof v[1] === 'symbol')
|
2021-03-11 09:56:49 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-03-11 16:59:40 +00:00
|
|
|
export function asRef(v: any): Ref {
|
|
|
|
if (!isRef(v)) {throw new TypeError(`Invalid Ref: ${_.stringify(v)}`);} else {return v;};
|
|
|
|
}
|
2021-03-11 09:56:49 +00:00
|
|
|
|
2021-03-12 19:41:35 +00:00
|
|
|
export function decodeRef(d: _.TypedDecoder<_ptr>): Ref | undefined {
|
2021-03-14 20:10:47 +00:00
|
|
|
let result;
|
|
|
|
if (d.openRecord()) {
|
|
|
|
let _tmp49: any;
|
|
|
|
_tmp49 = _.asLiteral(d.nextSymbol(), $ref);
|
|
|
|
if (_tmp49 !== void 0) {
|
|
|
|
let _tmp50, _tmp51, _tmp52: any;
|
2021-03-14 21:59:53 +00:00
|
|
|
_tmp51 = decodeModulePath(d);
|
2021-03-14 20:10:47 +00:00
|
|
|
if (_tmp51 !== void 0) {
|
|
|
|
_tmp52 = d.nextSymbol();
|
|
|
|
if (_tmp52 !== void 0) {if (d.closeCompound()) _tmp50 = [_tmp51, _tmp52];};
|
|
|
|
};
|
2021-03-14 21:59:53 +00:00
|
|
|
if (_tmp50 !== void 0) result = _.Record<(typeof $ref), [ModulePath, symbol]>(_tmp49 as any, _tmp50 as any);
|
2021-03-14 20:10:47 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
return result;
|
2021-03-12 19:41:35 +00:00
|
|
|
}
|
|
|
|
|
2021-03-11 09:56:49 +00:00
|
|
|
export function isModulePath(v: any): v is ModulePath {
|
|
|
|
return (
|
|
|
|
_.Array.isArray(v) &&
|
2021-03-11 16:59:40 +00:00
|
|
|
!_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
|
2021-03-11 09:56:49 +00:00
|
|
|
(v.length >= 0) &&
|
2021-03-14 20:10:47 +00:00
|
|
|
v.every(v => (typeof v === 'symbol'))
|
2021-03-11 09:56:49 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-03-11 13:43:58 +00:00
|
|
|
export function asModulePath(v: any): ModulePath {
|
2021-03-11 16:59:40 +00:00
|
|
|
if (!isModulePath(v)) {throw new TypeError(`Invalid ModulePath: ${_.stringify(v)}`);} else {return v;};
|
2021-03-11 13:43:58 +00:00
|
|
|
}
|
2021-03-10 22:15:53 +00:00
|
|
|
|
2021-03-12 19:41:35 +00:00
|
|
|
export function decodeModulePath(d: _.TypedDecoder<_ptr>): ModulePath | undefined {
|
2021-03-14 20:10:47 +00:00
|
|
|
let result;
|
|
|
|
if (d.openSequence()) {
|
2021-03-14 21:59:53 +00:00
|
|
|
let _tmp53: any;
|
2021-03-14 20:10:47 +00:00
|
|
|
{
|
|
|
|
let vN: Array<symbol> | undefined = [];
|
|
|
|
while (!d.closeCompound()) {
|
2021-03-14 21:59:53 +00:00
|
|
|
_tmp53 = void 0;
|
|
|
|
_tmp53 = d.nextSymbol();
|
|
|
|
if (_tmp53 === void 0) {vN = void 0; break;};
|
|
|
|
vN.push(_tmp53);
|
2021-03-14 20:10:47 +00:00
|
|
|
};
|
|
|
|
result = vN;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
return result;
|
2021-03-12 19:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const _decodePtr = () => { throw new _.DecodeError("Pointers forbidden"); };
|
|
|
|
|