Browse Source

* synchronized with trunk

git-svn-id: branches/wasm@46771 -
nickysn 4 years ago
parent
commit
13386e603d

+ 2 - 1
.gitattributes

@@ -13449,6 +13449,7 @@ tests/test/cg/cdecl/taoc3.pp svneol=native#text/plain
 tests/test/cg/cdecl/taoc4.pp svneol=native#text/plain
 tests/test/cg/cdecl/taoc4.pp svneol=native#text/plain
 tests/test/cg/cdecl/taoc5.pp svneol=native#text/plain
 tests/test/cg/cdecl/taoc5.pp svneol=native#text/plain
 tests/test/cg/cdecl/taoc6.pp svneol=native#text/plain
 tests/test/cg/cdecl/taoc6.pp svneol=native#text/plain
+tests/test/cg/cpudefs.inc svneol=native#text/plain
 tests/test/cg/obj/aix/powerpc/cpptcl1.o -text
 tests/test/cg/obj/aix/powerpc/cpptcl1.o -text
 tests/test/cg/obj/aix/powerpc/cpptcl2.o -text
 tests/test/cg/obj/aix/powerpc/cpptcl2.o -text
 tests/test/cg/obj/aix/powerpc/ctest.o -text
 tests/test/cg/obj/aix/powerpc/ctest.o -text
@@ -13821,7 +13822,6 @@ tests/test/cg/tcalcst5.pp svneol=native#text/plain
 tests/test/cg/tcalcst6.pp svneol=native#text/plain
 tests/test/cg/tcalcst6.pp svneol=native#text/plain
 tests/test/cg/tcalcst7.pp svneol=native#text/plain
 tests/test/cg/tcalcst7.pp svneol=native#text/plain
 tests/test/cg/tcalcst8.pp svneol=native#text/plain
 tests/test/cg/tcalcst8.pp svneol=native#text/plain
-tests/test/cg/tcaldefs.inc svneol=native#text/plain
 tests/test/cg/tcalext.pp svneol=native#text/plain
 tests/test/cg/tcalext.pp svneol=native#text/plain
 tests/test/cg/tcalext3.pp svneol=native#text/plain
 tests/test/cg/tcalext3.pp svneol=native#text/plain
 tests/test/cg/tcalext4.pp svneol=native#text/plain
 tests/test/cg/tcalext4.pp svneol=native#text/plain
@@ -18484,6 +18484,7 @@ tests/webtbs/tw37554.pp svneol=native#text/pascal
 tests/webtbs/tw3758.pp svneol=native#text/plain
 tests/webtbs/tw3758.pp svneol=native#text/plain
 tests/webtbs/tw3764.pp svneol=native#text/plain
 tests/webtbs/tw3764.pp svneol=native#text/plain
 tests/webtbs/tw3765.pp svneol=native#text/plain
 tests/webtbs/tw3765.pp svneol=native#text/plain
+tests/webtbs/tw37650.pp svneol=native#text/pascal
 tests/webtbs/tw3768.pp svneol=native#text/plain
 tests/webtbs/tw3768.pp svneol=native#text/plain
 tests/webtbs/tw3774.pp svneol=native#text/plain
 tests/webtbs/tw3774.pp svneol=native#text/plain
 tests/webtbs/tw3777.pp svneol=native#text/plain
 tests/webtbs/tw3777.pp svneol=native#text/plain

+ 6 - 1
compiler/pexpr.pas

@@ -114,7 +114,12 @@ implementation
                end
                end
              else
              else
                begin
                begin
-                if (tordconstnode(p).value<=0) then
+                { the node is a generic param while parsing a generic def
+                  so disable the range checking for the string }
+                if parse_generic and
+                  (nf_generic_para in p.flags) then
+                  tordconstnode(p).value:=255;
+                if tordconstnode(p).value<=0 then
                   begin
                   begin
                      Message(parser_e_invalid_string_size);
                      Message(parser_e_invalid_string_size);
                      tordconstnode(p).value:=255;
                      tordconstnode(p).value:=255;

+ 16 - 17
compiler/xtensa/cpupara.pas

@@ -49,7 +49,7 @@ unit cpupara;
            paras : tparalist; var curintreg : tsuperregister;
            paras : tparalist; var curintreg : tsuperregister;
            var cur_stack_offset : aword; varargsparas : boolean) : longint;
            var cur_stack_offset : aword; varargsparas : boolean) : longint;
          function create_paraloc1_info_intern(p: tabstractprocdef; side: tcallercallee; paradef: tdef; var loc: TCGPara; varspez: tvarspez; varoptions: tvaroptions;
          function create_paraloc1_info_intern(p: tabstractprocdef; side: tcallercallee; paradef: tdef; var loc: TCGPara; varspez: tvarspez; varoptions: tvaroptions;
-           var curintreg: tsuperregister; var cur_stack_offset: aword; varargsparas: boolean): longint;
+           var curintreg: tsuperregister; var cur_stack_offset: aword; varargsparas, funcret: boolean): longint;
        end;
        end;
 
 
   implementation
   implementation
@@ -153,10 +153,7 @@ unit cpupara;
           recorddef :
           recorddef :
             result:=(varspez = vs_const);
             result:=(varspez = vs_const);
           arraydef:
           arraydef:
-            result:=((varspez = vs_const) and (tarraydef(def).highrange>=tarraydef(def).lowrange)) or
-                             is_open_array(def) or
-                             is_array_of_const(def) or
-                             is_array_constructor(def);
+            result:=true;
           objectdef :
           objectdef :
             result:=is_object(def) and (varspez = vs_const);
             result:=is_object(def) and (varspez = vs_const);
           variantdef,
           variantdef,
@@ -252,7 +249,7 @@ unit cpupara;
         else if (result.def.size>4) and (result.def.size<=16) then
         else if (result.def.size>4) and (result.def.size<=16) then
           begin
           begin
             init_values(p,side,curintreg,cur_stack_offset);
             init_values(p,side,curintreg,cur_stack_offset);
-            create_paraloc1_info_intern(p,side,result.def,result,vs_value,[],curintreg,cur_stack_offset,false);
+            create_paraloc1_info_intern(p,side,result.def,result,vs_value,[],curintreg,cur_stack_offset,false,true);
 
 
             { check if everything is ok }
             { check if everything is ok }
             if result.location^.loc=LOC_INVALID then
             if result.location^.loc=LOC_INVALID then
@@ -320,7 +317,7 @@ unit cpupara;
 
 
 
 
     function tcpuparamanager.create_paraloc1_info_intern(p : tabstractprocdef; side: tcallercallee; paradef:tdef;var loc : TCGPara;varspez : tvarspez;varoptions : tvaroptions;
     function tcpuparamanager.create_paraloc1_info_intern(p : tabstractprocdef; side: tcallercallee; paradef:tdef;var loc : TCGPara;varspez : tvarspez;varoptions : tvaroptions;
-      var curintreg: tsuperregister; var cur_stack_offset: aword; varargsparas: boolean):longint;
+      var curintreg: tsuperregister; var cur_stack_offset: aword; varargsparas, funcret: boolean):longint;
       var
       var
         paralen: aint;
         paralen: aint;
         locdef,
         locdef,
@@ -349,19 +346,21 @@ unit cpupara;
             exit;
             exit;
           end;
           end;
 
 
-        if push_addr_param(varspez,paradef,p.proccalloption) then
+        if not is_special_array(paradef) then
+          paralen:=paradef.size
+        else
+          paralen:=tcgsize2size[def_cgsize(paradef)];
+
+        if (not(funcret) and push_addr_param(varspez,paradef,p.proccalloption)) or
+          (funcret and (paralen>24)) then
           begin
           begin
             paradef:=cpointerdef.getreusable_no_free(paradef);
             paradef:=cpointerdef.getreusable_no_free(paradef);
             locpara:=LOC_REGISTER;
             locpara:=LOC_REGISTER;
