Skip to content

Commit

Permalink
Merge branch 'master' of github.com:feeley/gambit
Browse files Browse the repository at this point in the history
Conflicts:
	gsc/_t-univ.scm
  • Loading branch information
feeley committed May 17, 2012
2 parents 095a643 + 02387aa commit d449f22
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 18 deletions.
60 changes: 43 additions & 17 deletions gsc/_t-univ.scm
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@
(case (gvm-instr-type gvm-instr)

((label)
(gen "function "
(gen "\n"
"function "
(lbl->id ctx (label-lbl-num gvm-instr) (ctx-ns ctx))
"() {\n"

Expand All @@ -323,7 +324,7 @@
"// closure-entry-point\n"
"// entry-point\n")
"if (nargs !== " (label-entry-nb-parms gvm-instr) ") "
"throw \"wrong number of arguments\";\n"))
"throw \"wrong number of arguments\";\n\n"))

((return)
(gen "// return-point\n"))
Expand Down Expand Up @@ -394,14 +395,17 @@
((jump)
;; TODO
;; (jump-safe? gvm-instr)
;; (jump-poll? gvm-instr)
;; test: (jump-poll? gvm-instr)
(gen (let ((nb-args (jump-nb-args gvm-instr)))
(if nb-args
(gen "nargs = " nb-args ";\n")
""))
(sp-adjust ctx (frame-size (gvm-instr-frame gvm-instr)) "\n")
(let ((opnd (jump-opnd gvm-instr)))
(gen "return " (translate-gvm-opnd ctx opnd) ";\n"))
(if (jump-poll? gvm-instr)
(gen "nextpc = " (translate-gvm-opnd ctx opnd) ";\n"
"return null;\n")
(gen "return " (translate-gvm-opnd ctx opnd) ";\n")))
"}\n"))

(else
Expand Down Expand Up @@ -486,37 +490,59 @@ var reg = [null];
var stack = [];
var sp = -1;
var nargs = 0;
var nextpc = null;
var yield;

if (this.hasOwnProperty('setTimeout')) {
yield = this.setTimeout;
} else {
yield = function() {};
}


function lbl1_fx_3c_() { // fx<
if (nargs !== 2) throw "wrong number of arguments";
reg[1] = reg[1] < reg[2];
return reg[0];
if (nargs !== 2) throw "wrong number of arguments";
reg[1] = reg[1] < reg[2];
return reg[0];
}

glo["fx<"] = lbl1_fx_3c_;

function lbl1_fx_2b_() { // fx+
if (nargs !== 2) throw "wrong number of arguments";
reg[1] = reg[1] + reg[2];
return reg[0];
if (nargs !== 2) throw "wrong number of arguments";
reg[1] = reg[1] + reg[2];
return reg[0];
}

glo["fx+"] = lbl1_fx_2b_;

function lbl1_fx_2d_() { // fx-
if (nargs !== 2) throw "wrong number of arguments";
reg[1] = reg[1] - reg[2];
return reg[0];
if (nargs !== 2) throw "wrong number of arguments";
reg[1] = reg[1] - reg[2];
return reg[0];
}

glo["fx-"] = lbl1_fx_2d_;

function lbl1_print() { // print
if (nargs !== 1) throw "wrong number of arguments";
print(reg[1]);
return reg[0];
if (nargs !== 1) throw "wrong number of arguments";
print(reg[1]);
return reg[0];
}

glo["print"] = lbl1_print;


function run(pc) {
while (pc !== null) pc = pc();
nextpc = pc;
while (nextpc !== null) {
yield("", 0);
pc = nextpc;
nextpc = null;
while (pc !== null) {
pc = pc();
}
}
}

EOF
Expand Down
2 changes: 1 addition & 1 deletion include/stamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
*/

#define ___STAMP_YMD 20120517
#define ___STAMP_HMS 170202
#define ___STAMP_HMS 171057

0 comments on commit d449f22

Please sign in to comment.