Dependency fixes; asynchronous ground dataspace
This commit is contained in:
parent
1380748b26
commit
2da4ba010d
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
require("../lib/index");
|
||||
require("@babel/cli/lib/babel");
|
||||
require("../node_modules/@babel/cli/lib/babel");
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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": {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
10
src/types.js
10
src/types.js
|
@ -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: {
|
||||
|
|
Loading…
Reference in New Issue