Adapt to latest Preserves changes
This commit is contained in:
parent
dd281366c4
commit
ccd87c09f1
|
@ -108,10 +108,14 @@ function stringifyId(i: Identifier): Items {
|
|||
return [ { ... i, type: TokenType.STRING, text: JSON.stringify(i.text) } ];
|
||||
}
|
||||
|
||||
function facetFieldObjectType(t: TemplateFunction, fs: FacetFields): Substitution {
|
||||
function facetFieldObjectType(
|
||||
t: TemplateFunction,
|
||||
fs: FacetFields,
|
||||
defaultType?: Substitution): Substitution
|
||||
{
|
||||
function formatBinder(binder: Binder) {
|
||||
const hasType = (binder.type !== void 0);
|
||||
return t`${[binder.id]}${hasType ? ': ': ''}${binder.type ?? ''}`;
|
||||
const hasType = ((binder.type ?? defaultType) !== void 0);
|
||||
return t`${[binder.id]}${hasType ? ': ': ''}${binder.type ?? defaultType ?? ''}`;
|
||||
}
|
||||
return t`{${commaJoin(fs.map(formatBinder))}}`;
|
||||
}
|
||||
|
@ -289,9 +293,12 @@ ${joinItems(sa.captureBinders.map(binderTypeGuard(t)), '\n')}
|
|||
});
|
||||
|
||||
x(ctx.parser.typeDefinitionStatement, (s, t) => {
|
||||
const l = JSON.stringify(s.label.text);
|
||||
const fs = JSON.stringify(s.fields.map(f => f.id.text));
|
||||
return t`const ${[s.label]} = __SYNDICATE__.Record.makeConstructor(${maybeWalk(s.wireName) ?? l}, ${fs});`;
|
||||
const l = `Symbol.for(${JSON.stringify(s.label.text)})`;
|
||||
const fns = JSON.stringify(s.fields.map(f => f.id.text));
|
||||
const fs = ctx.typescript
|
||||
? t`<${facetFieldObjectType(t, s.fields, t`__SYNDICATE__.Value`)}>`
|
||||
: '';
|
||||
return t`const ${[s.label]} = __SYNDICATE__.Record.makeConstructor${fs}()(${maybeWalk(s.wireName) ?? l}, ${fns});`;
|
||||
});
|
||||
|
||||
xf(ctx.parser.messageSendStatement, (s, t) => t`_send(${walk(s.expr)});`);
|
||||
|
|
|
@ -21,8 +21,8 @@ const { bootModule, Dataspace, Skeleton, Ground, Record, Discard, Capture, Obser
|
|||
const __ = Discard._instance;
|
||||
const _$ = Capture(__);
|
||||
|
||||
const BoxState = Record.makeConstructor('BoxState', ['value']);
|
||||
const SetBox = Record.makeConstructor('SetBox', ['newValue']);
|
||||
const BoxState = Record.makeConstructor()(Symbol.for('BoxState'), ['value']);
|
||||
const SetBox = Record.makeConstructor()(Symbol.for('SetBox'), ['newValue']);
|
||||
|
||||
const N = 100000;
|
||||
|
||||
|
|
|
@ -17,12 +17,18 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
import { bootModule, Skeleton, Record, Discard, Capture, Observe, Facet } from '..';
|
||||
import { bootModule, Skeleton, Record, Discard, Capture, Observe, Facet, Value } from '..';
|
||||
const __ = Discard._instance;
|
||||
const _$ = Capture(__);
|
||||
|
||||
const BoxState = Record.makeConstructor('BoxState', ['value']);
|
||||
const SetBox = Record.makeConstructor('SetBox', ['newValue']);
|
||||
// The current pattern representation puts Capture and Discard record
|
||||
// instances into Record fields, so those record fields have to be
|
||||
// prepared to type them, which is why we see `number | Pattern` here
|
||||
// rather than the ideal `number`.
|
||||
//
|
||||
type Pattern = ReturnType<typeof Capture> | ReturnType<typeof Discard>;
|
||||
const BoxState = Record.makeConstructor<{value: number | Pattern}>()(Symbol.for('BoxState'), ['value']);
|
||||
const SetBox = Record.makeConstructor<{newValue: number | Pattern}>()(Symbol.for('SetBox'), ['newValue']);
|
||||
|
||||
const N = 100000;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
import { Record, RecordConstructor, AsPreserve } from 'preserves';
|
||||
import { Record, RecordConstructor, AsPreserve, Value } from 'preserves';
|
||||
|
||||
export class Seal {
|
||||
readonly contents: any;
|
||||
|
@ -30,19 +30,33 @@ export class Seal {
|
|||
}
|
||||
}
|
||||
|
||||
interface Discard extends RecordConstructor {
|
||||
_instance: Record;
|
||||
interface Discard extends RecordConstructor<typeof _Discard, {}, []> {
|
||||
_instance: Record<typeof _Discard, []>;
|
||||
}
|
||||
|
||||
const _Discard = Symbol.for('discard');
|
||||
export const Discard: Discard = (function () {
|
||||
let Discard: any = Record.makeConstructor('discard', []);
|
||||
let Discard: any = Record.makeConstructor<{}>()(_Discard, []);
|
||||
Discard._instance = Discard();
|
||||
return Discard;
|
||||
})();
|
||||
|
||||
export const Capture = Record.makeConstructor('capture', ['specification']);
|
||||
export const Observe = Record.makeConstructor('observe', ['specification']);
|
||||
export const _Capture = Symbol.for('capture');
|
||||
export const Capture = Record.makeConstructor<{specification: Value}>()(
|
||||
_Capture, ['specification']);
|
||||
|
||||
export const Inbound = Record.makeConstructor('inbound', ['assertion']);
|
||||
export const Outbound = Record.makeConstructor('outbound', ['assertion']);
|
||||
export const Instance = Record.makeConstructor('instance', ['uniqueId']);
|
||||
export const _Observe = Symbol.for('observe');
|
||||
export const Observe = Record.makeConstructor<{specification: Value}>()(
|
||||
_Observe, ['specification']);
|
||||
|
||||
export const _Inbound = Symbol.for('inbound');
|
||||
export const Inbound = Record.makeConstructor<{assertion: Value}>()(
|
||||
_Inbound, ['assertion']);
|
||||
|
||||
export const _Outbound = Symbol.for('outbound');
|
||||
export const Outbound = Record.makeConstructor<{assertion: Value}>()(
|
||||
_Outbound, ['assertion']);
|
||||
|
||||
export const _Instance = Symbol.for('instance');
|
||||
export const Instance = Record.makeConstructor<{uniqueId: Value}>()(
|
||||
_Instance, ['uniqueId']);
|
||||
|
|
|
@ -70,7 +70,7 @@ export class NestedDataspace extends Dataspace {
|
|||
? {
|
||||
skeleton: null,
|
||||
constPaths: h.constPaths,
|
||||
constVals: h.constVals.map(v => (v as Record)[0]),
|
||||
constVals: h.constVals.map(v => (v as ReturnType<typeof Observe>)[0]),
|
||||
capturePaths: h.capturePaths.map(p => p.slice(1)),
|
||||
callback
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
//---------------------------------------------------------------------------
|
||||
|
||||
import { IdentitySet } from './idcoll.js';
|
||||
import { is, Value, Record, Set, Dictionary, canonicalString, preserves, RecordConstructorInfo } from 'preserves';
|
||||
import { is, Value, Record, Set, Dictionary, canonicalString, RecordConstructorInfo, Tuple } from 'preserves';
|
||||
|
||||
import { Bag, ChangeDescription } from './bag.js';
|
||||
import { Discard, Capture } from './assertions.js';
|
||||
|
@ -280,13 +280,13 @@ class Handler {
|
|||
}
|
||||
}
|
||||
|
||||
export function constructorInfoSignature(ci: RecordConstructorInfo): string {
|
||||
export function constructorInfoSignature(ci: RecordConstructorInfo<Value>): string {
|
||||
return canonicalString(ci.label) + '/' + ci.arity;
|
||||
}
|
||||
|
||||
function classOf(v: any): Shape | null {
|
||||
if (Record.isRecord(v)) {
|
||||
return constructorInfoSignature(v.getConstructorInfo());
|
||||
return constructorInfoSignature(Record.constructorInfo(v));
|
||||
} else if (Array.isArray(v)) {
|
||||
return '' + v.length;
|
||||
} else {
|
||||
|
@ -399,7 +399,7 @@ export function withoutCaptures(p: Value): Value {
|
|||
|
||||
const cls = classOf(p);
|
||||
if (cls === null) return p;
|
||||
if (Record.isRecord(p)) return new Record(p.label, p.map(walk));
|
||||
if (Record.isRecord(p)) return Record(p.label, p.map(walk));
|
||||
return (p as Array<Value>).map(walk);
|
||||
}
|
||||
return walk(p);
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<meta charset=utf-8>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.67, maximum-scale=0.67, user-scalable=no">
|
||||
<link href="css/style.css" rel="stylesheet" type="text/css">
|
||||
<script src="node_modules/@syndicate-lang/core/dist/syndicate.js"></script>
|
||||
<script src="node_modules/@syndicate-lang/html/dist/syndicate-html.js"></script>
|
||||
<script src="node_modules/@syndicate-lang/timer/dist/syndicate-timer.js"></script>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.67, maximum-scale=0.67, user-scalable=no">
|
||||
<link href="css/style.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div id="board-area" class="board">
|
||||
|
|
|
@ -477,7 +477,7 @@ export class Anchor {
|
|||
return new Anchor({ fragmentId: this.fragmentId + '__' + extn });
|
||||
}
|
||||
|
||||
html(selector: string, html: HtmlFragments, orderBy: NodeOrderKey = ''): Record {
|
||||
html(selector: string, html: HtmlFragments, orderBy: NodeOrderKey = ''): ReturnType<typeof P.UIFragment> {
|
||||
return P.UIFragment(this.fragmentId, selector, html.nodes(), orderBy);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -220,6 +220,10 @@ const boot: tslib.server.PluginModuleFactory = ({ typescript: ts }) => {
|
|||
this.inner = inner;
|
||||
}
|
||||
|
||||
getFileReferences(fileName: string): tslib.ReferenceEntry[] {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
cleanupSemanticCache(): void {
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue