Skip to content

Commit

Permalink
[enhance] runtime, cps: Added cps catch
Browse files Browse the repository at this point in the history
  • Loading branch information
BourgerieQuentin committed Jun 29, 2012
1 parent acd07ad commit 791f447
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
7 changes: 7 additions & 0 deletions opabsl/jsbsl/bslCps.js
Expand Up @@ -102,6 +102,13 @@ function toplevel_wait(barrier){
//////////////////////////////////////////////////
##register [opacapi, no-projection, restricted : cps] handler_cont \ `QmlCpsLib_handler_cont` : continuation('a) -> continuation('c)
##register [opacapi, no-projection : cps, restricted : cps] catch_native : \
(opa['c], continuation('a) -> _unit), continuation('a) -> continuation('a)
##args(h, k)
{
return k.catch_(h);
}
##register [no-projection : cps, restricted : cps] spawn \ spawn : (_unit, continuation('a) -> _unit) -> Cps.future('a)
Expand Down
14 changes: 11 additions & 3 deletions qmlcps/qmlCpsClientLib.js
Expand Up @@ -107,9 +107,6 @@ Barrier.prototype = {
cps_assert(result != null, "[Barrier.release] invoked on [null] result");
cps_assert(!this._is_computed, "[Barrier.release] invoked on already released barrier");
cps_debug("[Barrier.release] Releasing barrier "+this._id);
//DEBUG START
released_barriers.push(this._id);
//DEBUG STOP
this._is_computed = true;
this._result = result;
var waiters = this._waiters;
Expand Down Expand Up @@ -316,7 +313,18 @@ Continuation.prototype = {
var payload = this._paylexn;
payload = payload ? payload : QmlCpsLib_default_handler_cont(this)._payload;
return this._paylexn.apply(this._context, [exn])
},

ccont: function(f) {
return new Continuation(f, this._context, this._options);
},

catch_: function(h) {
var k = this.ccont(this._payload);
k._paylexn = h;
return k;
}

}

function QmlCpsLib_callcc_directive(f, k){
Expand Down

0 comments on commit 791f447

Please sign in to comment.