diff --git a/compiler/symtable.pas b/compiler/symtable.pas index 0ea59e232e..2e5e86b196 100644 --- a/compiler/symtable.pas +++ b/compiler/symtable.pas @@ -346,6 +346,7 @@ interface function search_struct_member_no_helper(pd : tabstractrecorddef;const s : string):tsym; function search_assignment_operator(from_def,to_def:Tdef;explicit:boolean):Tprocdef; function search_enumerator_operator(from_def,to_def:Tdef):Tprocdef; + function search_management_operator(mop:tmanagementoperator;pd:Tdef):Tprocdef; { searches for the helper definition that's currently active for pd } function search_last_objectpascal_helper(pd : tdef;contextclassh : tabstractrecorddef;out odef : tobjectdef):boolean; { searches whether the symbol s is available in the currently active } @@ -436,6 +437,14 @@ interface { _OP_INC } 'inc', { _OP_DEC } 'dec'); + managementoperator2tok:array[tmanagementoperator] of ttoken = ( + { mop_none } NOTOKEN, + { mop_initialize } _OP_INITIALIZE, + { mop_finalize } _OP_FINALIZE, + { mop_addref } _OP_ADDREF, + { mop_copy } _OP_COPY + ); + implementation @@ -3738,6 +3747,31 @@ implementation end; + function search_management_operator(mop:tmanagementoperator;pd:Tdef):Tprocdef; + var + sym : Tprocsym; + hashedid : THashedIDString; + optoken: ttoken; + begin + optoken := managementoperator2tok[mop]; + if (optokenlast_managment_operator) then + internalerror(201602280); + hashedid.id:=overloaded_names[optoken]; + if not (pd.typ in [recorddef]) then + internalerror(201602281); + sym:=Tprocsym(tabstractrecorddef(pd).symtable.FindWithHash(hashedid)); + if sym<>nil then + begin + if sym.typ<>procsym then + internalerror(201602282); + result:=sym.find_procdef_bytype(potype_operator); + end + else + result:=nil; + end; + + function search_system_type(const s: TIDString): ttypesym; var sym : tsym; diff --git a/compiler/tokens.pas b/compiler/tokens.pas index 5ea3b7f21f..3edfe6e794 100644 --- a/compiler/tokens.pas +++ b/compiler/tokens.pas @@ -334,6 +334,8 @@ const first_overloaded = succ(NOTOKEN); last_overloaded = _OP_DEC; last_operator = _GENERICSPECIALTOKEN; + first_managment_operator = _OP_INITIALIZE; + last_managment_operator = _OP_COPY; highest_precedence = oppower;