mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-24 04:15:36 +02:00
Replace values object with values passed as continuation arguments
This commit is contained in:
parent
ce1cc2706c
commit
d57dc85fa8
4 changed files with 17 additions and 37 deletions
|
@ -42,8 +42,8 @@
|
|||
(($ il:var id exp)
|
||||
(make-var (rename id) (compile-exp exp)))
|
||||
|
||||
(($ il:continue k exp)
|
||||
(make-return (make-call (name->id k) (list (compile-exp exp)))))
|
||||
(($ il:continue k exps)
|
||||
(make-return (make-call (name->id k) (map compile-exp exps))))
|
||||
|
||||
(($ il:branch test then else)
|
||||
(make-conditional (make-call (make-refine *scheme* (make-const "is_true"))
|
||||
|
@ -72,11 +72,6 @@
|
|||
(make-call (make-refine *scheme* (make-const "Closure"))
|
||||
(list (name->id label) (make-const nfree)))))
|
||||
|
||||
(($ il:values vals)
|
||||
(make-new
|
||||
(make-call (make-refine *scheme* (make-const "Values"))
|
||||
(map name->id vals))))
|
||||
|
||||
(($ il:id name)
|
||||
(name->id name))))
|
||||
|
||||
|
|
|
@ -159,12 +159,6 @@ scheme.primitives["resolve"] = function (sym, is_bound) {
|
|||
return scheme.env[sym.name];
|
||||
};
|
||||
|
||||
// values
|
||||
scheme.Values = function () {
|
||||
this.values = arguments;
|
||||
return this;
|
||||
};
|
||||
|
||||
// bleh
|
||||
scheme.initial_cont = function (x) { return x; };
|
||||
scheme.primitives.return = function (x) { return x; };
|
||||
|
@ -172,13 +166,11 @@ scheme.is_true = function (obj) {
|
|||
return !(obj == scheme.FALSE || obj == scheme.NIL);
|
||||
};
|
||||
|
||||
var callcc = function (k,vals) {
|
||||
var closure = vals.values[0];
|
||||
var f = function (k2, val) {
|
||||
// TODO: multivalue continuations
|
||||
var callcc = function (self, k, closure) {
|
||||
var f = function (self, k2, val) {
|
||||
return k(val);
|
||||
};
|
||||
return closure.fun(k, new scheme.Closure(f, 0));
|
||||
return closure.fun(closure, k, new scheme.Closure(f, 0));
|
||||
};
|
||||
scheme.builtins[4] = new scheme.Closure(callcc, 0);
|
||||
// #define FOR_EACH_VM_BUILTIN(M) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue