Support gaining access to the ground object

This commit is contained in:
Tony Garnock-Jones 2016-03-19 15:06:07 -04:00
parent b9aa833186
commit a8b7de0d64
3 changed files with 10 additions and 4 deletions

View File

@ -86,8 +86,13 @@ var modifiedSourceActions = {
return buildActor(ctorExp.asES5, block); return buildActor(ctorExp.asES5, block);
}, },
NetworkStatement_ground: function(_ground, _network, block) { NetworkStatement_ground: function(_ground, _network, maybeId, block) {
return 'new Syndicate.Ground(function () ' + block.asES5 + ').startStepping();'; var code = 'new Syndicate.Ground(function () ' + block.asES5 + ').startStepping();';
if (maybeId.numChildren === 1) {
return 'var ' + maybeId.children[0].interval.contents + ' = ' + code;
} else {
return code;
}
}, },
NetworkStatement_normal: function(_network, block) { NetworkStatement_normal: function(_network, block) {
return 'Syndicate.Network.spawn(new Network(function () ' + block.asES5 + '));'; return 'Syndicate.Network.spawn(new Network(function () ' + block.asES5 + '));';

View File

@ -18,8 +18,8 @@ Syndicate <: ES5 {
| actor Block -- noConstructor | actor Block -- noConstructor
NetworkStatement NetworkStatement
= ground network Block -- ground = ground network identifier? Block -- ground
| network Block -- normal | network Block -- normal
ActorFacetStatement ActorFacetStatement
= state FacetBlock until FacetStateTransitionBlock -- state = state FacetBlock until FacetStateTransitionBlock -- state

View File

@ -37,6 +37,7 @@ Ground.prototype.startStepping = function () {
self.startStepping(); self.startStepping();
}, 0); }, 0);
} }
return this; // because the syndicatec compiler chains startStepping after the ctor
}; };
Ground.prototype.stopStepping = function () { Ground.prototype.stopStepping = function () {