Procházet zdrojové kódy

* fixed parsing of message directive

peter před 26 roky
rodič
revize
72759d0ca3
2 změnil soubory, kde provedl 51 přidání a 116 odebrání
  1. 13 114
      compiler/pdecl.pas
  2. 38 2
      compiler/psub.pas

+ 13 - 114
compiler/pdecl.pas

@@ -1357,77 +1357,13 @@ unit pdecl;
                       oldparse_only:=parse_only;
                       parse_only:=true;
                       parse_proc_dec;
-                      if idtoken=_MESSAGE then
-                        begin
-                           { check parameter type }
-                           if ((aktprocsym^.definition^.options and pocontainsself)=0) and
-                              (assigned(aktprocsym^.definition^.para1^.next) or
-                             (aktprocsym^.definition^.para1^.paratyp<>vs_var)) then
-                             Message(parser_e_ill_msg_param);
-                           consume(idtoken);
-                           pt:=comp_expr(true);
-                           do_firstpass(pt);
-                           if pt^.treetype=stringconstn then
-                             begin
-                                aktclass^.options:=aktclass^.options or oo_hasmsgstr;
-                                aktprocsym^.definition^.options:=
-                                  aktprocsym^.definition^.options or pomsgstr;
-                                aktprocsym^.definition^.messageinf.str:=strnew(pt^.value_str);
-                             end
-                           else if is_constintnode(pt) then
-                             begin
+                      parse_object_proc_directives(aktprocsym);
+                      if (aktprocsym^.definition^.options and pomsgint)<>0 then
                                 aktclass^.options:=aktclass^.options or oo_hasmsgint;
-                                aktprocsym^.definition^.options:=
-                                  aktprocsym^.definition^.options or pomsgint;
-                                aktprocsym^.definition^.messageinf.i:=pt^.value;
-                             end
-                           else
-                             Message(parser_e_ill_msg_expr);
-                           disposetree(pt);
-                           consume(SEMICOLON);
-                        end
-                      else
-                        begin
-{$ifdef OLDOBJECTOPTIONS}
-                           case idtoken of
-                            _DYNAMIC,
-                            _VIRTUAL : begin
-                                         if actmembertype=sp_private then
-                                           Message(parser_w_priv_meth_not_virtual);
-                                         consume(idtoken);
-                                         consume(SEMICOLON);
-                                         aktprocsym^.definition^.options:=aktprocsym^.definition^.options or povirtualmethod;
-                                         aktclass^.options:=aktclass^.options or oo_hasvirtual;
-                                       end;
-                           _OVERRIDE : begin
-                                         consume(_OVERRIDE);
-                                         consume(SEMICOLON);
-                                         aktprocsym^.definition^.options:=aktprocsym^.definition^.options or
-                                           pooverridingmethod or povirtualmethod;
-                                       end;
-                           end;
-                           if idtoken=_ABSTRACT then
-                             begin
+                      if (aktprocsym^.definition^.options and pomsgstr)<>0 then
+                        aktclass^.options:=aktclass^.options or oo_hasmsgstr;
                                 if (aktprocsym^.definition^.options and povirtualmethod)<>0 then
-                                  aktprocsym^.definition^.options:=aktprocsym^.definition^.options or poabstractmethod
-                                else
-                                  Message(parser_e_only_virtual_methods_abstract);
-                                consume(_ABSTRACT);
-                                consume(SEMICOLON);
-                                { the method is defined }
-                                aktprocsym^.definition^.forwarddef:=false;
-                             end;
-                           if (cs_static_keyword in aktglobalswitches) and (idtoken=_STATIC) then
-                            begin
-                              consume(_STATIC);
-                              consume(SEMICOLON);
-                              aktprocsym^.properties:=aktprocsym^.properties or sp_static;
-                              aktprocsym^.definition^.options:=aktprocsym^.definition^.options or postaticmethod;
-                            end;
-{$else OLDOBJECTOPTIONS}
-                          parse_object_proc_directives(aktprocsym);
-{$endif def OLDOBJECTOPTIONS}
-                        end;
+                        aktclass^.options:=aktclass^.options or oo_hasvirtual;
                       parse_only:=oldparse_only;
                     end;
      _CONSTRUCTOR : begin
@@ -1436,33 +1372,9 @@ unit pdecl;
                       oldparse_only:=parse_only;
                       parse_only:=true;
                       constructor_head;
-{$ifdef OLDOBJECTOPTIONS}
-                      case idtoken of
-                       _DYNAMIC,
-                       _VIRTUAL : begin
-                                    if not(aktclass^.isclass) then
-                                     Message(parser_e_constructor_cannot_be_not_virtual)
-                                    else
-                                     begin
-                                       aktprocsym^.definition^.options:=aktprocsym^.definition^.options or povirtualmethod;
-                                       aktclass^.options:=aktclass^.options or oo_hasvirtual;
-                                     end;
-                                    consume(idtoken);
-                                    consume(SEMICOLON);
-                                  end;
-                      _OVERRIDE : begin
-                                    if (aktclass^.options and oo_is_class=0) then
-                                      Message(parser_e_constructor_cannot_be_not_virtual)
-                                    else
-                                      aktprocsym^.definition^.options:=aktprocsym^.definition^.options or
-                                        pooverridingmethod or povirtualmethod;
-                                    consume(_OVERRIDE);
-                                    consume(SEMICOLON);
-                                  end;
-                      end;
-{$else OLDOBJECTOPTIONS}
                       parse_object_proc_directives(aktprocsym);
