mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 12:09:30 +02:00
* Math.trunc polyfill
git-svn-id: trunk@38051 -
This commit is contained in:
parent
2f3fd73c0d
commit
0ef3fc2f29
18
utils/pas2js/dist/rtl.js
vendored
18
utils/pas2js/dist/rtl.js
vendored
@ -109,8 +109,20 @@ var rtl = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
exitcode: 0,
|
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){
|
run: function(module_name){
|
||||||
|
|
||||||
function doRun(){
|
function doRun(){
|
||||||
if (!rtl.hasString(module_name)) module_name='program';
|
if (!rtl.hasString(module_name)) module_name='program';
|
||||||
if (rtl.debug_load_units) rtl.debug('rtl.run module="'+module_name+'"');
|
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;
|
if (rtl.isNumber(r)) rtl.exitcode = r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rtl.createPolyFills();
|
||||||
|
|
||||||
if (rtl.showUncaughtExceptions) {
|
if (rtl.showUncaughtExceptions) {
|
||||||
try{
|
try{
|
||||||
doRun();
|
doRun();
|
||||||
|
Loading…
Reference in New Issue
Block a user