Browse Source

+ "compilerproc" directive support, which turns both the public and mangled
name to lowercase(declaration_name). This prevents a normal user from
accessing the routine, but they can still be easily looked up within
the compiler. This is used for helper procedures and should facilitate
the writing of more processor independent code in the code generator
itself (mostly written by Peter)
+ new "createintern" constructor for tcal nodes to create a call to
helper exported using the "compilerproc" directive
+ support for high(dynamic_array) using the the above new things
+ definition of 'HASCOMPILERPROC' symbol (to be able to check in the
compiler and rtl whether the "compilerproc" directive is supported)

Jonas Maebe 24 years ago
parent
commit
367f7a0362
6 changed files with 132 additions and 17 deletions
  1. 29 1
      compiler/ncal.pas
  2. 15 1
      compiler/options.pas
  3. 36 2
      compiler/pdecsub.pas
  4. 20 9
      compiler/pmodules.pas
  5. 16 3
      compiler/symconst.pas
  6. 16 1
      compiler/tokens.pas

+ 29 - 1
compiler/ncal.pas

@@ -44,6 +44,9 @@ interface
           { only the processor specific nodes need to override this }
           { only the processor specific nodes need to override this }
           { constructor                                             }
           { constructor                                             }
           constructor create(l:tnode; v : tprocsym;st : tsymtable; mp : tnode);virtual;
           constructor create(l:tnode; v : tprocsym;st : tsymtable; mp : tnode);virtual;
+{$ifdef hascompilerproc}
+          constructor createintern(const name: string; params: tnode);
+{$endif hascompilerproc}
           destructor destroy;override;
           destructor destroy;override;
           function  getcopy : tnode;override;
           function  getcopy : tnode;override;
           procedure insertintolist(l : tnodelist);override;
           procedure insertintolist(l : tnodelist);override;
@@ -537,6 +540,18 @@ implementation
          procdefinition:=nil;
          procdefinition:=nil;
       end;
       end;
 
 
+{$ifdef hascompilerproc}
+     constructor tcallnode.createintern(const name: string; params: tnode);
+       var
+         srsym: tsym;
+       begin
+         srsym := searchsymonlyin(systemunit,name);
+         if not assigned(srsym) or
+            (srsym.typ <> procsym) then
+           internalerror(200107271);
+         self.create(params,tprocsym(srsym),systemunit,nil);
+       end;
+{$endif hascompilerproc}
 
 
     destructor tcallnode.destroy;
     destructor tcallnode.destroy;
       begin
       begin
@@ -1666,7 +1681,20 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.38  2001-07-30 20:52:25  peter
+  Revision 1.39  2001-08-01 15:07:29  jonas
+    + "compilerproc" directive support, which turns both the public and mangled
+      name to lowercase(declaration_name). This prevents a normal user from
+      accessing the routine, but they can still be easily looked up within
+      the compiler. This is used for helper procedures and should facilitate
+      the writing of more processor independent code in the code generator
+      itself (mostly written by Peter)
+    + new "createintern" constructor for tcal nodes to create a call to
+      helper exported using the "compilerproc" directive
+    + support for high(dynamic_array) using the the above new things
+    + definition of 'HASCOMPILERPROC' symbol (to be able to check in the
+      compiler and rtl whether the "compilerproc" directive is supported)
+
+  Revision 1.38  2001/07/30 20:52:25  peter
     * fixed array constructor passing with type conversions
     * fixed array constructor passing with type conversions
 
 
   Revision 1.37  2001/07/09 21:15:40  peter
   Revision 1.37  2001/07/09 21:15:40  peter

+ 15 - 1
compiler/options.pas

@@ -1280,6 +1280,7 @@ begin
   def_symbol('PACKENUMFIXED');
   def_symbol('PACKENUMFIXED');
   def_symbol('HAS_ADDR_STACK_ON_STACK');
   def_symbol('HAS_ADDR_STACK_ON_STACK');
   def_symbol('NOBOUNDCHECK');
   def_symbol('NOBOUNDCHECK');
