* Patch from Mattias Gaertner with various improvements:

+ changed varname/funcname properties to string, saving many conversion
  + array of record
  + pass by reference
    - pass local var to a var/out parameter
    - pass variable to a var/out parameter
    - pass reference to a var/out parameter
    - pass array element to a var/out parameter
  + proc types
    - implemented as immutable wrapper function
    - assign := nil, proctype (not clone), @function, @method
    - call  explicit and implicit
    - compare equal and notequal with nil, proctype, address, function
    - assigned(proctype)
    - pass as argument
    - methods
    - mode delphi: proctype:=proc
    - mode delphi: functype=funcresulttype
  + class-of
    - assign :=   nil, var
    - call class method
    - call constructor
    - operators =, <>
    - class var, property, method
    - Self in class method
    - typecast

git-svn-id: trunk@35472 -
This commit is contained in:
michael 2017-02-22 20:59:23 +00:00
parent f022fdc848
commit 2d36af85bb
3 changed files with 3777 additions and 759 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -157,11 +157,24 @@ var rtl = {
},
createCallback: function(scope, fn){
var wrapper = function(){
var cb = function(){
return fn.apply(scope,arguments);
};
wrapper.fn = fn;
return wrapper;
cb.fn = fn;
cb.scope = scope;
return cb;
},
cloneCallback: function(cb){
return rtl.createCallback(cb.scope,cb.fn);
},
eqCallback: function(a,b){
if (a==null){
return (b==null);
} else {
return (b!=null) && (a.scope==b.scope) && (a.fn==b.fn);
}
},
createClass: function(owner,name,ancestor,initfn){
@ -205,6 +218,8 @@ var rtl = {
arr.length = newlength;
if (rtl.isArray(defaultvalue)){
for (var i=oldlen; i<newlength; i++) arr[i]=[]; // new array
} else if (rtl.isFunction(defaultvalue)){
for (var i=oldlen; i<newlength; i++) arr[i]=new defaultvalue(); // new record
} else {
for (var i=oldlen; i<newlength; i++) arr[i]=defaultvalue;
}