-            paracgsize := OS_ADDR;
-            paralen := tcgsize2size[OS_ADDR];
+            paracgsize:=OS_ADDR;
+            paralen:=tcgsize2size[OS_ADDR];
           end
           end
         else
         else
           begin
           begin
-            if not is_special_array(paradef) then
-              paralen := paradef.size
-            else
-              paralen := tcgsize2size[def_cgsize(paradef)];
             if (paradef.typ in [objectdef,arraydef,recorddef,setdef,stringdef]) and
             if (paradef.typ in [objectdef,arraydef,recorddef,setdef,stringdef]) and
                not is_special_array(paradef) and
                not is_special_array(paradef) and
                (varspez in [vs_value,vs_const]) then
                (varspez in [vs_value,vs_const]) then
@@ -369,10 +368,10 @@ unit cpupara;
             else
             else
               begin
               begin
                 paracgsize:=def_cgsize(paradef);
                 paracgsize:=def_cgsize(paradef);
-                if (paracgsize=OS_NO) then
+                if paracgsize=OS_NO then
                   begin
                   begin
                     paracgsize:=OS_ADDR;
                     paracgsize:=OS_ADDR;
-                    paralen := tcgsize2size[OS_ADDR];
+                    paralen:=tcgsize2size[OS_ADDR];
                     paradef:=voidpointertype;
                     paradef:=voidpointertype;
                   end;
                   end;
               end;
               end;
@@ -481,7 +480,7 @@ unit cpupara;
         result:=0;
         result:=0;
         for i:=0 to paras.count-1 do
         for i:=0 to paras.count-1 do
           result:=create_paraloc1_info_intern(p,side,tparavarsym(paras[i]).vardef,tparavarsym(paras[i]).paraloc[side],tparavarsym(paras[i]).varspez,
           result:=create_paraloc1_info_intern(p,side,tparavarsym(paras[i]).vardef,tparavarsym(paras[i]).paraloc[side],tparavarsym(paras[i]).varspez,
-            tparavarsym(paras[i]).varoptions,curintreg,cur_stack_offset,false);
+            tparavarsym(paras[i]).varoptions,curintreg,cur_stack_offset,false,false);
       end;
       end;
 
 
 
 

+ 7 - 4
packages/chm/src/chmls.lpr

@@ -482,7 +482,7 @@ begin
    s:=r.readstringsentry(cnt);
    s:=r.readstringsentry(cnt);
 end;
 end;
 
 
-
+var dx : dword;
 begin
 begin
   setlength(s,4);
   setlength(s,4);
   for i:=1 to 4 do
   for i:=1 to 4 do
@@ -529,7 +529,8 @@ begin
   Writeln('Unknown. Often 1. Also 0, 3.                  :',leton(m.readdword));
   Writeln('Unknown. Often 1. Also 0, 3.                  :',leton(m.readdword));
   cnt2:=m.ReadDWordLE;
   cnt2:=m.ReadDWordLE;
   Writeln('Number of files in the [MERGE FILES] list     :',cnt2);
   Writeln('Number of files in the [MERGE FILES] list     :',cnt2);
-  Writeln('Unknown. Often 0.                             :',leton(m.readdword),'(Non-zero mostly in files with some files in the merge files list)');
+  dx:=leton(m.readdword);
+  Writeln('Unknown. Often 0.                             :',dx,' =$',inttohex(dx,8),'(Non-zero mostly in files with some files in the merge files list)');
   if cnt2>0 then
   if cnt2>0 then
     for i:=0 to cnt2-1 do
     for i:=0 to cnt2-1 do
       begin
       begin
@@ -805,7 +806,7 @@ begin
   writeln(' Non zero if there are ALinks      : ',m.readdwordLE );
   writeln(' Non zero if there are ALinks      : ',m.readdwordLE );
   ts.dwlowdatetime:=m.readdwordLE;
   ts.dwlowdatetime:=m.readdwordLE;
   ts.dwhighdatetime:=m.readdwordLE;
   ts.dwhighdatetime:=m.readdwordLE;
-  writeln(' Timestamp                         : ',ts.dwhighdatetime,':', ts.dwlowdatetime );
+  writeln(' Timestamp                         : ',ts.dwhighdatetime,':', ts.dwlowdatetime, ' = $',inttohex(ts.dwhighdatetime,8),': $', inttohex(ts.dwlowdatetime,8));
   writeln(' 0/1 except in dsmsdn.chi has 1    : ',m.readdwordLE );
   writeln(' 0/1 except in dsmsdn.chi has 1    : ',m.readdwordLE );
   writeln(' 0 (unknown)                       : ',m.readdwordLE );
   writeln(' 0 (unknown)                       : ',m.readdwordLE );
 end;
 end;
@@ -831,6 +832,7 @@ begin
     writeln('   x size is larger than 16');
     writeln('   x size is larger than 16');
   m.position:=m.position+chsz-16;
   m.position:=m.position+chsz-16;
 end;
 end;
+var dx : dword;
 
 
 begin
 begin
   symbolname:='helpid';
   symbolname:='helpid';
@@ -878,7 +880,8 @@ begin
             8 : printentry8(m,chunksize);
             8 : printentry8(m,chunksize);
             9 : Writeln('(9)  CHM compiler version          :',printnulterminated(chunksize));
             9 : Writeln('(9)  CHM compiler version          :',printnulterminated(chunksize));
             10: begin
             10: begin
-                  writeln('(10) Timestamp (32-bit?)           :',m.readdwordle);
+                  dx:=m.readdwordle;
+                  writeln('(10) Timestamp (32-bit?)           :',dx,' , = $',inttohex(dx,8));
                   m.position:=m.position+chunksize-4;
                   m.position:=m.position+chunksize-4;
                 end;
                 end;
             11: Writeln('(11)  DWord when Binary TOC is on   :',m.readdwordle, '(= entry in #urltbl has same first dword');
             11: Writeln('(11)  DWord when Binary TOC is on   :',m.readdwordle, '(= entry in #urltbl has same first dword');

+ 18 - 18
packages/fcl-passrc/src/pasresolveeval.pas

@@ -1027,27 +1027,27 @@ var
 begin
 begin
   if o=nil then
   if o=nil then
     Result:='nil'
     Result:='nil'
-  else if o is TPasArrayType then
+  else if (o is TPasArrayType) and (TPasArrayType(o).Name='') then
     begin
     begin
-      if TPasArrayType(o).ElType = nil then
-          Result:='array of const'
-      else
-        Result:=Format('TArray<%s>', [TPasArrayType(o).ElType.Name]);
+    if TPasArrayType(o).ElType = nil then
+      Result:='array of const'
+    else
+      Result:=Format('TArray<%s>', [TPasArrayType(o).ElType.Name]);
     end
     end
-    else if o is TPasElement then
+  else if o is TPasElement then
+    begin
+    Result:=TPasElement(o).Name;
+    if o is TPasGenericType then
       begin
       begin
-      Result:=TPasElement(o).Name;
-      if o is TPasGenericType then
-        begin
-        GenType:=TPasGenericType(o);
-        if (GenType.GenericTemplateTypes<>nil)
-            and (GenType.GenericTemplateTypes.Count>0) then
-          Result:=Result+GetGenericParamCommas(GenType.GenericTemplateTypes.Count);
-        end;
-      Result:=Result+':'+o.ClassName;
-      end
-    else
-      Result:=o.ClassName;
+      GenType:=TPasGenericType(o);
+      if (GenType.GenericTemplateTypes<>nil)
+          and (GenType.GenericTemplateTypes.Count>0) then
+        Result:=Result+GetGenericParamCommas(GenType.GenericTemplateTypes.Count);
+      end;
+    Result:=Result+':'+o.ClassName;
+    end
+  else
+    Result:=o.ClassName;
 end;
 end;
 
 
 function GetObjPath(o: TObject): string;
 function GetObjPath(o: TObject): string;

