mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-21 03:00:19 +02:00
Add some primitives to runtime.js
* module/language/js-il/runtime.js(add/immediate, sub/immediate, load-u64, u64-=-scm, handle-interrupts): Add primitives.
This commit is contained in:
parent
e771241020
commit
936050c657
1 changed files with 43 additions and 1 deletions
|
@ -33,6 +33,10 @@ scheme.primitives.add1 = function (x) {
|
||||||
return x + 1;
|
return x + 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
scheme.primitives["add/immediate"] = function (x, y) {
|
||||||
|
return x + y;
|
||||||
|
};
|
||||||
|
|
||||||
scheme.primitives.sub = function (x, y) {
|
scheme.primitives.sub = function (x, y) {
|
||||||
return x - y;
|
return x - y;
|
||||||
};
|
};
|
||||||
|
@ -41,6 +45,10 @@ scheme.primitives.sub1 = function (x) {
|
||||||
return x - 1;
|
return x - 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
scheme.primitives["sub/immediate"] = function (x, y) {
|
||||||
|
return x - y;
|
||||||
|
};
|
||||||
|
|
||||||
scheme.primitives.mul = function (x, y) {
|
scheme.primitives.mul = function (x, y) {
|
||||||
return x * y;
|
return x * y;
|
||||||
};
|
};
|
||||||
|
@ -73,6 +81,32 @@ scheme.primitives.quo = not_implemented_yet;
|
||||||
scheme.primitives.rem = not_implemented_yet;
|
scheme.primitives.rem = not_implemented_yet;
|
||||||
scheme.primitives.mod = not_implemented_yet;
|
scheme.primitives.mod = not_implemented_yet;
|
||||||
|
|
||||||
|
// Unboxed Numbers
|
||||||
|
scheme.primitives["load-u64"] = function(x) {
|
||||||
|
return x;
|
||||||
|
};
|
||||||
|
|
||||||
|
scheme.primitives["u64-=-scm"] = function(x, y) {
|
||||||
|
// i.e. br-if-u64-=-scm
|
||||||
|
return coerce_bool(x === y);
|
||||||
|
};
|
||||||
|
|
||||||
|
scheme.primitives["u64-<=-scm"] = function(x, y) {
|
||||||
|
return coerce_bool(x <= y);
|
||||||
|
};
|
||||||
|
|
||||||
|
scheme.primitives["u64-<-scm"] = function(x, y) {
|
||||||
|
return coerce_bool(x < y);
|
||||||
|
};
|
||||||
|
|
||||||
|
scheme.primitives["u64->-scm"] = function(x, y) {
|
||||||
|
return coerce_bool(x > y);
|
||||||
|
};
|
||||||
|
|
||||||
|
scheme.primitives["u64->=-scm"] = function(x, y) {
|
||||||
|
return coerce_bool(x >= y);
|
||||||
|
};
|
||||||
|
|
||||||
// Boxes
|
// Boxes
|
||||||
scheme.Box = function (x) {
|
scheme.Box = function (x) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
|
@ -259,7 +293,9 @@ scheme.primitives["builtin-ref"] = function (idx) {
|
||||||
|
|
||||||
// Modules
|
// Modules
|
||||||
scheme.primitives["define!"] = function(sym, obj) {
|
scheme.primitives["define!"] = function(sym, obj) {
|
||||||
scheme.env[sym.name] = new scheme.Box(obj);
|
var b = new scheme.Box(obj);
|
||||||
|
scheme.env[sym.name] = b;
|
||||||
|
return b;
|
||||||
};
|
};
|
||||||
|
|
||||||
scheme.primitives["cache-current-module!"] = function (module, scope) {
|
scheme.primitives["cache-current-module!"] = function (module, scope) {
|
||||||
|
@ -430,6 +466,12 @@ var find_prompt = function(prompt) {
|
||||||
// FIXME: should error
|
// FIXME: should error
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
scheme.primitives["handle-interrupts"] = function () {
|
||||||
|
// TODO: implement
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
// Dynstack frames
|
// Dynstack frames
|
||||||
scheme.frame = {};
|
scheme.frame = {};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue