Skip to content

Commit

Permalink
rename colocally to enclave
Browse files Browse the repository at this point in the history
  • Loading branch information
shumbo committed Aug 5, 2024
1 parent 8e2dcc1 commit 3efa670
Show file tree
Hide file tree
Showing 16 changed files with 169 additions and 160 deletions.
8 changes: 6 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"cSpell.words": ["colocally", "Colocated", "TAPL"],
"cSpell.words": [
"enclave",
"Colocated",
"TAPL"
],
"eslint.options": {
"overrideConfigFile": "./.eslintrc.cjs"
},
"C_Cpp.intelliSenseEngineFallback": "enabled"
}
}
9 changes: 7 additions & 2 deletions choreography-ts.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
"search.exclude": {
"dist/**": true,
},
"cSpell.words": ["choreographies", "Colocally", "Colocated", "ivar"],
"cSpell.words": [
"choreographies",
"Enclave",
"Colocated",
"ivar"
],
"files.associations": {
"turbo.json": "jsonc",
},
Expand All @@ -40,4 +45,4 @@
"bierner.comment-tagged-templates",
],
},
}
}
6 changes: 3 additions & 3 deletions packages/core/src/core.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ describe("core", () => {
await g([]);
expect(count).toBe(1);
});
test("colocally", async () => {
test("enclave", async () => {
let count = 0;
const test: Choreography<Locations> = async ({ colocally }) => {
await colocally(
const test: Choreography<Locations> = async ({ enclave }) => {
await enclave(
["bob", "carol"],
async ({ locally, broadcast }) => {
const msgAtBob = await locally("bob", () => "Hello, world!");
Expand Down
20 changes: 10 additions & 10 deletions packages/core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class MultiplyLocated<T, L extends Location> {
export type Dependencies<L extends Location> = {
locally: Locally<L>;
comm: Comm<L>;
colocally: Colocally<L>;
enclave: Enclave<L>;
multicast: Multicast<L>;
broadcast: Broadcast<L>;
call: Call<L>;
Expand Down Expand Up @@ -96,7 +96,7 @@ export type Comm<L extends Location> = <L1 extends L, L2 extends L, T>(
value: Located<T, L1>,
) => Promise<Located<T, L2>>;

export type Colocally<L extends Location> = <
export type Enclave<L extends Location> = <
LL extends L,
Args extends Located<any, LL>[],
Return extends Located<any, LL>[],
Expand Down Expand Up @@ -362,7 +362,7 @@ export class Projector<L extends Location, L1 extends L> {
return undefined as any;
};

const colocally: (t: Tag) => Colocally<L> =
const enclave: (t: Tag) => Enclave<L> =
(t: Tag) =>
async <
LL extends L,
Expand All @@ -381,7 +381,7 @@ export class Projector<L extends Location, L1 extends L> {
wrapMethods((m) => ctxManager.checkContext(m), {
locally: locally(childTag),
comm: comm(childTag),
colocally: colocally(childTag),
enclave: enclave(childTag),
multicast: multicast(childTag),
broadcast: broadcast(childTag),
call: call(childTag),
Expand Down Expand Up @@ -510,7 +510,7 @@ export class Projector<L extends Location, L1 extends L> {
broadcast: broadcast(childTag),
call: call(childTag),
multicast: multicast(childTag),
colocally: colocally(childTag),
enclave: enclave(childTag),
naked: naked,
}),
a,
Expand All @@ -524,7 +524,7 @@ export class Projector<L extends Location, L1 extends L> {
broadcast: broadcast(tag),
call: call(tag),
multicast: multicast(tag),
colocally: colocally(tag),
enclave: enclave(tag),
naked: naked,
}),
args.map((x) => new Located(x, key)) as any,
Expand Down Expand Up @@ -604,7 +604,7 @@ export class Runner {
) => {
return new Located(value.getValue(key), key);
};
const colocally: Colocally<L> = async <
const enclave: Enclave<L> = async <
LL extends L,
Args extends Located<any, LL>[],
Return extends Located<any, LL>[],
Expand All @@ -617,7 +617,7 @@ export class Runner {
wrapMethods((m) => m, {
locally: locally,
comm: comm,
colocally: colocally,
enclave: enclave,
multicast: multicast,
broadcast: broadcast,
call: call,
Expand Down Expand Up @@ -659,7 +659,7 @@ export class Runner {
broadcast: broadcast,
call: call,
multicast: multicast,
colocally: colocally,
enclave: enclave,
naked: naked,
}),
a,
Expand All @@ -676,7 +676,7 @@ export class Runner {
broadcast: broadcast,
call: call,
multicast: multicast,
colocally: colocally,
enclave: enclave,
naked: naked,
},
args.map((x) => new Located(x, key)) as any,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export type {
Dependencies,
Locally,
Comm,
Colocally,
Enclave,
Naked,
Multicast,
Broadcast,
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/lib/transport-test-suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ export namespace TransportTestSuite {
]);
expect(count).toEqual(4);
});
test("colocally", async () => {
test("enclave", async () => {
let count = 0;
const test: Choreography<Locations, [], []> = async ({ colocally }) => {
await colocally(
const test: Choreography<Locations, [], []> = async ({ enclave }) => {
await enclave(
["alice", "bob"],
async ({ locally, broadcast }) => {
const bAtAlice = await locally("alice", () => "SECRET");
Expand All @@ -202,14 +202,14 @@ export namespace TransportTestSuite {
expect(count).toEqual(2);
});

test("colocally changes context", async () => {
test("enclave changes context", async () => {
const test: Choreography<Locations> = async ({
locally,
broadcast,
colocally,
enclave,
}) => {
const msgAtCarol = await locally("carol", () => "I'm Carol");
await colocally(
await enclave(
["alice", "bob"],
async () => {
const _msgAtEveryone = await broadcast("carol", msgAtCarol);
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin-choreography-ts/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TSESLint } from "@typescript-eslint/utils";
import noRenameRule from "./no-renaming-operator";
import noOutsideOperatorRule from "./no-outside-choreographic-operator";
import noUnusedColocallyLocation from "./no-unused-colocally-location";
import noUnusedEnclaveLocation from "./no-unused-enclave-location";

// https://stackoverflow.com/a/63188062
const rules: TSESLint.Linter.Plugin = {
Expand All @@ -12,14 +12,14 @@ const rules: TSESLint.Linter.Plugin = {
"@choreography-ts/choreography-ts/no-renaming-operator": "error",
"@choreography-ts/choreography-ts/no-outside-choreographic-operator":
"error",
"@choreography-ts/choreography-ts/no-unused-colocally-location": "warn",
"@choreography-ts/choreography-ts/no-unused-enclave-location": "warn",
},
},
},
rules: {
"no-renaming-operator": noRenameRule,
"no-outside-choreographic-operator": noOutsideOperatorRule,
"no-unused-colocally-location": noUnusedColocallyLocation,
"no-unused-enclave-location": noUnusedEnclaveLocation,
},
};
export = rules;
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import ts from "typescript";

type MessageIDs = "error" | "suggestion";

const operators = /^(locally|colocally|multicast|broadcast|comm|call|naked)$/;
const operators = /^(locally|enclave|multicast|broadcast|comm|call|naked)$/;

const choreographySelector = `VariableDeclaration[kind = "const"] > VariableDeclarator`;
const functionSelector = `${choreographySelector} > :matches(ArrowFunctionExpression, FunctionExpression)`;
Expand Down Expand Up @@ -89,7 +89,7 @@ const noOutsideOperatorRule: TSESLint.RuleModule<MessageIDs, []> = {
if (properties.length > 0) {
let match = false;
// `propertyRange` tracks the location range of the last encountered
// operator in the dependencies parameter `{locally, colocally, ...}` so we
// operator in the dependencies parameter `{locally, enclave, ...}` so we
// know where to place the missing operator
let propertyRange: [number, number];
// find the matching operator in the dependencies parameter if it exists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ts from "typescript";

type MessageIDs = "rename" | "invalid";

const operators = /^(colocally|call)$/; // The operators that accept a choreography as an argument
const operators = /^(enclave|call)$/; // The operators that accept a choreography as an argument
const choreographySelector = `VariableDeclaration[kind = "const"] > VariableDeclarator`;
const operatorSelector = `${choreographySelector} CallExpression[callee.name = ${operators}]`;
// Match any top-level choreography, or any choreographic operator call that accepts a choreography argument
Expand Down Expand Up @@ -64,7 +64,7 @@ const noRenameRule: TSESLint.RuleModule<MessageIDs, []> = {
if (node.params[0]?.type === AST_NODE_TYPES.ObjectPattern) {
// If the first argument for the choreography is an object pattern
node.params[0].properties.forEach((property) => {
// Check for shorthand json format: {locally, colocally, ...}, and no rest element `...rest`
// Check for shorthand json format: {locally, enclave, ...}, and no rest element `...rest`
if (
property.type === AST_NODE_TYPES.Property
? property.shorthand !== true
Expand Down
Loading

0 comments on commit 3efa670

Please sign in to comment.