+ 12 - 4
packages/fcl-passrc/src/pasresolver.pp

@@ -986,12 +986,14 @@ type
   TPasArrayScope = Class(TPasGenericScope)
   TPasArrayScope = Class(TPasGenericScope)
   public
   public
   end;
   end;
+  TPasArrayScopeClass = class of TPasArrayScope;
 
 
   { TPasProcTypeScope }
   { TPasProcTypeScope }
 
 
   TPasProcTypeScope = Class(TPasGenericScope)
   TPasProcTypeScope = Class(TPasGenericScope)
   public
   public
   end;
   end;
+  TPasProcTypeScopeClass = class of TPasProcTypeScope;
 
 
   { TPasClassOrRecordScope }
   { TPasClassOrRecordScope }
 
 
@@ -1510,10 +1512,12 @@ type
     FOptions: TPasResolverOptions;
     FOptions: TPasResolverOptions;
     FPendingForwardProcs: TFPList; // list of TPasElement needed to check for forward procs
     FPendingForwardProcs: TFPList; // list of TPasElement needed to check for forward procs
     FRootElement: TPasModule;
     FRootElement: TPasModule;
+    FScopeClass_Array: TPasArrayScopeClass;
     FScopeClass_Class: TPasClassScopeClass;
     FScopeClass_Class: TPasClassScopeClass;
     FScopeClass_InitialFinalization: TPasInitialFinalizationScopeClass;
     FScopeClass_InitialFinalization: TPasInitialFinalizationScopeClass;
     FScopeClass_Module: TPasModuleScopeClass;
     FScopeClass_Module: TPasModuleScopeClass;
     FScopeClass_Proc: TPasProcedureScopeClass;
     FScopeClass_Proc: TPasProcedureScopeClass;
+    FScopeClass_ProcType: TPasProcTypeScopeClass;
     FScopeClass_Record: TPasRecordScopeClass;
     FScopeClass_Record: TPasRecordScopeClass;
     FScopeClass_Section: TPasSectionScopeClass;
     FScopeClass_Section: TPasSectionScopeClass;
     FScopeClass_WithExpr: TPasWithExprScopeClass;
     FScopeClass_WithExpr: TPasWithExprScopeClass;
@@ -2424,10 +2428,12 @@ type
     property ScopeCount: integer read FScopeCount;
     property ScopeCount: integer read FScopeCount;
     property TopScope: TPasScope read FTopScope;
     property TopScope: TPasScope read FTopScope;
     property DefaultScope: TPasDefaultScope read FDefaultScope write FDefaultScope;
     property DefaultScope: TPasDefaultScope read FDefaultScope write FDefaultScope;
+    property ScopeClass_Array: TPasArrayScopeClass read FScopeClass_Array write FScopeClass_Array;
     property ScopeClass_Class: TPasClassScopeClass read FScopeClass_Class write FScopeClass_Class;
     property ScopeClass_Class: TPasClassScopeClass read FScopeClass_Class write FScopeClass_Class;
     property ScopeClass_InitialFinalization: TPasInitialFinalizationScopeClass read FScopeClass_InitialFinalization write FScopeClass_InitialFinalization;
     property ScopeClass_InitialFinalization: TPasInitialFinalizationScopeClass read FScopeClass_InitialFinalization write FScopeClass_InitialFinalization;
     property ScopeClass_Module: TPasModuleScopeClass read FScopeClass_Module write FScopeClass_Module;
     property ScopeClass_Module: TPasModuleScopeClass read FScopeClass_Module write FScopeClass_Module;
     property ScopeClass_Procedure: TPasProcedureScopeClass read FScopeClass_Proc write FScopeClass_Proc;
     property ScopeClass_Procedure: TPasProcedureScopeClass read FScopeClass_Proc write FScopeClass_Proc;
+    property ScopeClass_ProcType: TPasProcTypeScopeClass read FScopeClass_ProcType write FScopeClass_ProcType;
     property ScopeClass_Record: TPasRecordScopeClass read FScopeClass_Record write FScopeClass_Record;
     property ScopeClass_Record: TPasRecordScopeClass read FScopeClass_Record write FScopeClass_Record;
     property ScopeClass_Section: TPasSectionScopeClass read FScopeClass_Section write FScopeClass_Section;
     property ScopeClass_Section: TPasSectionScopeClass read FScopeClass_Section write FScopeClass_Section;
     property ScopeClass_WithExpr: TPasWithExprScopeClass read FScopeClass_WithExpr write FScopeClass_WithExpr;
     property ScopeClass_WithExpr: TPasWithExprScopeClass read FScopeClass_WithExpr write FScopeClass_WithExpr;
@@ -11910,7 +11916,7 @@ begin
 
 
     if TypeParams<>nil then
     if TypeParams<>nil then
       begin
       begin
-      Scope:=TPasArrayScope(PushScope(El,TPasArrayScope));
+      Scope:=TPasArrayScope(PushScope(El,ScopeClass_Array));
       AddGenericTemplateIdentifiers(TypeParams,Scope);
       AddGenericTemplateIdentifiers(TypeParams,Scope);
       end;
       end;
   end else if TypeParams<>nil then
   end else if TypeParams<>nil then
@@ -12239,7 +12245,7 @@ begin
 
 
     if TypeParams<>nil then
     if TypeParams<>nil then
       begin
       begin
-      Scope:=TPasProcTypeScope(PushScope(El,TPasProcTypeScope));
+      Scope:=TPasProcTypeScope(PushScope(El,ScopeClass_ProcType));
       AddGenericTemplateIdentifiers(TypeParams,Scope);
       AddGenericTemplateIdentifiers(TypeParams,Scope);
       end;
       end;
   end else if TypeParams<>nil then
   end else if TypeParams<>nil then
@@ -17664,7 +17670,7 @@ var
 begin
 begin
   if GenEl.GenericTemplateTypes<>nil then
   if GenEl.GenericTemplateTypes<>nil then
     begin
     begin
-    GenScope:=TPasGenericScope(PushScope(SpecEl,TPasProcTypeScope));
+    GenScope:=TPasGenericScope(PushScope(SpecEl,ScopeClass_ProcType));
     if SpecializedItem<>nil then
     if SpecializedItem<>nil then
       begin
       begin
       // specialized procedure type
       // specialized procedure type
@@ -18148,7 +18154,7 @@ begin
   SpecEl.PackMode:=GenEl.PackMode;
   SpecEl.PackMode:=GenEl.PackMode;
   if GenEl.GenericTemplateTypes<>nil then
   if GenEl.GenericTemplateTypes<>nil then
     begin
     begin
-    GenScope:=TPasGenericScope(PushScope(SpecEl,TPasArrayScope));
+    GenScope:=TPasGenericScope(PushScope(SpecEl,ScopeClass_Array));
     if SpecializedItem<>nil then
     if SpecializedItem<>nil then
       begin
       begin
       // specialized generic array
       // specialized generic array
@@ -20525,10 +20531,12 @@ begin
   cInterfaceToTGUID:=cTypeConversion+1;
   cInterfaceToTGUID:=cTypeConversion+1;
   cInterfaceToString:=cTypeConversion+2;
   cInterfaceToString:=cTypeConversion+2;
 
 
