Browse Source

+ some stuff to support method pointers (procedure of object) added
(declaration, parameter handling)

florian 27 years ago
parent
commit
fd860db6c6
3 changed files with 40 additions and 8 deletions
  1. 17 3
      compiler/cgi386.pas
  2. 11 1
      compiler/pdecl.pas
  3. 12 4
      compiler/types.pas

+ 17 - 3
compiler/cgi386.pas

@@ -2668,9 +2668,10 @@ implementation
               emitpushreferenceaddr(funcretref);
               emitpushreferenceaddr(funcretref);
               inc(pushedparasize,4);
               inc(pushedparasize,4);
            end;
            end;
-         { overloaded operator have no symtable }
+         { procedure variable ? }
          if (p^.right=nil) then
          if (p^.right=nil) then
            begin
            begin
+              { overloaded operator have no symtable }
               { push self }
               { push self }
               if assigned(p^.symtable) and
               if assigned(p^.symtable) and
                 (p^.symtable^.symtabletype=withsymtable) then
                 (p^.symtable^.symtabletype=withsymtable) then
@@ -3044,8 +3045,17 @@ implementation
                    must_pop:=false;
                    must_pop:=false;
                    pop_size:=0;
                    pop_size:=0;
                 end;
                 end;
-
               secondpass(p^.right);
               secondpass(p^.right);
+              { method pointer ? }
+              if (p^.procdefinition^.options and pomethodpointer)<>0 then
+                begin
+                   { method pointer can't be in a register }
+                   inc(p^.right^.location.reference^.offset,4);
+                   { push self pointer }
+                   exprasmlist^.concat(new(pai386,op_ref(A_PUSH,S_L,newreference(p^.right^.location.reference))));
+                   del_reference(p^.right^.location.reference);
+                   dec(p^.right^.location.reference^.offset,4);
+                end;
               case p^.right^.location.loc of
               case p^.right^.location.loc of
                  LOC_REGISTER,LOC_CREGISTER:
                  LOC_REGISTER,LOC_CREGISTER:
                     begin
                     begin
@@ -5715,7 +5725,11 @@ do_jmp:
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.8  1998-04-09 22:16:33  florian
+  Revision 1.9  1998-04-10 21:36:55  florian
+    + some stuff to support method pointers (procedure of object) added
+      (declaration, parameter handling)
+
+  Revision 1.8  1998/04/09 22:16:33  florian
     * problem with previous REGALLOC solved
     * problem with previous REGALLOC solved
     * improved property support
     * improved property support
 
 

+ 11 - 1
compiler/pdecl.pas

@@ -1097,6 +1097,12 @@ unit pdecl;
             until false;
             until false;
             dec(testcurobject);
             dec(testcurobject);
             consume(RKLAMMER);
             consume(RKLAMMER);
+            if token=_OF then
+              begin
+                 consume(_OF);
+                 consume(_OBJECT);
+                 procvardef^.options:=procvardef^.options or pomethodpointer;
+              end;
          end;
          end;
        handle_procvar:=procvardef;
        handle_procvar:=procvardef;
     end;
     end;
@@ -1730,7 +1736,11 @@ unit pdecl;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.8  1998-04-10 15:39:48  florian
+  Revision 1.9  1998-04-10 21:36:56  florian
+    + some stuff to support method pointers (procedure of object) added
+      (declaration, parameter handling)
+
+  Revision 1.8  1998/04/10 15:39:48  florian
     * more fixes to get classes.pas compiled
     * more fixes to get classes.pas compiled
 
 
   Revision 1.7  1998/04/09 23:02:15  florian
   Revision 1.7  1998/04/09 23:02:15  florian

+ 12 - 4
compiler/types.pas

@@ -225,10 +225,11 @@ unit types;
          ret_in_acc:=(def^.deftype=orddef) or
          ret_in_acc:=(def^.deftype=orddef) or
                      (def^.deftype=pointerdef) or
                      (def^.deftype=pointerdef) or
                      (def^.deftype=enumdef) or
                      (def^.deftype=enumdef) or
-                     (def^.deftype=procvardef) or
+                     ((def^.deftype=procvardef) and
+                      ((pprocvardef(def)^.options and pomethodpointer)=0)) or
                      (def^.deftype=classrefdef) or
                      (def^.deftype=classrefdef) or
                      ((def^.deftype=objectdef) and
                      ((def^.deftype=objectdef) and
-                      ((pobjectdef(def)^.options and oois_class)<>0)
+                      pobjectdef(def)^.isclass
                      ) or
                      ) or
                      ((def^.deftype=setdef) and
                      ((def^.deftype=setdef) and
                       (psetdef(def)^.settype=smallset)) or
                       (psetdef(def)^.settype=smallset)) or
@@ -242,6 +243,8 @@ unit types;
       begin
       begin
          ret_in_param:=(def^.deftype=arraydef) or
          ret_in_param:=(def^.deftype=arraydef) or
                        (def^.deftype=stringdef) or
                        (def^.deftype=stringdef) or
+                       ((def^.deftype=procvardef) and
+                        ((pprocvardef(def)^.options and pomethodpointer)<>0)) or
                        ((def^.deftype=objectdef) and
                        ((def^.deftype=objectdef) and
                         ((pobjectdef(def)^.options and oois_class)=0)
                         ((pobjectdef(def)^.options and oois_class)=0)
                        ) or
                        ) or
@@ -259,7 +262,8 @@ unit types;
                        (def^.deftype=objectdef) or
                        (def^.deftype=objectdef) or
                        (def^.deftype=formaldef) or
                        (def^.deftype=formaldef) or
                        (def^.deftype=recorddef) or
                        (def^.deftype=recorddef) or
-                       (def^.deftype=formaldef) or
+                       ((def^.deftype=procvardef) and
+                        ((pprocvardef(def)^.options and pomethodpointer)<>0)) or
                        ((def^.deftype=setdef) and
                        ((def^.deftype=setdef) and
                         (psetdef(def)^.settype<>smallset));
                         (psetdef(def)^.settype<>smallset));
       end;
       end;
@@ -896,7 +900,11 @@ unit types;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.6  1998-04-10 15:39:49  florian
+  Revision 1.7  1998-04-10 21:36:56  florian
+    + some stuff to support method pointers (procedure of object) added
+      (declaration, parameter handling)
+
+  Revision 1.6  1998/04/10 15:39:49  florian
     * more fixes to get classes.pas compiled
     * more fixes to get classes.pas compiled
 
 
   Revision 1.5  1998/04/09 23:02:16  florian
   Revision 1.5  1998/04/09 23:02:16  florian