Browse Source

* Math.trunc polyfill

git-svn-id: trunk@38051 -
michael 7 years ago
parent
commit
0ef3fc2f29
1 changed files with 16 additions and 2 deletions
  1. 16 2
      utils/pas2js/dist/rtl.js

+ 16 - 2
utils/pas2js/dist/rtl.js

@@ -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();