+  FScopeClass_Array:=TPasArrayScope;
   FScopeClass_Class:=TPasClassScope;
   FScopeClass_Class:=TPasClassScope;
   FScopeClass_InitialFinalization:=TPasInitialFinalizationScope;
   FScopeClass_InitialFinalization:=TPasInitialFinalizationScope;
   FScopeClass_Module:=TPasModuleScope;
   FScopeClass_Module:=TPasModuleScope;
   FScopeClass_Proc:=TPasProcedureScope;
   FScopeClass_Proc:=TPasProcedureScope;
+  FScopeClass_ProcType:=TPasProcTypeScope;
   FScopeClass_Record:=TPasRecordScope;
   FScopeClass_Record:=TPasRecordScope;
   FScopeClass_Section:=TPasSectionScope;
   FScopeClass_Section:=TPasSectionScope;
   FScopeClass_WithExpr:=TPasWithExprScope;
   FScopeClass_WithExpr:=TPasWithExprScope;

+ 9 - 17
packages/openssl/src/openssl.pas

@@ -1152,7 +1152,7 @@ var
   function EvpPkeyAssign(pkey: PEVP_PKEY; _type: cInt; key: Prsa): cInt;
   function EvpPkeyAssign(pkey: PEVP_PKEY; _type: cInt; key: Prsa): cInt;
   function EvpGetDigestByName(Name: String): PEVP_MD;
   function EvpGetDigestByName(Name: String): PEVP_MD;
   procedure EVPcleanup;
   procedure EVPcleanup;
-  function SSLeayversion(t: cInt): string;  deprecated 'For 1.1+ use OpenSSL_version';
+  function SSLeayversion(t: cInt): string;  deprecated 'For 1.1+ use OpenSSLGetVersion';
   procedure ErrErrorString(e: cInt; var buf: string; len: cInt);
   procedure ErrErrorString(e: cInt; var buf: string; len: cInt);
   function ErrGetError: cInt;
   function ErrGetError: cInt;
   procedure ErrClearError;
   procedure ErrClearError;
@@ -1243,7 +1243,7 @@ var
 
 
   // Crypto Functions
   // Crypto Functions
 
 
-  function SSLeay_version(t: cint): PChar;
+  function SSLeay_version(t: cint): PChar; deprecated 'For 1.1+ use OpenSSLGetVersion';
 
 
   // EVP Functions - evp.h
   // EVP Functions - evp.h
   function EVP_des_ede3_cbc : PEVP_CIPHER;
   function EVP_des_ede3_cbc : PEVP_CIPHER;
@@ -1551,7 +1551,6 @@ end;
 
 
 type
 type
 // libssl.dll
 // libssl.dll
-  TOpenSSLversion = function (arg : cint) : pchar; cdecl;
   TSslGetError = function(s: PSSL; ret_code: cInt):cInt; cdecl;
   TSslGetError = function(s: PSSL; ret_code: cInt):cInt; cdecl;
   TSslLibraryInit = function:cInt; cdecl;
   TSslLibraryInit = function:cInt; cdecl;
   TOPENSSL_INIT_new = function : POPENSSL_INIT_SETTINGS; cdecl;
   TOPENSSL_INIT_new = function : POPENSSL_INIT_SETTINGS; cdecl;
@@ -1631,6 +1630,7 @@ type
   TEvpPkeyAssign = function(pkey: PEVP_PKEY; _type: cInt; key: Prsa): cInt; cdecl;
   TEvpPkeyAssign = function(pkey: PEVP_PKEY; _type: cInt; key: Prsa): cInt; cdecl;
   TEvpGetDigestByName = function(Name: PChar): PEVP_MD; cdecl;
   TEvpGetDigestByName = function(Name: PChar): PEVP_MD; cdecl;
   TEVPcleanup = procedure; cdecl;
   TEVPcleanup = procedure; cdecl;
+  TOpenSSLversion = function (arg : cint) : pchar; cdecl;
   TSSLeayversion = function(t: cInt): PChar; cdecl;
   TSSLeayversion = function(t: cInt): PChar; cdecl;
   TErrErrorString = procedure(e: cInt; buf: PChar; len: cInt); cdecl;
   TErrErrorString = procedure(e: cInt; buf: PChar; len: cInt); cdecl;
   TErrGetError = function: cInt; cdecl;
   TErrGetError = function: cInt; cdecl;
@@ -1716,7 +1716,6 @@ type
 
 
   // Crypto Functions
   // Crypto Functions
 
 
-  TSSLeay_version = function(t: cint): PChar; cdecl;
   TCRYPTOcleanupAllExData = procedure; cdecl;
   TCRYPTOcleanupAllExData = procedure; cdecl;
   TOPENSSLaddallalgorithms = procedure; cdecl;
   TOPENSSLaddallalgorithms = procedure; cdecl;
 
 
@@ -1789,7 +1788,6 @@ type
 
 
 var
 var
 // libssl.dll
 // libssl.dll
-  _OpenSSLVersion : TOpenSSLversion = Nil;
   _SslGetError: TSslGetError = nil;
   _SslGetError: TSslGetError = nil;
   _SslLibraryInit: TSslLibraryInit = nil;
   _SslLibraryInit: TSslLibraryInit = nil;
   _OPENSSL_init_ssl : TOPENSSL_init_ssl = Nil;
   _OPENSSL_init_ssl : TOPENSSL_init_ssl = Nil;
@@ -1868,6 +1866,7 @@ var
   _EvpPkeyAssign: TEvpPkeyAssign = nil;
   _EvpPkeyAssign: TEvpPkeyAssign = nil;
   _EvpGetDigestByName: TEvpGetDigestByName = nil;
   _EvpGetDigestByName: TEvpGetDigestByName = nil;
   _EVPcleanup: TEVPcleanup = nil;
   _EVPcleanup: TEVPcleanup = nil;
+  _OpenSSLVersion : TOpenSSLversion = Nil;
   _SSLeayversion: TSSLeayversion = nil;
   _SSLeayversion: TSSLeayversion = nil;
   _ErrErrorString: TErrErrorString = nil;
   _ErrErrorString: TErrErrorString = nil;
   _ErrGetError: TErrGetError = nil;
   _ErrGetError: TErrGetError = nil;
@@ -1971,7 +1970,6 @@ var
 
 
   // Crypto Functions
   // Crypto Functions
 
 
-  _SSLeay_version: TSSLeay_version = nil;
   _CRYPTOcleanupAllExData: TCRYPTOcleanupAllExData = nil;
   _CRYPTOcleanupAllExData: TCRYPTOcleanupAllExData = nil;
   _OPENSSLaddallalgorithms: TOPENSSLaddallalgorithms = nil;
   _OPENSSLaddallalgorithms: TOPENSSLaddallalgorithms = nil;
 
 
@@ -3350,8 +3348,8 @@ end;
 
 
 function SSLeay_version(t: cint): PChar;
 function SSLeay_version(t: cint): PChar;
 begin
 begin
-  if InitSSLInterface and Assigned(_SSLeay_version) then
-    Result := _SSLeay_version(t)
+  if InitSSLInterface and Assigned(_SSLeayversion) then
+    Result := _SSLeayversion(t)
   else
   else
     Result := nil;
     Result := nil;
 end;
 end;
@@ -4858,7 +4856,6 @@ end;
 Procedure LoadSSLEntryPoints;
 Procedure LoadSSLEntryPoints;
 
 
 begin
 begin
-  _OpenSSLVersion := GetProcAddr(SSLLibHandle, 'OpenSSL_version');
   _SslGetError := GetProcAddr(SSLLibHandle, 'SSL_get_error');
   _SslGetError := GetProcAddr(SSLLibHandle, 'SSL_get_error');
   _SslLibraryInit := GetProcAddr(SSLLibHandle, 'SSL_library_init');
   _SslLibraryInit := GetProcAddr(SSLLibHandle, 'SSL_library_init');
   _OPENSSL_init_ssl := GetProcAddr(SSLLibHandle, 'OPENSSL_init_ssl');
   _OPENSSL_init_ssl := GetProcAddr(SSLLibHandle, 'OPENSSL_init_ssl');
