From 7b9f035fa8c3675c0cc908a0c67e4641a5aebf0c Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Fri, 3 Dec 2021 01:52:46 +0100 Subject: [PATCH] tsc package --- packages/tsc/examples/typescript/index.html | 3 --- packages/tsc/examples/typescript/src/box.ts | 14 +++++++++----- packages/tsc/examples/typescript/src/client.ts | 12 +++++++++--- packages/tsc/examples/typescript/src/index.ts | 15 +++++++++------ packages/tsc/examples/typescript/src/protocol.ts | 4 ++-- packages/tsc/src/tsc.ts | 2 +- 6 files changed, 30 insertions(+), 20 deletions(-) diff --git a/packages/tsc/examples/typescript/index.html b/packages/tsc/examples/typescript/index.html index 13b7645..dec9da3 100644 --- a/packages/tsc/examples/typescript/index.html +++ b/packages/tsc/examples/typescript/index.html @@ -7,7 +7,4 @@

Look in the JavaScript console for output.

- diff --git a/packages/tsc/examples/typescript/src/box.ts b/packages/tsc/examples/typescript/src/box.ts index 0df308e..ce72186 100644 --- a/packages/tsc/examples/typescript/src/box.ts +++ b/packages/tsc/examples/typescript/src/box.ts @@ -2,13 +2,17 @@ /// SPDX-FileCopyrightText: Copyright © 2016-2021 Tony Garnock-Jones import { BoxState, SetBox, N } from './protocol.js'; +import { Ref } from '@syndicate-lang/core'; -boot { +export function boot(ds: Ref) { spawn named 'box' { - field value: number = 0; - assert BoxState(this.value); - stop on (this.value === N) + field boxValue: number = 0; + at ds { + assert BoxState(boxValue.value); + on message SetBox($v: number) => boxValue.value = v; + } + stop on (boxValue.value === N) { console.log('terminated box root facet'); - on message SetBox($v: number) => this.value = v; + } } } diff --git a/packages/tsc/examples/typescript/src/client.ts b/packages/tsc/examples/typescript/src/client.ts index b1765d1..f572f49 100644 --- a/packages/tsc/examples/typescript/src/client.ts +++ b/packages/tsc/examples/typescript/src/client.ts @@ -2,10 +2,16 @@ /// SPDX-FileCopyrightText: Copyright © 2016-2021 Tony Garnock-Jones import { BoxState, SetBox } from './protocol.js'; +import { Ref } from '@syndicate-lang/core'; -boot { +export function boot(ds: Ref, doneCallback: () => void) { spawn named 'client' { - on asserted BoxState($v: number) => send message SetBox(v + 1); - on retracted BoxState(_) => console.log('box gone'); + at ds { + on asserted BoxState($v: number) => send message SetBox(v + 1); + on retracted BoxState(_) => { + console.log('box gone'); + doneCallback(); + } + } } } diff --git a/packages/tsc/examples/typescript/src/index.ts b/packages/tsc/examples/typescript/src/index.ts index ae242bd..7aad83f 100644 --- a/packages/tsc/examples/typescript/src/index.ts +++ b/packages/tsc/examples/typescript/src/index.ts @@ -2,11 +2,14 @@ /// SPDX-FileCopyrightText: Copyright © 2016-2021 Tony Garnock-Jones import { N } from './protocol.js'; -activate import './box.js'; -activate import './client.js'; +import * as Box from './box.js'; +import * as Client from './client.js'; +import { Actor, Dataspace, Turn } from '@syndicate-lang/core'; console.time('box-and-client-' + N.toString()); -boot { - thisFacet.actor.dataspace.ground().addStopHandler(() => - console.timeEnd('box-and-client-' + N.toString())); -} +Actor.boot(() => { + Turn.activeFacet.preventInertCheck(); + const ds = create new Dataspace(); + Box.boot(ds); + Client.boot(ds, () => console.timeEnd('box-and-client-' + N.toString())); +}); diff --git a/packages/tsc/examples/typescript/src/protocol.ts b/packages/tsc/examples/typescript/src/protocol.ts index 551aeba..4e4ed3b 100644 --- a/packages/tsc/examples/typescript/src/protocol.ts +++ b/packages/tsc/examples/typescript/src/protocol.ts @@ -1,7 +1,7 @@ /// SPDX-License-Identifier: GPL-3.0-or-later /// SPDX-FileCopyrightText: Copyright © 2016-2021 Tony Garnock-Jones -export assertion type BoxState(value); -export message type SetBox(newValue); +export assertion type BoxState(value: number); +export message type SetBox(newValue: number); export const N = 100000; diff --git a/packages/tsc/src/tsc.ts b/packages/tsc/src/tsc.ts index aeb7067..c93ca4c 100644 --- a/packages/tsc/src/tsc.ts +++ b/packages/tsc/src/tsc.ts @@ -163,7 +163,7 @@ function runBuildOnce(options: CommandLineArguments, toWatch = new ToWatch()) { return sf; } catch (e) { console.error(e); - onError?.(e.message); + onError?.((e as any).message ?? ''); return undefined; } } else {