-{$endif def OLDOBJECTOPTIONS}
+                      if (aktprocsym^.definition^.options and povirtualmethod)<>0 then
+                        aktclass^.options:=aktclass^.options or oo_hasvirtual;
                       parse_only:=oldparse_only;
                     end;
       _DESTRUCTOR : begin
@@ -1474,25 +1386,9 @@ unit pdecl;
                       oldparse_only:=parse_only;
                       parse_only:=true;
                       destructor_head;
-{$ifdef OLDOBJECTOPTIONS}
-                      case idtoken of
-                       _DYNAMIC,
-                       _VIRTUAL : begin
-                                    consume(idtoken);
-                                    consume(SEMICOLON);
-                                    aktprocsym^.definition^.options:=aktprocsym^.definition^.options or povirtualmethod;
-                                    aktclass^.options:=aktclass^.options or oo_hasvirtual;
-                                  end;
-                      _OVERRIDE : begin
-                                    consume(_OVERRIDE);
-                                    consume(SEMICOLON);
-                                    aktprocsym^.definition^.options:=aktprocsym^.definition^.options or
-                                      pooverridingmethod or povirtualmethod;
-                                  end;
-                      end;
-{$else OLDOBJECTOPTIONS}
                       parse_object_proc_directives(aktprocsym);
-{$endif def OLDOBJECTOPTIONS}
+                      if (aktprocsym^.definition^.options and povirtualmethod)<>0 then
+                        aktclass^.options:=aktclass^.options or oo_hasvirtual;
                       parse_only:=oldparse_only;
                     end;
              _END : begin
@@ -2219,7 +2115,10 @@ unit pdecl;
 end.
 {
   $Log$
-  Revision 1.127  1999-06-02 22:44:10  pierre
+  Revision 1.127.2.1  1999-07-02 12:59:49  peter
+    * fixed parsing of message directive
+
+  Revision 1.127  1999/06/02 22:44:10  pierre
    * previous wrong log corrected
 
   Revision 1.126  1999/06/02 22:25:42  pierre

+ 38 - 2
compiler/psub.pas

@@ -736,6 +736,33 @@ begin
     Message(parser_e_no_object_override);
 end;
 
+procedure pd_message(const procnames:Tstringcontainer);
+var
+  pt : ptree;
+begin
+  { check parameter type }
+  if ((aktprocsym^.definition^.options and pocontainsself)=0) and
+     (assigned(aktprocsym^.definition^.para1^.next) or
+      (aktprocsym^.definition^.para1^.paratyp<>vs_var)) then
+   Message(parser_e_ill_msg_param);
+  pt:=comp_expr(true);
+  do_firstpass(pt);
+  if pt^.treetype=stringconstn then
+    begin
+      aktprocsym^.definition^.options:=aktprocsym^.definition^.options or pomsgstr;
+      aktprocsym^.definition^.messageinf.str:=strnew(pt^.value_str);
+    end
+  else
+   if is_constintnode(pt) then
+    begin
+      aktprocsym^.definition^.options:=aktprocsym^.definition^.options or pomsgint;
+      aktprocsym^.definition^.messageinf.i:=pt^.value;
+    end
+  else
+    Message(parser_e_ill_msg_expr);
+  disposetree(pt);
+end;
+
 
 procedure pd_cdecl(const procnames:Tstringcontainer);
 begin
@@ -845,7 +872,7 @@ type
    end;
 const
   {Should contain the number of procedure directives we support.}
-  num_proc_directives=27;
+  num_proc_directives=28;
   proc_direcdata:array[1..num_proc_directives] of proc_dir_rec=
    (
     (
@@ -938,6 +965,12 @@ const
       flag:poiocheck;
       pd_flags:pd_implemen+pd_body;
       mut_excl:pointernproc+poexternal
+    ),(
+      idtok:_MESSAGE;
+      handler:{$ifndef TP}@{$endif}pd_message;
+      flag:0; { can be pomsgstr or pomsgint }
+      pd_flags:pd_interface+pd_object;
+      mut_excl:poinline+pointernproc+pointerrupt+poexternal
     ),(
       idtok:_NEAR;
       handler:{$ifndef TP}@{$endif}pd_near;
@@ -1792,7 +1825,10 @@ end.
 
 {
   $Log$
-  Revision 1.1.2.1  1999-06-17 12:44:47  pierre
+  Revision 1.1.2.2  1999-07-02 12:59:52  peter
+    * fixed parsing of message directive
+
+  Revision 1.1.2.1  1999/06/17 12:44:47  pierre
     * solve problems related to assignment overloading
     * support Delphi syntax for operator
     * avoid problems if local procedure in operator