mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-29 16:20:40 +02:00
rtl: less free return null, fixed rc return null, set $ancestor to null
This commit is contained in:
parent
8b28290444
commit
aafec52c70
18
compiler/utils/pas2js/dist/rtl.js
vendored
18
compiler/utils/pas2js/dist/rtl.js
vendored
@ -280,7 +280,7 @@ var rtl = {
|
|||||||
// if root is an "object" then c.$ancestor === Object.getPrototypeOf(c)
|
// if root is an "object" then c.$ancestor === Object.getPrototypeOf(c)
|
||||||
// if root is a "function" then c.$ancestor === c.__proto__, Object.getPrototypeOf(c) returns the root
|
// if root is a "function" then c.$ancestor === c.__proto__, Object.getPrototypeOf(c) returns the root
|
||||||
} else {
|
} else {
|
||||||
c = {};
|
c = { $ancestor: null };
|
||||||
c.$create = function(fn,args){
|
c.$create = function(fn,args){
|
||||||
if (args == undefined) args = [];
|
if (args == undefined) args = [];
|
||||||
var o = Object.create(this);
|
var o = Object.create(this);
|
||||||
@ -314,6 +314,7 @@ var rtl = {
|
|||||||
// If newinstancefnname is given, use that function to create the new object.
|
// If newinstancefnname is given, use that function to create the new object.
|
||||||
// If exist call BeforeDestruction and AfterConstruction.
|
// If exist call BeforeDestruction and AfterConstruction.
|
||||||
var c = Object.create(ancestor);
|
var c = Object.create(ancestor);
|
||||||
|
c.$ancestor = null; // no pascal ancestor
|
||||||
c.$create = function(fn,args){
|
c.$create = function(fn,args){
|
||||||
if (args == undefined) args = [];
|
if (args == undefined) args = [];
|
||||||
var o = null;
|
var o = null;
|
||||||
@ -332,6 +333,7 @@ var rtl = {
|
|||||||
if (o.AfterConstruction) o.AfterConstruction();
|
if (o.AfterConstruction) o.AfterConstruction();
|
||||||
} catch($e){
|
} catch($e){
|
||||||
// do not call BeforeDestruction
|
// do not call BeforeDestruction
|
||||||
|
console.log($e);
|
||||||
if (o.Destroy) o.Destroy();
|
if (o.Destroy) o.Destroy();
|
||||||
if (o.$final) this.$final();
|
if (o.$final) this.$final();
|
||||||
throw $e;
|
throw $e;
|
||||||
@ -355,7 +357,7 @@ var rtl = {
|
|||||||
c.$ancestor = ancestor;
|
c.$ancestor = ancestor;
|
||||||
// c.$ancestor === Object.getPrototypeOf(c)
|
// c.$ancestor === Object.getPrototypeOf(c)
|
||||||
} else {
|
} else {
|
||||||
c = {};
|
c = { $ancestor = null };
|
||||||
};
|
};
|
||||||
parent[name] = c;
|
parent[name] = c;
|
||||||
c.$class = c; // Note: o.$class === Object.getPrototypeOf(o)
|
c.$class = c; // Note: o.$class === Object.getPrototypeOf(o)
|
||||||
@ -374,13 +376,13 @@ var rtl = {
|
|||||||
tObjectDestroy: "Destroy",
|
tObjectDestroy: "Destroy",
|
||||||
|
|
||||||
free: function(obj,name){
|
free: function(obj,name){
|
||||||
if (obj[name]==null) return;
|
if (obj[name]==null) return null;
|
||||||
obj[name].$destroy(rtl.tObjectDestroy);
|
obj[name].$destroy(rtl.tObjectDestroy);
|
||||||
obj[name]=null;
|
obj[name]=null;
|
||||||
},
|
},
|
||||||
|
|
||||||
freeLoc: function(obj){
|
freeLoc: function(obj){
|
||||||
if (obj==null) return;
|
if (obj==null) return null;
|
||||||
obj.$destroy(rtl.tObjectDestroy);
|
obj.$destroy(rtl.tObjectDestroy);
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
@ -453,6 +455,7 @@ var rtl = {
|
|||||||
EInvalidCast: null,
|
EInvalidCast: null,
|
||||||
EAbstractError: null,
|
EAbstractError: null,
|
||||||
ERangeError: null,
|
ERangeError: null,
|
||||||
|
EIntOverflow: null;
|
||||||
EPropWriteOnly: null,
|
EPropWriteOnly: null,
|
||||||
|
|
||||||
raiseE: function(typename){
|
raiseE: function(typename){
|
||||||
@ -751,6 +754,12 @@ var rtl = {
|
|||||||
rtl.raiseE("EInvalidCast");
|
rtl.raiseE("EInvalidCast");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
oc: function(i){
|
||||||
|
// overflow check integer
|
||||||
|
if ((Math.floor(i)===i) && (i>=-0x1fffffffffffff) && (i<=0x1fffffffffffff)) return i;
|
||||||
|
rtl.raiseE('EIntOverflow');
|
||||||
|
},
|
||||||
|
|
||||||
rc: function(i,minval,maxval){
|
rc: function(i,minval,maxval){
|
||||||
// range check integer
|
// range check integer
|
||||||
if ((Math.floor(i)===i) && (i>=minval) && (i<=maxval)) return i;
|
if ((Math.floor(i)===i) && (i>=minval) && (i<=maxval)) return i;
|
||||||
@ -1095,6 +1104,7 @@ var rtl = {
|
|||||||
s=' '+s;
|
s=' '+s;
|
||||||
l++;
|
l++;
|
||||||
};
|
};
|
||||||
|
return s;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user