@@ -4950,9 +4947,10 @@ begin
   _EvpPkeyAssign := GetProcAddr(SSLUtilHandle, 'EVP_PKEY_assign');
   _EvpPkeyAssign := GetProcAddr(SSLUtilHandle, 'EVP_PKEY_assign');
   _EVPCleanup := GetProcAddr(SSLUtilHandle, 'EVP_cleanup');
   _EVPCleanup := GetProcAddr(SSLUtilHandle, 'EVP_cleanup');
   _EvpGetDigestByName := GetProcAddr(SSLUtilHandle, 'EVP_get_digestbyname');
   _EvpGetDigestByName := GetProcAddr(SSLUtilHandle, 'EVP_get_digestbyname');
+  _OpenSSLVersion := GetProcAddr(SSLUtilHandle, 'OpenSSL_version');
   _SSLeayversion := GetProcAddr(SSLUtilHandle, 'SSLeay_version');
   _SSLeayversion := GetProcAddr(SSLUtilHandle, 'SSLeay_version');
   if @_SSLeayversion=Nil then
   if @_SSLeayversion=Nil then
-    _SSLeayversion := GetProcAddr(SSLUtilHandle, 'OpenSSL_version');
+    _SSLeayversion := _OpenSSLVersion;
   _ErrErrorString := GetProcAddr(SSLUtilHandle, 'ERR_error_string_n');
   _ErrErrorString := GetProcAddr(SSLUtilHandle, 'ERR_error_string_n');
   _ErrGetError := GetProcAddr(SSLUtilHandle, 'ERR_get_error');
   _ErrGetError := GetProcAddr(SSLUtilHandle, 'ERR_get_error');
   _ErrClearError := GetProcAddr(SSLUtilHandle, 'ERR_clear_error');
   _ErrClearError := GetProcAddr(SSLUtilHandle, 'ERR_clear_error');
@@ -5090,8 +5088,6 @@ begin
   _BIO_s_file := GetProcAddr(SSLUtilHandle, 'BIO_s_file');
   _BIO_s_file := GetProcAddr(SSLUtilHandle, 'BIO_s_file');
   _BIO_new_file := GetProcAddr(SSLUtilHandle, 'BIO_new_file');
   _BIO_new_file := GetProcAddr(SSLUtilHandle, 'BIO_new_file');
   _BIO_new_mem_buf := GetProcAddr(SSLUtilHandle, 'BIO_new_mem_buf');
   _BIO_new_mem_buf := GetProcAddr(SSLUtilHandle, 'BIO_new_mem_buf');
-  // Crypto Functions
-  _SSLeay_version := GetProcAddr(SSLUtilHandle, 'SSLeay_version');
   // PKCS7
   // PKCS7
   _PKCS7_ISSUER_AND_SERIAL_new:=GetProcAddr(SSLUtilHandle,'PKCS7_ISSUER_AND_SERIAL_new');
   _PKCS7_ISSUER_AND_SERIAL_new:=GetProcAddr(SSLUtilHandle,'PKCS7_ISSUER_AND_SERIAL_new');
   _PKCS7_ISSUER_AND_SERIAL_free:=GetProcAddr(SSLUtilHandle,'PKCS7_ISSUER_AND_SERIAL_free');
   _PKCS7_ISSUER_AND_SERIAL_free:=GetProcAddr(SSLUtilHandle,'PKCS7_ISSUER_AND_SERIAL_free');
@@ -5217,7 +5213,6 @@ end;
 Procedure ClearSSLEntryPoints;
 Procedure ClearSSLEntryPoints;
 
 
 begin
 begin
-  _OpenSSLVersion := Nil;
   _SslGetError := nil;
   _SslGetError := nil;
   _SslLibraryInit := nil;
   _SslLibraryInit := nil;
   _OPENSSL_init_ssl:=Nil;
   _OPENSSL_init_ssl:=Nil;
@@ -5396,6 +5391,7 @@ end;
 Procedure ClearUtilEntryPoints;
 Procedure ClearUtilEntryPoints;
 
 
 begin
 begin
+  _OpenSSLVersion := Nil;
   _SSLeayversion := nil;
   _SSLeayversion := nil;
   _ERR_load_crypto_strings := nil;
   _ERR_load_crypto_strings := nil;
   _OPENSSL_init_crypto:=Nil;
   _OPENSSL_init_crypto:=Nil;
@@ -5564,10 +5560,6 @@ begin
   _BIO_s_file := nil;
   _BIO_s_file := nil;
   _BIO_new_file := nil;
   _BIO_new_file := nil;
   _BIO_new_mem_buf := nil;
   _BIO_new_mem_buf := nil;
-
-  // Crypto Functions
-
-  _SSLeay_version := nil;
 end;
 end;
 
 
 procedure locking_callback(mode, ltype: integer; lfile: PChar; line: integer); cdecl;
 procedure locking_callback(mode, ltype: integer; lfile: PChar; line: integer); cdecl;

+ 96 - 24
packages/pastojs/src/fppas2js.pp

@@ -1166,6 +1166,7 @@ type
 
 
   TPas2JSClassScope = class(TPasClassScope)
   TPas2JSClassScope = class(TPasClassScope)
   public
   public
+    LongName: string;
     NewInstanceFunction: TPasClassFunction;
     NewInstanceFunction: TPasClassFunction;
     GUID: string;
     GUID: string;
     ElevatedLocals: TPas2jsElevatedLocals;
     ElevatedLocals: TPas2jsElevatedLocals;
@@ -1183,6 +1184,7 @@ type
 
 
   TPas2JSRecordScope = class(TPasRecordScope)
   TPas2JSRecordScope = class(TPasRecordScope)
   public
   public
+    LongName: string;
     MemberOverloadsRenamed: boolean;
     MemberOverloadsRenamed: boolean;
   end;
   end;
 
 
@@ -1191,6 +1193,7 @@ type
   TPas2JSProcedureScope = class(TPasProcedureScope)
   TPas2JSProcedureScope = class(TPasProcedureScope)
   public
   public
     OverloadName: string;
     OverloadName: string;
+    LongName: string;
     ResultVarName: string; // valid in implementation ProcScope, empty means use ResolverResultVar
     ResultVarName: string; // valid in implementation ProcScope, empty means use ResolverResultVar
     BodyOverloadsRenamed: boolean;
     BodyOverloadsRenamed: boolean;
     BodyJS: string; // Option coStoreProcJS: stored in ImplScope
     BodyJS: string; // Option coStoreProcJS: stored in ImplScope
@@ -1200,6 +1203,20 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
   end;
   end;
 
 
+  { TPas2JSArrayScope }
+
+  TPas2JSArrayScope = Class(TPasArrayScope)
+  public
+    LongName: string;
+  end;
+
+  { TPas2JSProcTypeScope }
+
+  TPas2JSProcTypeScope = Class(TPasProcTypeScope)
+  public
+    LongName: string;
+  end;
+
   { TPas2JSWithExprScope }
   { TPas2JSWithExprScope }
 
 
   TPas2JSWithExprScope = class(TPasWithExprScope)
   TPas2JSWithExprScope = class(TPasWithExprScope)
@@ -1495,9 +1512,12 @@ type
     function GenerateGUID(El: TPasClassType): string; virtual;
     function GenerateGUID(El: TPasClassType): string; virtual;
   protected
   protected
     // generic/specialize
     // generic/specialize