+  def_symbol('HASCOMPILERPROC');
 
 
 { some stuff for TP compatibility }
 { some stuff for TP compatibility }
 {$ifdef i386}
 {$ifdef i386}
@@ -1563,7 +1564,20 @@ finalization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.51  2001-07-31 19:38:46  peter
+  Revision 1.52  2001-08-01 15:07:29  jonas
+    + "compilerproc" directive support, which turns both the public and mangled
+      name to lowercase(declaration_name). This prevents a normal user from
+      accessing the routine, but they can still be easily looked up within
+      the compiler. This is used for helper procedures and should facilitate
+      the writing of more processor independent code in the code generator
+      itself (mostly written by Peter)
+    + new "createintern" constructor for tcal nodes to create a call to
+      helper exported using the "compilerproc" directive
+    + support for high(dynamic_array) using the the above new things
+    + definition of 'HASCOMPILERPROC' symbol (to be able to check in the
+      compiler and rtl whether the "compilerproc" directive is supported)
+
+  Revision 1.51  2001/07/31 19:38:46  peter
     * removed fpu_in_rtl define (merged)
     * removed fpu_in_rtl define (merged)
 
 
   Revision 1.50  2001/07/30 21:39:26  peter
   Revision 1.50  2001/07/30 21:39:26  peter

+ 36 - 2
compiler/pdecsub.pas

@@ -1105,6 +1105,7 @@ begin
     end;
     end;
 end;
 end;
 
 
+
 type
 type
    pd_handler=procedure;
    pd_handler=procedure;
    proc_dir_rec=record
    proc_dir_rec=record
@@ -1119,7 +1120,7 @@ type
    end;
    end;
 const
 const
   {Should contain the number of procedure directives we support.}
   {Should contain the number of procedure directives we support.}
-  num_proc_directives=33;
+  num_proc_directives=34;
   proc_direcdata:array[1..num_proc_directives] of proc_dir_rec=
   proc_direcdata:array[1..num_proc_directives] of proc_dir_rec=
    (
    (
     (
     (
@@ -1428,6 +1429,15 @@ const
                        pocall_leftright,pocall_inline];
                        pocall_leftright,pocall_inline];
       mutexclpotype : [];
       mutexclpotype : [];
       mutexclpo     : [po_assembler,po_interrupt]
       mutexclpo     : [po_assembler,po_interrupt]
+    ),(
+      idtok:_COMPILERPROC;
+      pd_flags : pd_interface+pd_implemen+pd_body+pd_notobjintf;
+      handler  : nil;
+      pocall   : [pocall_compilerproc];
+      pooption : [];
+      mutexclpocall : [];
+      mutexclpotype : [];
+      mutexclpo     : [po_interrupt]
     )
     )
    );
    );
 
 
@@ -1811,6 +1821,17 @@ const
                          else
                          else
                            p:=pd;
                            p:=pd;
                          aktprocsym.definition:=hd;
                          aktprocsym.definition:=hd;
