Dependency fixes; asynchronous ground dataspace

This commit is contained in:
Tony Garnock-Jones 2018-11-01 16:57:52 +00:00
parent 1380748b26
commit 2da4ba010d
7 changed files with 123 additions and 368 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/env node
require("../lib/index");
require("@babel/cli/lib/babel");
require("../node_modules/@babel/cli/lib/babel");

402
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -15,11 +15,11 @@
"prepare": "make build"
},
"devDependencies": {
"@babel/cli": "^7.1.2",
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0"
},
"dependencies": {
"@babel/cli": "^7.1.2",
"@babel/core": "^7.1.2",
"@babel/polyfill": "^7.0.0"
},
"bin": {

View File

@ -18,7 +18,8 @@
import * as t from "@babel/types";
function spawnlikeStatement(node) {
export function SpawnStatement(node) {
this.word("spawn");
this.space();
if (node.name) {
this.word("named");
@ -29,14 +30,16 @@ function spawnlikeStatement(node) {
this.printBlock(node);
}
export function SpawnStatement(node) {
this.word("spawn");
spawnlikeStatement.call(this, node);
}
export function DataspaceStatement(node) {
export function GroundDataspaceStatement(node) {
this.word("ground");
this.space();
this.word("dataspace");
spawnlikeStatement.call(this, node);
this.space();
if (this.id) {
this.print(node.id, node);
this.space();
}
this.print(node.body, node);
}
export function FieldDeclarationStatement(node) {

View File

@ -57,12 +57,26 @@ export default class SyndicateParser extends _original_Parser {
return this.finishNode(node, "FieldDeclarationStatement");
}
if (this.isContextual("dataspace")) {
return this.parseSpawnlikeStatement("DataspaceStatement");
if (this.isContextual("ground")) {
this.next();
this.expectContextual("dataspace");
const node = this.startNode();
if (this.match(tt.name)) {
node.id = this.parseIdentifier();
}
node.body = this.parseStatement();
return this.finishNode(node, "GroundDataspaceStatement");
}
if (this.isContextual("spawn")) {
return this.parseSpawnlikeStatement("SpawnStatement");
this.next();
const node = this.startNode();
if (this.isContextual("named")) {
this.next();
node.name = this.parseExpression();
}
node.body = this.parseStatement();
return this.finishNode(node, "SpawnStatement");
}
if (this.isContextual("assert")) {
@ -147,17 +161,6 @@ export default class SyndicateParser extends _original_Parser {
}
}
parseSpawnlikeStatement(type) {
const node = this.startNode();
this.next();
if (this.isContextual("named")) {
this.next();
node.name = this.parseExpression();
}
node.body = this.parseStatement();
return this.finishNode(node, type);
}
parseEventHandlerEndpoint(terminal, pseudoEventsAllowed) {
this.expectContextual("on");
const node = this.startNode();

View File

@ -247,17 +247,20 @@ export default declare((api, options) => {
}));
},
DataspaceStatement(path, state) {
GroundDataspaceStatement(path, state) {
const { node } = path;
let uid = path.scope.generateUidIdentifier("ds");
// TODO: name! Also this is a ground DS not a nested one. FIXME
path.replaceWith(template(`{ let DS = new DATASPACE(function () { BODY });
while (DS.runScripts()) ; }`)({
DS: uid,
DATASPACE: state.DataspaceID,
// NAME: node.name || t.nullLiteral(),
BODY: node.body
}));
if (node.id) {
path.replaceWith(template(`let G = (new SYNDICATE.Ground.Ground(function () { BODY }).start());`)({
G: node.id,
SYNDICATE: state.SyndicateID,
BODY: node.body
}));
} else {
path.replaceWith(template(`(new SYNDICATE.Ground.Ground(function () { BODY }).start());`)({
SYNDICATE: state.SyndicateID,
BODY: node.body
}));
}
},
FieldDeclarationStatement(path, state) {

View File

@ -39,13 +39,13 @@ defineType("SpawnStatement", {
},
});
defineType("DataspaceStatement", {
builder: ["name", "body"],
visitor: ["name", "body"],
defineType("GroundDataspaceStatement", {
builder: ["id", "body"],
visitor: ["id", "body"],
aliases: ["Statement"],
fields: {
name: {
validate: assertNodeType("Expression"),
id: {
validate: assertNodeType("Identifier"),
optional: true,
},
body: {