+    procedure SpecializeGenericIntf(SpecializedItem: TPRSpecializedItem);
+      override;
     procedure SpecializeGenericImpl(SpecializedItem: TPRSpecializedItem);
     procedure SpecializeGenericImpl(SpecializedItem: TPRSpecializedItem);
       override;
       override;
     function SpecializeNeedsDelay(SpecializedItem: TPRSpecializedItem): TPasElement; virtual;
     function SpecializeNeedsDelay(SpecializedItem: TPRSpecializedItem): TPasElement; virtual;
+    function CreateLongName(SpecializedItem: TPRSpecializedItem): string; virtual;
   protected
   protected
     const
     const
       cJSValueConversion = 2*cTypeConversion;
       cJSValueConversion = 2*cTypeConversion;
@@ -4955,6 +4975,49 @@ begin
   Result:=Result+'}';
   Result:=Result+'}';
 end;
 end;
 
 
+procedure TPas2JSResolver.SpecializeGenericIntf(
+  SpecializedItem: TPRSpecializedItem);
+{$IFDEF EnableLongNames}
+var
+  El: TPasElement;
+  C: TClass;
+  RecScope: TPas2JSRecordScope;
+  ClassScope: TPas2JSClassScope;
+  ArrayScope: TPas2JSArrayScope;
+  ProcTypeScope: TPas2JSProcTypeScope;
+  LongName: String;
+{$ENDIF}
+begin
+  {$IFDEF EnableLongNames}
+  El:=SpecializedItem.SpecializedEl;
+  C:=El.ClassType;
+  LongName:=CreateLongName(SpecializedItem);
+  if C=TPasRecordType then
+    begin
+    RecScope:=TPas2JSRecordScope(El.CustomData);
+    RecScope.LongName:=LongName;
+    end
+  else if C=TPasClassType then
+    begin
+    ClassScope:=TPas2JSClassScope(El.CustomData);
+    ClassScope.LongName:=LongName;
+    end
+  else if C=TPasArrayType then
+    begin
+    ArrayScope:=TPas2JSArrayScope(El.CustomData);
+    ArrayScope.LongName:=LongName;
+    end
+  else if (C=TPasProcedureType) or (C=TPasFunctionType) then
+    begin
+    ProcTypeScope:=TPas2JSProcTypeScope(El.CustomData);
+    ProcTypeScope.LongName:=LongName;
+    end
+  else
+    RaiseNotYetImplemented(20200904132908,El);
+  {$ENDIF}
+  inherited SpecializeGenericIntf(SpecializedItem);
+end;
+
 procedure TPas2JSResolver.SpecializeGenericImpl(
 procedure TPas2JSResolver.SpecializeGenericImpl(
   SpecializedItem: TPRSpecializedItem);
   SpecializedItem: TPRSpecializedItem);
 var
 var
@@ -5037,6 +5100,24 @@ begin
     end;
     end;
 end;
 end;
 
 
+function TPas2JSResolver.CreateLongName(SpecializedItem: TPRSpecializedItem
+  ): string;
+var
+  GenEl: TPasElement;
+  i: Integer;
+  Param: TPasType;
+begin
+  GenEl:=SpecializedItem.GenericEl;
+  Result:=GenEl.Name+'<';
+  for i:=0 to length(SpecializedItem.Params)-1 do
+    begin
+    Param:=ResolveAliasType(SpecializedItem.Params[i],false);
+    // ToDo  move to resolver
+    if Param=nil then ;
+    end;
+  Result:=Result+'>';
+end;
+
 function TPas2JSResolver.AddJSBaseType(const aName: string; Typ: TPas2jsBaseType
 function TPas2JSResolver.AddJSBaseType(const aName: string; Typ: TPas2jsBaseType
   ): TResElDataPas2JSBaseType;
   ): TResElDataPas2JSBaseType;
 var
 var
@@ -5827,6 +5908,8 @@ begin
   ScopeClass_Module:=TPas2JSModuleScope;
   ScopeClass_Module:=TPas2JSModuleScope;
   ScopeClass_Procedure:=TPas2JSProcedureScope;
   ScopeClass_Procedure:=TPas2JSProcedureScope;
   ScopeClass_Record:=TPas2JSRecordScope;
   ScopeClass_Record:=TPas2JSRecordScope;
+  ScopeClass_Array:=TPas2JSArrayScope;
+  ScopeClass_ProcType:=TPas2JSProcTypeScope;
   ScopeClass_Section:=TPas2JSSectionScope;
   ScopeClass_Section:=TPas2JSSectionScope;
   ScopeClass_WithExpr:=TPas2JSWithExprScope;
   ScopeClass_WithExpr:=TPas2JSWithExprScope;
   for bt in [pbtJSValue] do
   for bt in [pbtJSValue] do
@@ -14791,6 +14874,8 @@ begin
         end;
         end;
 
 
       // add class members: types and class vars
       // add class members: types and class vars
+      if SpecializeNeedsDelay then
+        DelayFuncContext:=CreateDelayedInitFunction(El,Src,FuncContext,DelaySrc);
       if El.ObjKind in ([okClass]+okAllHelpers) then
       if El.ObjKind in ([okClass]+okAllHelpers) then
         begin
         begin
         For i:=0 to El.Members.Count-1 do
         For i:=0 to El.Members.Count-1 do
@@ -14828,11 +14913,7 @@ begin
           if NewEl<>nil then
           if NewEl<>nil then
             begin
             begin
             if SpecializeNeedsDelay and not (P is TPasProcedure) then
             if SpecializeNeedsDelay and not (P is TPasProcedure) then
-              begin
-              if DelayFuncContext=nil then
-                DelayFuncContext:=CreateDelayedInitFunction(El,Src,FuncContext,DelaySrc);
-              AddToSourceElements(DelaySrc,NewEl);
-              end
+              AddToSourceElements(DelaySrc,NewEl)
             else
             else
               AddToSourceElements(Src,NewEl);
               AddToSourceElements(Src,NewEl);
             end;
             end;
@@ -14900,11 +14981,7 @@ begin
         AddClassMessageIds(El,Src,FuncContext,pbivnMessageStr);
         AddClassMessageIds(El,Src,FuncContext,pbivnMessageStr);
         // add RTTI init function
         // add RTTI init function
         if SpecializeNeedsDelay then
         if SpecializeNeedsDelay then
-          begin
-          if DelayFuncContext=nil then
-            DelayFuncContext:=CreateDelayedInitFunction(El,Src,FuncContext,DelaySrc);
-          AddClassRTTI(El,DelaySrc,DelayFuncContext);
-          end
+          AddClassRTTI(El,DelaySrc,DelayFuncContext)
         else
         else
           AddClassRTTI(El,Src,FuncContext);
           AddClassRTTI(El,Src,FuncContext);
         end;
         end;
@@ -15400,7 +15477,7 @@ var
   Obj: TJSObjectLiteral;
   Obj: TJSObjectLiteral;
   Prop: TJSObjectLiteralElement;
   Prop: TJSObjectLiteralElement;
   aResolver: TPas2JSResolver;
   aResolver: TPas2JSResolver;
-  Scope: TPasProcTypeScope;
+  Scope: TPas2JSProcTypeScope;
   SpecializeNeedsDelay: Boolean;
   SpecializeNeedsDelay: Boolean;
   FuncSt: TJSFunctionDeclarationStatement;
   FuncSt: TJSFunctionDeclarationStatement;
   AssignSt: TJSSimpleAssignStatement;
   AssignSt: TJSSimpleAssignStatement;
@@ -15420,7 +15497,7 @@ begin
   if El.Parent is TProcedureBody then
   if El.Parent is TProcedureBody then
     RaiseNotSupported(El,AContext,20181231112029);
     RaiseNotSupported(El,AContext,20181231112029);
 
 