+                         { for compilerproc defines we need to rename and update the
+                           mangledname }
+                         if (pocall_compilerproc in aktprocsym.definition.proccalloptions) then
+                          begin
+                            { rename to lowercase so users can't access it }
+                            aktprocsym.owner.rename(aktprocsym.name,lower(aktprocsym.name));
+                            { also update the realname that is stored in the ppu }
+                            stringdispose(aktprocsym._realname);
+                            aktprocsym._realname:=stringdup('$'+aktprocsym.name);
+                            aktprocsym.definition.setmangledname(aktprocsym.name);
+                          end;
                          check_identical_proc:=true;
                          check_identical_proc:=true;
                          break;
                          break;
                        end
                        end
@@ -1886,7 +1907,20 @@ const
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.29  2001-07-09 21:11:14  peter
+  Revision 1.30  2001-08-01 15:07:29  jonas
+    + "compilerproc" directive support, which turns both the public and mangled
+      name to lowercase(declaration_name). This prevents a normal user from
+      accessing the routine, but they can still be easily looked up within
+      the compiler. This is used for helper procedures and should facilitate
+      the writing of more processor independent code in the code generator
+      itself (mostly written by Peter)
+    + new "createintern" constructor for tcal nodes to create a call to
+      helper exported using the "compilerproc" directive
+    + support for high(dynamic_array) using the the above new things
+    + definition of 'HASCOMPILERPROC' symbol (to be able to check in the
+      compiler and rtl whether the "compilerproc" directive is supported)
+
+  Revision 1.29  2001/07/09 21:11:14  peter
     * fixed overload checking for delphi. Empty parameters are only
     * fixed overload checking for delphi. Empty parameters are only
       allowed in implementation and not when the forward declaration
       allowed in implementation and not when the forward declaration
       contains overload directive
       contains overload directive

+ 20 - 9
compiler/pmodules.pas

@@ -1044,15 +1044,13 @@ implementation
          if (Errorcount=0) then
          if (Errorcount=0) then
            tppumodule(current_module).writeppu;
            tppumodule(current_module).writeppu;
 
 
-         if not(cs_compilesystem in aktmoduleswitches) then
-           if store_interface_crc<>current_module.interface_crc then
-             Comment(V_Warning,current_module.ppufilename^+' Interface CRC changed '+
-               hexstr(store_crc,8)+'<>'+hexstr(current_module.interface_crc,8));
 {$ifdef EXTDEBUG}
 {$ifdef EXTDEBUG}
-         if not(cs_compilesystem in aktmoduleswitches) then
-           if (store_crc<>current_module.crc) and simplify_ppu then
-             Comment(V_Warning,current_module.ppufilename^+' implementation CRC changed '+
-               hexstr(store_crc,8)+'<>'+hexstr(current_module.interface_crc,8));
+         if store_interface_crc<>current_module.interface_crc then
+           Comment(V_Warning,current_module.ppufilename^+' Interface CRC changed '+
+                   hexstr(store_crc,8)+'<>'+hexstr(current_module.interface_crc,8));
+         if (store_crc<>current_module.crc) and simplify_ppu then
+           Comment(V_Warning,current_module.ppufilename^+' implementation CRC changed '+
+                   hexstr(store_crc,8)+'<>'+hexstr(current_module.interface_crc,8));
 {$endif EXTDEBUG}
 {$endif EXTDEBUG}
 
 
          { remove static symtable (=refsymtable) here to save some mem }
          { remove static symtable (=refsymtable) here to save some mem }
@@ -1335,7 +1333,20 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.38  2001-07-30 20:59:27  peter
+  Revision 1.39  2001-08-01 15:07:29  jonas
+    + "compilerproc" directive support, which turns both the public and mangled
+      name to lowercase(declaration_name). This prevents a normal user from
+      accessing the routine, but they can still be easily looked up within
+      the compiler. This is used for helper procedures and should facilitate
+      the writing of more processor independent code in the code generator
+      itself (mostly written by Peter)
+    + new "createintern" constructor for tcal nodes to create a call to
+      helper exported using the "compilerproc" directive
+    + support for high(dynamic_array) using the the above new things
+    + definition of 'HASCOMPILERPROC' symbol (to be able to check in the
+      compiler and rtl whether the "compilerproc" directive is supported)
+
+  Revision 1.38  2001/07/30 20:59:27  peter
     * m68k updates from v10 merged
     * m68k updates from v10 merged
 
 
   Revision 1.37  2001/06/18 20:36:25  peter
   Revision 1.37  2001/06/18 20:36:25  peter

+ 16 - 3
compiler/symconst.pas

@@ -199,8 +199,8 @@ type
     pocall_inline,        { Procedure is an assembler macro }
     pocall_inline,        { Procedure is an assembler macro }
     pocall_internproc,    { Procedure has compiler magic}
     pocall_internproc,    { Procedure has compiler magic}
     pocall_internconst,   { procedure has constant evaluator intern }
     pocall_internconst,   { procedure has constant evaluator intern }
-    pocall_cppdecl        { C++ calling conventions }
-    ,pocall_13
+    pocall_cppdecl,       { C++ calling conventions }
+    pocall_compilerproc   { Procedure is used for internal compiler calls }
     ,pocall_14
     ,pocall_14
     ,pocall_15
     ,pocall_15
     ,pocall_16
     ,pocall_16
@@ -450,7 +450,20 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.20  2001-06-04 18:14:54  peter
+  Revision 1.21  2001-08-01 15:07:29  jonas
+    + "compilerproc" directive support, which turns both the public and mangled
+      name to lowercase(declaration_name). This prevents a normal user from
+      accessing the routine, but they can still be easily looked up within
+      the compiler. This is used for helper procedures and should facilitate
+      the writing of more processor independent code in the code generator
+      itself (mostly written by Peter)
+    + new "createintern" constructor for tcal nodes to create a call to
+      helper exported using the "compilerproc" directive
+    + support for high(dynamic_array) using the the above new things
+    + definition of 'HASCOMPILERPROC' symbol (to be able to check in the
+      compiler and rtl whether the "compilerproc" directive is supported)
+
+  Revision 1.20  2001/06/04 18:14:54  peter
     * varargs added for proc to procvar comparison
     * varargs added for proc to procvar comparison
 
 
   Revision 1.19  2001/06/04 11:53:13  peter
   Revision 1.19  2001/06/04 11:53:13  peter

+ 16 - 1
compiler/tokens.pas

@@ -214,6 +214,7 @@ type
     _INTERNCONST,
     _INTERNCONST,
     _REINTRODUCE,
     _REINTRODUCE,
     _SHORTSTRING,
     _SHORTSTRING,
+    _COMPILERPROC,
     _FINALIZATION,
     _FINALIZATION,
     _DISPINTERFACE,
     _DISPINTERFACE,
     _SAVEREGISTERS,
     _SAVEREGISTERS,
@@ -436,6 +437,7 @@ const
       (str:'INTERNCONST'   ;special:false;keyword:m_none;op:NOTOKEN),
       (str:'INTERNCONST'   ;special:false;keyword:m_none;op:NOTOKEN),
       (str:'REINTRODUCE'   ;special:false;keyword:m_none;op:NOTOKEN),
       (str:'REINTRODUCE'   ;special:false;keyword:m_none;op:NOTOKEN),
       (str:'SHORTSTRING'   ;special:false;keyword:m_none;op:NOTOKEN),
       (str:'SHORTSTRING'   ;special:false;keyword:m_none;op:NOTOKEN),
+      (str:'COMPILERPROC'  ;special:false;keyword:m_none;op:NOTOKEN),
       (str:'FINALIZATION'  ;special:false;keyword:m_initfinal;op:NOTOKEN),
       (str:'FINALIZATION'  ;special:false;keyword:m_initfinal;op:NOTOKEN),
       (str:'DISPINTERFACE' ;special:false;keyword:m_class;op:NOTOKEN),
       (str:'DISPINTERFACE' ;special:false;keyword:m_class;op:NOTOKEN),
       (str:'SAVEREGISTERS' ;special:false;keyword:m_none;op:NOTOKEN),
       (str:'SAVEREGISTERS' ;special:false;keyword:m_none;op:NOTOKEN),
@@ -495,7 +497,20 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.12  2001-07-30 20:59:28  peter
+  Revision 1.13  2001-08-01 15:07:29  jonas
+    + "compilerproc" directive support, which turns both the public and mangled
+      name to lowercase(declaration_name). This prevents a normal user from
+      accessing the routine, but they can still be easily looked up within
+      the compiler. This is used for helper procedures and should facilitate
+      the writing of more processor independent code in the code generator
+      itself (mostly written by Peter)
+    + new "createintern" constructor for tcal nodes to create a call to
+      helper exported using the "compilerproc" directive
+    + support for high(dynamic_array) using the the above new things
+    + definition of 'HASCOMPILERPROC' symbol (to be able to check in the
+      compiler and rtl whether the "compilerproc" directive is supported)
+
+  Revision 1.12  2001/07/30 20:59:28  peter
     * m68k updates from v10 merged
     * m68k updates from v10 merged
 
 
   Revision 1.11  2001/06/03 21:57:38  peter
   Revision 1.11  2001/06/03 21:57:38  peter