* Math.trunc polyfill

git-svn-id: trunk@38051 -
This commit is contained in:
michael 2018-01-26 20:33:42 +00:00
parent 2f3fd73c0d
commit 0ef3fc2f29

View File

@ -109,8 +109,20 @@ var rtl = {
},
exitcode: 0,
// Create needed polyfills for the rtl to run.
createPolyFills : function () {
if (!Math.trunc) {
Math.trunc = function(v) {
v = +v;
if (!isFinite(v)) return v;
return (v - v % 1) || (v < 0 ? -0 : v === 0 ? v : 0);
};
}
},
run: function(module_name){
function doRun(){
if (!rtl.hasString(module_name)) module_name='program';
if (rtl.debug_load_units) rtl.debug('rtl.run module="'+module_name+'"');
@ -125,7 +137,9 @@ var rtl = {
if (rtl.isNumber(r)) rtl.exitcode = r;
}
}
rtl.createPolyFills();
if (rtl.showUncaughtExceptions) {
try{
doRun();