-  Scope:=El.CustomData as TPasProcTypeScope;
+  Scope:=El.CustomData as TPas2JSProcTypeScope;
   SpecializeNeedsDelay:=(Scope<>nil)
   SpecializeNeedsDelay:=(Scope<>nil)
            and (aResolver.SpecializeNeedsDelay(Scope.SpecializedFromItem)<>nil);
            and (aResolver.SpecializeNeedsDelay(Scope.SpecializedFromItem)<>nil);
 
 
@@ -15532,7 +15609,7 @@ var
 
 
 var
 var
   aResolver: TPas2JSResolver;
   aResolver: TPas2JSResolver;
-  Scope: TPasArrayScope;
+  Scope: TPas2JSArrayScope;
   SpecializeNeedsDelay: Boolean;
   SpecializeNeedsDelay: Boolean;
   AssignSt: TJSSimpleAssignStatement;
   AssignSt: TJSSimpleAssignStatement;
   CallName, ArrName: String;
   CallName, ArrName: String;
@@ -15566,7 +15643,7 @@ begin
   writeln('TPasToJSConverter.ConvertArrayType ',GetObjName(El));
   writeln('TPasToJSConverter.ConvertArrayType ',GetObjName(El));
   {$ENDIF}
   {$ENDIF}
 
 
-  Scope:=El.CustomData as TPasArrayScope;
+  Scope:=El.CustomData as TPas2JSArrayScope;
   SpecializeNeedsDelay:=(Scope<>nil)
   SpecializeNeedsDelay:=(Scope<>nil)
            and (aResolver.SpecializeNeedsDelay(Scope.SpecializedFromItem)<>nil);
            and (aResolver.SpecializeNeedsDelay(Scope.SpecializedFromItem)<>nil);
 
 
@@ -16750,6 +16827,7 @@ begin
   if (C=TPasRecordType)
   if (C=TPasRecordType)
       or (C=TPasClassType) then
       or (C=TPasClassType) then
     begin
     begin
+    if (C=TPasClassType) and TPasClassType(El).IsExternal then exit;
     // pas.unitname.recordtype.$initSpec();
     // pas.unitname.recordtype.$initSpec();
     Path:=CreateReferencePath(El,AContext,rpkPathAndName)+'.'+GetBIName(pbifnClassInitSpecialize);
     Path:=CreateReferencePath(El,AContext,rpkPathAndName)+'.'+GetBIName(pbifnClassInitSpecialize);
     Call:=CreateCallExpression(El);
     Call:=CreateCallExpression(El);
@@ -24998,6 +25076,8 @@ begin
     Vars:=TFPList.Create;
     Vars:=TFPList.Create;
     Methods:=TFPList.Create;
     Methods:=TFPList.Create;
     IsComplex:=false;
     IsComplex:=false;
+    if SpecializeNeedsDelay then
+      DelayFuncContext:=CreateDelayedInitFunction(El,Src,FuncContext,DelaySrc);
     for i:=0 to El.Members.Count-1 do
     for i:=0 to El.Members.Count-1 do
       begin
       begin
       P:=TPasElement(El.Members[i]);
       P:=TPasElement(El.Members[i]);
@@ -25072,11 +25152,7 @@ begin
       if NewEl<>nil then
       if NewEl<>nil then
         begin
         begin
         if SpecializeNeedsDelay and not (P is TPasProcedure) then
         if SpecializeNeedsDelay and not (P is TPasProcedure) then
-          begin
-          if DelayFuncContext=nil then
-            DelayFuncContext:=CreateDelayedInitFunction(El,Src,FuncContext,DelaySrc);
-          AddToSourceElements(DelaySrc,NewEl);
-          end
+          AddToSourceElements(DelaySrc,NewEl)
         else
         else
           AddToSourceElements(Src,NewEl);
           AddToSourceElements(Src,NewEl);
         end;
         end;
@@ -25103,11 +25179,7 @@ begin
     if (aResolver<>nil) and HasTypeInfo(El,FuncContext) then
     if (aResolver<>nil) and HasTypeInfo(El,FuncContext) then
       begin
       begin
       if SpecializeNeedsDelay then
       if SpecializeNeedsDelay then
-        begin
-        if DelayFuncContext=nil then
-          DelayFuncContext:=CreateDelayedInitFunction(El,Src,FuncContext,DelaySrc);
-        CreateRecordRTTI(El,DelaySrc,DelayFuncContext);
-        end
+        CreateRecordRTTI(El,DelaySrc,DelayFuncContext)
       else
       else
         CreateRecordRTTI(El,Src,FuncContext);
         CreateRecordRTTI(El,Src,FuncContext);
       end;
       end;

+ 122 - 0
packages/pastojs/tests/tcgenerics.pas

@@ -47,6 +47,7 @@ type
     procedure TestGen_ExtClass_GenJSValueAssign;
     procedure TestGen_ExtClass_GenJSValueAssign;
     procedure TestGen_ExtClass_AliasMemberType;
     procedure TestGen_ExtClass_AliasMemberType;
     Procedure TestGen_ExtClass_RTTI;
     Procedure TestGen_ExtClass_RTTI;
+    procedure TestGen_ExtClass_UnitImplRec;
 
 
     // class interfaces
     // class interfaces
     procedure TestGen_ClassInterface_Corba;
     procedure TestGen_ClassInterface_Corba;
@@ -79,6 +80,8 @@ type
     procedure TestGen_ArrayOfUnitImplRec;
     procedure TestGen_ArrayOfUnitImplRec;
 
 
     // generic procedure type
     // generic procedure type
+    procedure TestGen_ProcType_ProcLocal;
+    procedure TestGen_ProcType_ProcLocal_RTTI;
     procedure TestGen_ProcType_ParamUnitImpl;
     procedure TestGen_ProcType_ParamUnitImpl;
   end;
   end;
 
 
@@ -1324,6 +1327,70 @@ begin
     '']));
     '']));
 end;
 end;
 
 
+procedure TTestGenerics.TestGen_ExtClass_UnitImplRec;
+begin
+  WithTypeInfo:=true;
+  StartProgram(true,[supTObject]);
+  AddModuleWithIntfImplSrc('UnitA.pas',
+  LinesToStr([
+  '{$mode objfpc}',
+  '{$modeswitch externalclass}',
+  'type',
+  '  generic TAnt<T> = class external name ''SET''',
+  '    x: T;',
+  '  end;',
+  '']),
+  LinesToStr([
+  'type',
+  '  TBird = record',
+  '    b: word;',
+  '  end;',
+  'var',
+  '  f: specialize TAnt<TBird>;',
+  'begin',
+  '  f.x.b:=f.x.b+10;',
+  '']));
+  Add([
+  'uses UnitA;',
+  'begin',
+  'end.']);
+  ConvertProgram;
+  CheckUnit('UnitA.pas',
+    LinesToStr([ // statements
+    'rtl.module("UnitA", ["system"], function () {',
+    '  var $mod = this;',
+    '  var $impl = $mod.$impl;',
+    '  $mod.$rtti.$ExtClass("TAnt$G1", {',
+    '    jsclass: "SET"',
+    '  });',
+    '  $mod.$init = function () {',
+    '    $impl.f.x.b = $impl.f.x.b + 10;',
+    '  };',
+    '}, null, function () {',
+    '  var $mod = this;',
+    '  var $impl = $mod.$impl;',
+    '  rtl.recNewT($impl, "TBird", function () {',
+    '    this.b = 0;',
+    '    this.$eq = function (b) {',
+    '      return this.b === b.b;',
+    '    };',
+    '    this.$assign = function (s) {',
+    '      this.b = s.b;',
+    '      return this;',
+    '    };',
+    '    var $r = $mod.$rtti.$Record("TBird", {});',
+    '    $r.addField("b", rtl.word);',
+    '  });',
+    '  $impl.f = null;',
+    '});']));
+  CheckSource('TestGen_Class_ClassVarRecord_UnitImpl',
+    LinesToStr([ // statements
+    //'pas.UnitA.TAnt$G1.$initSpec();',
+    '']),
+    LinesToStr([ // $mod.$main
+    '']));
+end;
+
 procedure TTestGenerics.TestGen_ClassInterface_Corba;
 procedure TTestGenerics.TestGen_ClassInterface_Corba;
 begin
 begin
   StartProgram(false);
   StartProgram(false);
