mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-11-04 16:39:24 +01:00 
			
		
		
		
	* support overload keyword
This commit is contained in:
		
							parent
							
								
									d55672bd95
								
							
						
					
					
						commit
						b71b416cd1
					
				@ -229,32 +229,17 @@ begin
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  if assigned(aktprocsym) then
 | 
					  if assigned(aktprocsym) then
 | 
				
			||||||
   begin
 | 
					   begin
 | 
				
			||||||
     { Check if overloading is enabled }
 | 
					     { Check if overloaded is a procsym, we use a different error message
 | 
				
			||||||
     if not(m_fpc in aktmodeswitches) then
 | 
					       for tp7 so it looks more compatible }
 | 
				
			||||||
 | 
					     if aktprocsym^.typ<>procsym then
 | 
				
			||||||
      begin
 | 
					      begin
 | 
				
			||||||
        if aktprocsym^.typ<>procsym then
 | 
					        if (m_fpc in aktmodeswitches) then
 | 
				
			||||||
         begin
 | 
					         Message1(parser_e_overloaded_no_procedure,aktprocsym^.name)
 | 
				
			||||||
           DuplicateSym(aktprocsym);
 | 
					 | 
				
			||||||
           { try to recover by creating a new aktprocsym }
 | 
					 | 
				
			||||||
           tokenpos:=procstartfilepos;
 | 
					 | 
				
			||||||
           aktprocsym:=new(pprocsym,init(sp));
 | 
					 | 
				
			||||||
         end
 | 
					 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
         begin
 | 
					         DuplicateSym(aktprocsym);
 | 
				
			||||||
           if not(aktprocsym^.definition^.forwarddef) then
 | 
					        { try to recover by creating a new aktprocsym }
 | 
				
			||||||
            Message(parser_e_procedure_overloading_is_off);
 | 
					        tokenpos:=procstartfilepos;
 | 
				
			||||||
         end;
 | 
					        aktprocsym:=new(pprocsym,init(sp));
 | 
				
			||||||
      end
 | 
					 | 
				
			||||||
     else
 | 
					 | 
				
			||||||
      begin
 | 
					 | 
				
			||||||
        { Check if the overloaded sym is realy a procsym }
 | 
					 | 
				
			||||||
        if aktprocsym^.typ<>procsym then
 | 
					 | 
				
			||||||
         begin
 | 
					 | 
				
			||||||
           Message1(parser_e_overloaded_no_procedure,aktprocsym^.name);
 | 
					 | 
				
			||||||
           { try to recover by creating a new aktprocsym }
 | 
					 | 
				
			||||||
           tokenpos:=procstartfilepos;
 | 
					 | 
				
			||||||
           aktprocsym:=new(pprocsym,init(sp));
 | 
					 | 
				
			||||||
         end;
 | 
					 | 
				
			||||||
      end;
 | 
					      end;
 | 
				
			||||||
   end
 | 
					   end
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
@ -649,6 +634,10 @@ begin
 | 
				
			|||||||
    Message(parser_e_no_object_override);
 | 
					    Message(parser_e_no_object_override);
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					procedure pd_overload(const procnames:Tstringcontainer);
 | 
				
			||||||
 | 
					begin
 | 
				
			||||||
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
procedure pd_message(const procnames:Tstringcontainer);
 | 
					procedure pd_message(const procnames:Tstringcontainer);
 | 
				
			||||||
var
 | 
					var
 | 
				
			||||||
  pt : ptree;
 | 
					  pt : ptree;
 | 
				
			||||||
