on master help sign in
Fix function wrapping bug in JavaScript RTS

`i$ffiWrap` was basically apply the first argument over and over instead of for looping through each argument. ie. ```JavaScript foreach(arg in arguments) { while(function is not fully applied) { func.apply(arg); } } ``` This has made it impossible to use native JavaScript higher-order functions through the FFI. `make test_js` passes, but I'm not familiar with the js codegen/rts, so someone should check and make sure this is correct.

commit15590d71071a32757ea0b851d0d04f13cc2700f1 authorfiendfan1 <fiendfan1@yahoo.com> dateWed 4 Feb 2015, 16:32 (12 years ago) parente13e48d
1 file changed+11−13
jsrts/Runtime-common.js+11−13
jsrts/Runtime-common.js+11−13
@@ -68,20 +68,18 @@ var i$ffiWrap = function(fid,oldbase,myoldbase) {
6868 var res = fid;
6969
7070 for(var i = 0; i < (arguments.length ? arguments.length : 1); ++i) {
71− while (res instanceof i$CON) {
72− i$valstack_top += 1;
73− i$valstack[i$valstack_top] = res;
74− i$valstack[i$valstack_top + 1] = arguments[i];
75− i$SLIDE(2);
76− i$valstack_top = i$valstack_base + 2;
77− i$CALL(_idris__123_APPLY0_125_,[oldbase])
78− while (i$callstack.length) {
79− var func = i$callstack.pop();
80− var args = i$callstack.pop();
81− func.apply(this,args);
82− }
83− res = i$ret;
71+ i$valstack_top += 1;
72+ i$valstack[i$valstack_top] = res;
73+ i$valstack[i$valstack_top + 1] = arguments[i];
74+ i$SLIDE(2);
75+ i$valstack_top = i$valstack_base + 2;
76+ i$CALL(_idris__123_APPLY0_125_,[oldbase])
77+ while (i$callstack.length) {
78+ var func = i$callstack.pop();
79+ var args = i$callstack.pop();
80+ func.apply(this,args);
8481 }
82+ res = i$ret;
8583 }
8684
8785 i$callstack = i$vm.callstack;