@@ -2044,6 +2111,61 @@ begin
     '']));
     '']));
 end;
 end;
 
 
+procedure TTestGenerics.TestGen_ProcType_ProcLocal;
+begin
+  StartProgram(false);
+  Add([
+  'procedure Fly(w: word);',
+  'begin',
+  'end;',
+  'procedure Run(w: word);',
+  'type generic TProc<T> = procedure(a: T);',
+  'var p: specialize TProc<word>;',
+  'begin',
+  '  p:=@Fly;',
+  '  p(w);',
+  'end;',
+  'begin',
+  'end.']);
+  ConvertProgram;
+  CheckSource('TestGen_ProcType_ProcLocal',
+    LinesToStr([ // statements
+    'this.Fly = function (w) {',
+    '};',
+    'this.Run = function (w) {',
+    '  var p = null;',
+    '  p = $mod.Fly;',
+    '  p(w);',
+    '};',
+    '']),
+    LinesToStr([ // $mod.$main
+    '']));
+end;
+
+procedure TTestGenerics.TestGen_ProcType_ProcLocal_RTTI;
+begin
+  WithTypeInfo:=true;
+  StartProgram(false);
+  Add([
+  'procedure Fly(w: word);',
+  'begin',
+  'end;',
+  'procedure Run(w: word);',
+  'type generic TProc<T> = procedure(a: T);',
+  'var',
+  '  p: specialize TProc<word>;',
+  '  t: Pointer;',
+  'begin',
+  '  p:=@Fly;',
+  '  p(w);',
+  '  t:=typeinfo(p);',
+  'end;',
+  'begin',
+  'end.']);
+  SetExpectedPasResolverError(sSymbolCannotBePublished,nSymbolCannotBePublished);
+  ConvertProgram;
+end;
+
 procedure TTestGenerics.TestGen_ProcType_ParamUnitImpl;
 procedure TTestGenerics.TestGen_ProcType_ParamUnitImpl;
 begin
 begin
   WithTypeInfo:=true;
   WithTypeInfo:=true;

+ 1 - 1
packages/winunits-base/src/richedit.pp

@@ -692,7 +692,7 @@ Const
      COMPCOLOR = _compcolor;
      COMPCOLOR = _compcolor;
      TCOMPCOLOR = _compcolor;
      TCOMPCOLOR = _compcolor;
 
 
-     EDITSTREAMCALLBACK = function (dwCookie:PDWORD; pbBuff:LPBYTE; cb:LONG; var pcb:LONG):DWORD;
+     EDITSTREAMCALLBACK = function (dwCookie:DWORD_PTR; pbBuff:LPBYTE; cb:LONG; var pcb:LONG):DWORD;
 
 
      _editstream = record
      _editstream = record
           dwCookie : DWORD_PTR;
           dwCookie : DWORD_PTR;

+ 11 - 4
rtl/objpas/math.pp

@@ -56,10 +56,6 @@ interface
        sysutils;
        sysutils;
 
 
 {$IFDEF FPDOC_MATH}
 {$IFDEF FPDOC_MATH}
-{$DEFINE FPC_HAS_TYPE_SINGLE}
-{$DEFINE FPC_HAS_TYPE_DOUBLE}
-{$DEFINE FPC_HAS_TYPE_EXTENDED}
-{$DEFINE FPC_HAS_TYPE_COMP}
 Type
 Type
   Float = MaxFloatType;
   Float = MaxFloatType;
 
 
@@ -158,6 +154,17 @@ Const
        NegInfinity = -1.0/0.0;
        NegInfinity = -1.0/0.0;
 {$pop}
 {$pop}
 
 
+
+{$IFDEF FPDOC_MATH}
+
+// This must be after the above defines.
+
+{$DEFINE FPC_HAS_TYPE_SINGLE}
+{$DEFINE FPC_HAS_TYPE_DOUBLE}
+{$DEFINE FPC_HAS_TYPE_EXTENDED}
+{$DEFINE FPC_HAS_TYPE_COMP}
+{$ENDIF}
+
 { Min/max determination }
 { Min/max determination }
 function MinIntValue(const Data: array of Integer): Integer;
 function MinIntValue(const Data: array of Integer): Integer;
 function MaxIntValue(const Data: array of Integer): Integer;
 function MaxIntValue(const Data: array of Integer): Integer;

+ 13 - 10
rtl/win/sysutils.pp

@@ -476,16 +476,19 @@ begin
             end;
             end;
           end;
           end;
 
 
-          Handle := FindFirstFileExW(PUnicodeChar(SymLinkRec.TargetName), FindExInfoDefaults , @SymLinkRec.FindData,
-                      FindExSearchNameMatch, Nil, 0);
-          if Handle <> INVALID_HANDLE_VALUE then begin
-            Windows.FindClose(Handle);
-            SymLinkRec.Attr := SymLinkRec.FindData.dwFileAttributes;
-            SymLinkRec.Size := QWord(SymLinkRec.FindData.nFileSizeHigh) shl 32 + QWord(SymLinkRec.FindData.nFileSizeLow);
-          end else if RaiseErrorOnMissing then
-            raise EDirectoryNotFoundException.Create(SysErrorMessage(GetLastOSError))
-          else
-            SymLinkRec.TargetName := '';
+          if SymLinkRec.TargetName <> '' then begin
+            Handle := FindFirstFileExW(PUnicodeChar(SymLinkRec.TargetName), FindExInfoDefaults , @SymLinkRec.FindData,
+                        FindExSearchNameMatch, Nil, 0);
+            if Handle <> INVALID_HANDLE_VALUE then begin
+              Windows.FindClose(Handle);
+              SymLinkRec.Attr := SymLinkRec.FindData.dwFileAttributes;
+              SymLinkRec.Size := QWord(SymLinkRec.FindData.nFileSizeHigh) shl 32 + QWord(SymLinkRec.FindData.nFileSizeLow);
+            end else if RaiseErrorOnMissing then
+              raise EDirectoryNotFoundException.Create(SysErrorMessage(GetLastOSError))
+            else
+              SymLinkRec.TargetName := '';
+          end else
+            SetLastError(ERROR_REPARSE_TAG_INVALID);
         end else
         end else
           SetLastError(ERROR_REPARSE_TAG_INVALID);
           SetLastError(ERROR_REPARSE_TAG_INVALID);
       finally
       finally

+ 0 - 0
tests/test/cg/tcaldefs.inc → tests/test/cg/cpudefs.inc


+ 22 - 0
tests/webtbs/tw37650.pp

@@ -0,0 +1,22 @@
+{ %NORUN }
+
+program tw37650;
+
+{$mode objfpc}
+
+type
+  generic TMyClass<const U: Integer> = class
+    type TKey = String[U];
+  end;
+
+generic procedure Test<const U: Integer>;
+type
+  TKey = String[U];
+begin
+end;
+
+type
+  TMyClass12 = specialize TMyClass<12>;
+begin
+  specialize Test<12>;
+end.