Parcourir la source

* fix for normal method calls inside static methods :
WARNING there were both parser and codegen errors !!
added static_call boolean to calln tree

pierre il y a 26 ans
Parent
commit
f59803f7d2
4 fichiers modifiés avec 44 ajouts et 9 suppressions
  1. 12 3
      compiler/cg386cal.pas
  2. 14 3
      compiler/pexpr.pas
  3. 10 1
      compiler/pstatmnt.pas
  4. 8 2
      compiler/tree.pas

+ 12 - 3
compiler/cg386cal.pas

@@ -805,10 +805,14 @@ implementation
                 begin
                    { static functions contain the vmt_address in ESI }
                    { also class methods                              }
+                   { Here it is quite tricky because it also depends }
+                   { on the methodpointer                         PM }
                    if assigned(aktprocsym) then
                      begin
-                       if ((aktprocsym^.properties and sp_static)<>0) or
-                        ((aktprocsym^.definition^.options and poclassmethod)<>0) or
+                       if ((((aktprocsym^.properties and sp_static)<>0) or
+                        ((aktprocsym^.definition^.options and poclassmethod)<>0)) and
+                        ((p^.methodpointer=nil) or (p^.methodpointer^.treetype=typen)))
+                        or
                         ((p^.procdefinition^.options and postaticmethod)<>0) or
                         ((p^.procdefinition^.options and poconstructor)<>0) or
                         { ESI is loaded earlier }
@@ -1300,7 +1304,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.66  1999-02-09 15:45:46  florian
+  Revision 1.67  1999-02-11 09:46:21  pierre
+    * fix for normal method calls inside static methods :
+      WARNING there were both parser and codegen errors !!
+      added static_call boolean to calln tree
+
+  Revision 1.66  1999/02/09 15:45:46  florian
     + complex results for assembler functions, fixes bug0155
 
   Revision 1.65  1999/02/08 11:29:04  pierre

+ 14 - 3
compiler/pexpr.pas

@@ -790,7 +790,7 @@ unit pexpr;
                          Factor_read_id
          ---------------------------------------------}
 
-         procedure factor_read_id;
+       procedure factor_read_id;
          begin
            { allow post fix operators }
            again:=true;
@@ -1129,7 +1129,10 @@ unit pexpr;
                         PostFixOperators
          ---------------------------------------------}
 
-        procedure postfixoperators;
+      procedure postfixoperators;
+        var
+           store_static : boolean;
+           
         { p1 and p2 must contain valid value_str }
         begin
           check_tokenpos;
@@ -1312,6 +1315,8 @@ unit pexpr;
                            begin
                              classh:=pobjectdef(pd);
                              sym:=nil;
+                             store_static:=allow_only_static;
+                             allow_only_static:=false;
                              while assigned(classh) do
                               begin
                                 sym:=pvarsym(classh^.publicsyms^.search(pattern));
@@ -1320,6 +1325,7 @@ unit pexpr;
                                  break;
                                 classh:=classh^.childof;
                               end;
+                             allow_only_static:=store_static;
                              consume(ID);
                              do_member_read(false,sym,p1,pd,again);
                            end;
@@ -1934,7 +1940,12 @@ unit pexpr;
 end.
 {
   $Log$
-  Revision 1.82  1999-01-28 14:06:47  florian
+  Revision 1.83  1999-02-11 09:46:25  pierre
+    * fix for normal method calls inside static methods :
+      WARNING there were both parser and codegen errors !!
+      added static_call boolean to calln tree
+
+  Revision 1.82  1999/01/28 14:06:47  florian
     * small fix for method pointers
     * found the annoying strpas bug, mainly nested call to type cast which
       use ansistrings crash

+ 10 - 1
compiler/pstatmnt.pas

@@ -779,6 +779,7 @@ unit pstatmnt;
         var
           p,p2 : ptree;
           ht : ttoken;
+          store_allow : boolean;
           again : boolean; { dummy for do_proc_call }
           destrukname : stringid;
           sym : psym;
@@ -853,7 +854,10 @@ unit pstatmnt;
                    sym:=nil;
                    while assigned(classh) do
                          begin
+                            store_allow:=allow_only_static;
+                            allow_only_static:=false;
                             sym:=classh^.publicsyms^.search(pattern);
+                            allow_only_static:=store_allow;
                             srsymtable:=classh^.publicsyms;
                             if assigned(sym) then
                                   break;
@@ -1259,7 +1263,12 @@ unit pstatmnt;
 end.
 {
   $Log$
-  Revision 1.63  1999-02-09 15:45:47  florian
+  Revision 1.64  1999-02-11 09:46:26  pierre
+    * fix for normal method calls inside static methods :
+      WARNING there were both parser and codegen errors !!
+      added static_call boolean to calln tree
+
+  Revision 1.63  1999/02/09 15:45:47  florian
     + complex results for assembler functions, fixes bug0155
 
   Revision 1.62  1999/01/27 13:06:57  pierre

+ 8 - 2
compiler/tree.pas

@@ -242,7 +242,8 @@ unit tree;
              calln : (symtableprocentry : psym;
                       symtableproc : psymtable;procdefinition : pprocdef;
                       methodpointer : ptree;
-                      no_check,unit_specific,return_value_used : boolean);
+                      no_check,unit_specific,
+                      return_value_used,static_call : boolean);
              ordconstn : (value : longint);
              realconstn : (value_real : bestreal;lab_real : plabel;realtyp : tait);
              fixconstn : (value_fix: longint);
@@ -1685,7 +1686,12 @@ unit tree;
 end.
 {
   $Log$
-  Revision 1.64  1999-01-27 12:57:22  pierre
+  Revision 1.65  1999-02-11 09:46:31  pierre
+    * fix for normal method calls inside static methods :
+      WARNING there were both parser and codegen errors !!
+      added static_call boolean to calln tree
+
+  Revision 1.64  1999/01/27 12:57:22  pierre
    * memory leaks with hightree solved by adding a new disposetyp
      dt_leftrighthigh