ref: c1c637b7396e9cfe9227eb3fc06b61ec4fd6db83
parent: 0b9d3be3d0b4371c44142021040fb0ff03b03c29
author: Tor Andersson <tor.andersson@artifex.com>
date: Thu Dec 17 06:24:40 EST 2015
Implement js_replace. js_replace moves the value at top of the stack to the specified stack slot.
--- a/jsrun.c
+++ b/jsrun.c
@@ -346,6 +346,19 @@
--TOP;
}
+void js_insert(js_State *J, int idx)
+{
+ js_error(J, "not implemented yet");
+}
+
+void js_replace(js_State* J, int idx)
+{
+ idx = idx < 0 ? TOP + idx : BOT + idx;
+ if (idx < BOT || idx >= TOP)
+ js_error(J, "stack error!");
+ STACK[idx] = STACK[--TOP];
+}
+
void js_copy(js_State *J, int idx)
{
CHECKSTACK(1);