@ -731,7 +720,13 @@ end;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
procedure pd_register(const procnames:Tstringcontainer);
 | 
					procedure pd_register(const procnames:Tstringcontainer);
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
  Message(parser_w_proc_register_ignored);
 | 
					  Message1(parser_w_proc_directive_ignored,'REGISTER');
 | 
				
			||||||
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					procedure pd_reintroduce(const procnames:Tstringcontainer);
 | 
				
			||||||
 | 
					begin
 | 
				
			||||||
 | 
					  Message1(parser_w_proc_directive_ignored,'REINTRODUCE');
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -842,7 +837,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=29;
 | 
					  num_proc_directives=31;
 | 
				
			||||||
  proc_direcdata:array[1..num_proc_directives] of proc_dir_rec=
 | 
					  proc_direcdata:array[1..num_proc_directives] of proc_dir_rec=
 | 
				
			||||||
   (
 | 
					   (
 | 
				
			||||||
    (
 | 
					    (
 | 
				
			||||||
@ -998,6 +993,15 @@ const
 | 
				
			|||||||
      mutexclpocall : [pocall_internproc];
 | 
					      mutexclpocall : [pocall_internproc];
 | 
				
			||||||
      mutexclpotype : [];
 | 
					      mutexclpotype : [];
 | 
				
			||||||
      mutexclpo     : []
 | 
					      mutexclpo     : []
 | 
				
			||||||
 | 
					    ),(
 | 
				
			||||||
 | 
					      idtok:_OVERLOAD;
 | 
				
			||||||
 | 
					      pd_flags : pd_implemen+pd_interface+pd_body;
 | 
				
			||||||
 | 
					      handler  : {$ifndef TP}@{$endif}pd_overload;
 | 
				
			||||||
 | 
					      pocall   : [];
 | 
				
			||||||
 | 
					      pooption : [po_overload];
 | 
				
			||||||
 | 
					      mutexclpocall : [pocall_internproc];
 | 
				
			||||||
 | 
					      mutexclpotype : [];
 | 
				
			||||||
 | 
					      mutexclpo     : []
 | 
				
			||||||
    ),(
 | 
					    ),(
 | 
				
			||||||
      idtok:_OVERRIDE;
 | 
					      idtok:_OVERRIDE;
 | 
				
			||||||
      pd_flags : pd_interface+pd_object;
 | 
					      pd_flags : pd_interface+pd_object;
 | 
				
			||||||
@ -1043,6 +1047,15 @@ const
 | 
				
			|||||||
      mutexclpocall : [pocall_leftright,pocall_cdecl,pocall_internproc];
 | 
					      mutexclpocall : [pocall_leftright,pocall_cdecl,pocall_internproc];
 | 
				
			||||||
      mutexclpotype : [];
 | 
					      mutexclpotype : [];
 | 
				
			||||||
      mutexclpo     : [po_external]
 | 
					      mutexclpo     : [po_external]
 | 
				
			||||||
 | 
					    ),(
 | 
				
			||||||
 | 
					      idtok:_REINTRODUCE;
 | 
				
			||||||
 | 
					      pd_flags : pd_interface+pd_object;
 | 
				
			||||||
 | 
					      handler  : {$ifndef TP}@{$endif}pd_reintroduce;
 | 
				
			||||||
 | 
					      pocall   : [];
 | 
				
			||||||
 | 
					      pooption : [];
 | 
				
			||||||
 | 
					      mutexclpocall : [];
 | 
				
			||||||
 | 
					      mutexclpotype : [];
 | 
				
			||||||
 | 
					      mutexclpo     : []
 | 
				
			||||||
    ),(
 | 
					    ),(
 | 
				
			||||||
      idtok:_SAFECALL;
 | 
					      idtok:_SAFECALL;
 | 
				
			||||||
      pd_flags : pd_interface+pd_implemen+pd_body+pd_procvar;
 | 
					      pd_flags : pd_interface+pd_implemen+pd_body+pd_procvar;
 | 
				
			||||||
@ -1251,18 +1264,37 @@ begin
 | 
				
			|||||||
      { walk the procdef list }
 | 
					      { walk the procdef list }
 | 
				
			||||||
        while (assigned(pd)) and (assigned(pd^.nextoverloaded)) do
 | 
					        while (assigned(pd)) and (assigned(pd^.nextoverloaded)) do
 | 
				
			||||||
         begin
 | 
					         begin
 | 
				
			||||||
 | 
					           hd:=pd^.nextoverloaded;
 | 
				
			||||||
 | 
					           { check for allowing overloading }
 | 
				
			||||||
 | 
					           if not(m_fpc in aktmodeswitches) then
 | 
				
			||||||
 | 
					            begin
 | 
				
			||||||
 | 
					              { if one of the two has overload directive then
 | 
				
			||||||
 | 
					                we should issue an other error }
 | 
				
			||||||
 | 
					              if (po_overload in pd^.procoptions) or
 | 
				
			||||||
 | 
					                 (po_overload in hd^.procoptions) then
 | 
				
			||||||
 | 
					               begin
 | 
				
			||||||
 | 
					                 if not((po_overload in pd^.procoptions) and
 | 
				
			||||||
 | 
					                        (po_overload in hd^.procoptions)) then
 | 
				
			||||||
 | 
					                  Message1(parser_e_no_overload_for_all_procs,aktprocsym^.name);
 | 
				
			||||||
 | 
					               end
 | 
				
			||||||
 | 
					              else
 | 
				
			||||||
 | 
					               begin
 | 
				
			||||||
 | 
					                 if not(hd^.forwarddef) then
 | 
				
			||||||
 | 
					                  Message(parser_e_procedure_overloading_is_off);
 | 
				
			||||||
 | 
					               end;
 | 
				
			||||||
 | 
					            end;
 | 
				
			||||||
 | 
					           { check the parameters }
 | 
				
			||||||
           if (not(m_repeat_forward in aktmodeswitches) and
 | 
					           if (not(m_repeat_forward in aktmodeswitches) and
 | 
				
			||||||
               (aktprocsym^.definition^.para^.count=0)) or
 | 
					               (aktprocsym^.definition^.para^.count=0)) or
 | 
				
			||||||
              (equal_paras(aktprocsym^.definition^.para,pd^.nextoverloaded^.para,false) and
 | 
					              (equal_paras(aktprocsym^.definition^.para,hd^.para,false) and
 | 
				
			||||||
              { for operators equal_paras is not enough !! }
 | 
					              { for operators equal_paras is not enough !! }
 | 
				
			||||||
              ((aktprocsym^.definition^.proctypeoption<>potype_operator) or (optoken<>_ASSIGNMENT) or
 | 
					              ((aktprocsym^.definition^.proctypeoption<>potype_operator) or (optoken<>_ASSIGNMENT) or
 | 
				
			||||||
               is_equal(pd^.nextoverloaded^.rettype.def,aktprocsym^.definition^.rettype.def))) then
 | 
					               is_equal(pd^.nextoverloaded^.rettype.def,aktprocsym^.definition^.rettype.def))) then
 | 
				
			||||||
             begin
 | 
					             begin
 | 
				
			||||||
               if pd^.nextoverloaded^.forwarddef then
 | 
					               if hd^.forwarddef then
 | 
				
			||||||
               { remove the forward definition  but don't delete it,      }
 | 
					               { remove the forward definition  but don't delete it,      }
 | 
				
			||||||
               { the symtable is the owner !!  }
 | 
					               { the symtable is the owner !!  }
 | 
				
			||||||
                 begin
 | 
					                 begin
 | 
				
			||||||
                   hd:=pd^.nextoverloaded;
 | 
					 | 
				
			||||||
                 { Check if the procedure type and return type are correct }
 | 
					                 { Check if the procedure type and return type are correct }
 | 
				
			||||||
                   if (hd^.proctypeoption<>aktprocsym^.definition^.proctypeoption) or
 | 
					                   if (hd^.proctypeoption<>aktprocsym^.definition^.proctypeoption) or
 | 
				
			||||||
                      (not(is_equal(hd^.rettype.def,aktprocsym^.definition^.rettype.def)) and
 | 
					                      (not(is_equal(hd^.rettype.def,aktprocsym^.definition^.rettype.def)) and
 | 
				
			||||||
@ -2042,7 +2074,10 @@ end.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  $Log$
 | 
					  $Log$
 | 
				
			||||||
  Revision 1.62  2000-06-02 21:24:48  pierre
 | 
					  Revision 1.63  2000-06-18 18:12:40  peter
 | 
				
			||||||
 | 
					    * support overload keyword
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Revision 1.62  2000/06/02 21:24:48  pierre
 | 
				
			||||||
    * operator overloading now uses isbinaryoperatoracceptable
 | 
					    * operator overloading now uses isbinaryoperatoracceptable
 | 
				
			||||||
      and is unaryoperatoracceptable
 | 
					      and is unaryoperatoracceptable
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -2176,4 +2211,4 @@ end.
 | 
				
			|||||||
    * moved mangledname creation of normal proc so it also handles a wrong
 | 
					    * moved mangledname creation of normal proc so it also handles a wrong
 | 
				
			||||||
      method proc
 | 
					      method proc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
										
											Binary file not shown.
										
									
								
							@ -182,6 +182,7 @@ type
 | 
				
			|||||||
    _EXTERNAL,
 | 
					    _EXTERNAL,
 | 
				
			||||||
    _FUNCTION,
 | 
					    _FUNCTION,
 | 
				
			||||||
    _OPERATOR,
 | 
					    _OPERATOR,
 | 
				
			||||||
 | 
					    _OVERLOAD,
 | 
				
			||||||
    _OVERRIDE,
 | 
					    _OVERRIDE,
 | 
				
			||||||
    _POPSTACK,
 | 
					    _POPSTACK,
 | 
				
			||||||
    _PROPERTY,
 | 
					    _PROPERTY,
 | 
				
			||||||
@ -203,6 +204,7 @@ type
 | 
				
			|||||||
    _OPENSTRING,
 | 
					    _OPENSTRING,
 | 
				
			||||||
    _CONSTRUCTOR,
 | 
					    _CONSTRUCTOR,
 | 
				
			||||||
    _INTERNCONST,
 | 
					    _INTERNCONST,
 | 
				
			||||||
 | 
					    _REINTRODUCE,
 | 
				
			||||||
    _SHORTSTRING,
 | 
					    _SHORTSTRING,
 | 
				
			||||||
    _FINALIZATION,
 | 
					    _FINALIZATION,
 | 
				
			||||||
    _SAVEREGISTERS,
 | 
					    _SAVEREGISTERS,
 | 
				
			||||||
@ -383,6 +385,7 @@ const
 | 
				
			|||||||
      (str:'EXTERNAL'      ;special:false;keyword:m_none;op:NOTOKEN),
 | 
					      (str:'EXTERNAL'      ;special:false;keyword:m_none;op:NOTOKEN),
 | 
				
			||||||
      (str:'FUNCTION'      ;special:false;keyword:m_all;op:NOTOKEN),
 | 
					      (str:'FUNCTION'      ;special:false;keyword:m_all;op:NOTOKEN),
 | 
				
			||||||
      (str:'OPERATOR'      ;special:false;keyword:m_fpc;op:NOTOKEN),
 | 
					      (str:'OPERATOR'      ;special:false;keyword:m_fpc;op:NOTOKEN),
 | 
				
			||||||
 | 
					      (str:'OVERLOAD'      ;special:false;keyword:m_none;op:NOTOKEN),
 | 
				
			||||||
      (str:'OVERRIDE'      ;special:false;keyword:m_none;op:NOTOKEN),
 | 
					      (str:'OVERRIDE'      ;special:false;keyword:m_none;op:NOTOKEN),
 | 
				
			||||||
      (str:'POPSTACK'      ;special:false;keyword:m_none;op:NOTOKEN),
 | 
					      (str:'POPSTACK'      ;special:false;keyword:m_none;op:NOTOKEN),
 | 
				
			||||||
      (str:'PROPERTY'      ;special:false;keyword:m_class;op:NOTOKEN),
 | 
					      (str:'PROPERTY'      ;special:false;keyword:m_class;op:NOTOKEN),
 | 
				
			||||||
@ -404,6 +407,7 @@ const
 | 
				
			|||||||
      (str:'OPENSTRING'    ;special:false;keyword:m_none;op:NOTOKEN),
 | 
					      (str:'OPENSTRING'    ;special:false;keyword:m_none;op:NOTOKEN),
 | 
				
			||||||
      (str:'CONSTRUCTOR'   ;special:false;keyword:m_all;op:NOTOKEN),
 | 
					      (str:'CONSTRUCTOR'   ;special:false;keyword:m_all;op:NOTOKEN),
 | 
				
			||||||
      (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:'SHORTSTRING'   ;special:false;keyword:m_none;op:NOTOKEN),
 | 
					      (str:'SHORTSTRING'   ;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:'SAVEREGISTERS' ;special:false;keyword:m_none;op:NOTOKEN),
 | 
					      (str:'SAVEREGISTERS' ;special:false;keyword:m_none;op:NOTOKEN),
 | 
				
			||||||
@ -515,7 +519,10 @@ end;
 | 
				
			|||||||
end.
 | 
					end.
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  $Log$
 | 
					  $Log$
 | 
				
			||||||
  Revision 1.23  2000-06-05 20:41:18  pierre
 | 
					  Revision 1.24  2000-06-18 18:12:40  peter
 | 
				
			||||||
 | 
					    * support overload keyword
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Revision 1.23  2000/06/05 20:41:18  pierre
 | 
				
			||||||
    + support for NOT overloading
 | 
					    + support for NOT overloading
 | 
				
			||||||
    + unsupported overloaded operators generate errors
 | 
					    + unsupported overloaded operators generate errors
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user