|
@@ -31,13 +31,15 @@ interface
|
|
|
type
|
|
|
tpdflag=(
|
|
|
pd_body, { directive needs a body }
|
|
|
- pd_implemen, { directive can be used implementation section }
|
|
|
- pd_interface, { directive can be used interface section }
|
|
|
- pd_object, { directive can be used object declaration }
|
|
|
- pd_procvar, { directive can be used procvar declaration }
|
|
|
- pd_notobject, { directive can not be used object declaration }
|
|
|
- pd_notobjintf, { directive can not be used interface declaration }
|
|
|
- pd_notprocvar, { directive can not be used procvar declaration }
|
|
|
+ pd_implemen, { directive can be used in implementation section }
|
|
|
+ pd_interface, { directive can be used in interface section }
|
|
|
+ pd_object, { directive can be used with object declaration }
|
|
|
+ pd_record, { directive can be used with record declaration }
|
|
|
+ pd_procvar, { directive can be used with procvar declaration }
|
|
|
+ pd_notobject, { directive can not be used with object declaration }
|
|
|
+ pd_notrecord, { directive can not be used with record declaration }
|
|
|
+ pd_notobjintf, { directive can not be used with interface declaration }
|
|
|
+ pd_notprocvar, { directive can not be used with procvar declaration }
|
|
|
pd_dispinterface,{ directive can be used with dispinterface methods }
|
|
|
pd_cppobject, { directive can be used with cppclass }
|
|
|
pd_objcclass, { directive can be used with objcclass }
|
|
@@ -59,8 +61,9 @@ interface
|
|
|
procedure parse_proc_directives(pd:tabstractprocdef;var pdflags:tpdflags);
|
|
|
procedure parse_var_proc_directives(sym:tsym);
|
|
|
procedure parse_object_proc_directives(pd:tabstractprocdef);
|
|
|
- function parse_proc_head(aclass:tobjectdef;potype:tproctypeoption;var pd:tprocdef):boolean;
|
|
|
- function parse_proc_dec(isclassmethod:boolean; aclass:tobjectdef):tprocdef;
|
|
|
+ procedure parse_record_proc_directives(pd:tabstractprocdef);
|
|
|
+ function parse_proc_head(astruct:tabstractrecorddef;potype:tproctypeoption;var pd:tprocdef):boolean;
|
|
|
+ function parse_proc_dec(isclassmethod:boolean;astruct:tabstractrecorddef):tprocdef;
|
|
|
|
|
|
{ helper functions - they insert nested objects hierarcy to the symtablestack
|
|
|
with object hierarchy
|
|
@@ -246,7 +249,7 @@ implementation
|
|
|
sl : tpropaccesslist;
|
|
|
begin
|
|
|
if (pd.typ=procdef) and
|
|
|
- is_objc_class_or_protocol(tprocdef(pd)._class) and
|
|
|
+ is_objc_class_or_protocol(tprocdef(pd).struct) and
|
|
|
(pd.parast.symtablelevel=normal_function_level) then
|
|
|
begin
|
|
|
{ insert Objective-C self and selector parameters }
|
|
@@ -263,7 +266,7 @@ implementation
|
|
|
{ compatible with what gcc does }
|
|
|
hdef:=objc_idtype
|
|
|
else
|
|
|
- hdef:=tprocdef(pd)._class;
|
|
|
+ hdef:=tprocdef(pd).struct;
|
|
|
|
|
|
vs:=tparavarsym.create('$self',paranr_objc_self,vs_value,hdef,[vo_is_self,vo_is_hidden_para]);
|
|
|
pd.parast.insert(vs);
|
|
@@ -278,7 +281,7 @@ implementation
|
|
|
else
|
|
|
begin
|
|
|
if (pd.typ=procdef) and
|
|
|
- assigned(tprocdef(pd)._class) and
|
|
|
+ assigned(tprocdef(pd).struct) and
|
|
|
(pd.parast.symtablelevel=normal_function_level) then
|
|
|
begin
|
|
|
{ static class methods have no hidden self/vmt pointer }
|
|
@@ -289,7 +292,7 @@ implementation
|
|
|
current_tokenpos:=tprocdef(pd).fileinfo;
|
|
|
|
|
|
{ Generate VMT variable for constructor/destructor }
|
|
|
- if (pd.proctypeoption in [potype_constructor,potype_destructor]) and not(is_cppclass(tprocdef(pd)._class)) then
|
|
|
+ if (pd.proctypeoption in [potype_constructor,potype_destructor]) and not(is_cppclass(tprocdef(pd).struct)) then
|
|
|
begin
|
|
|
{ can't use classrefdef as type because inheriting
|
|
|
will then always file because of a type mismatch }
|
|
@@ -303,12 +306,12 @@ implementation
|
|
|
vsp:=vs_value;
|
|
|
if (po_staticmethod in pd.procoptions) or
|
|
|
(po_classmethod in pd.procoptions) then
|
|
|
- hdef:=tclassrefdef.create(tprocdef(pd)._class)
|
|
|
+ hdef:=tclassrefdef.create(tprocdef(pd).struct)
|
|
|
else
|
|
|
begin
|
|
|
- if is_object(tprocdef(pd)._class) then
|
|
|
+ if is_object(tprocdef(pd).struct) or is_record(tprocdef(pd).struct) then
|
|
|
vsp:=vs_var;
|
|
|
- hdef:=tprocdef(pd)._class;
|
|
|
+ hdef:=tprocdef(pd).struct;
|
|
|
end;
|
|
|
vs:=tparavarsym.create('$self',paranr_self,vsp,hdef,[vo_is_self,vo_is_hidden_para]);
|
|
|
pd.parast.insert(vs);
|
|
@@ -409,7 +412,7 @@ implementation
|
|
|
MessagePos(fileinfo,parser_w_cdecl_no_openstring);
|
|
|
if not(po_external in pd.procoptions) and
|
|
|
(pd.typ<>procvardef) and
|
|
|
- not is_objc_class_or_protocol(tprocdef(pd)._class) then
|
|
|
+ not is_objc_class_or_protocol(tprocdef(pd).struct) then
|
|
|
if is_array_of_const(vardef) then
|
|
|
MessagePos(fileinfo,parser_e_varargs_need_cdecl_and_external)
|
|
|
else
|
|
@@ -732,7 +735,7 @@ implementation
|
|
|
CGMessage(cg_e_file_must_call_by_reference);
|
|
|
|
|
|
{ Dispinterfaces are restricted to using only automatable types }
|
|
|
- if (pd.typ=procdef) and is_dispinterface(tprocdef(pd)._class) and
|
|
|
+ if (pd.typ=procdef) and is_dispinterface(tprocdef(pd).struct) and
|
|
|
not is_automatable(hdef) then
|
|
|
Message1(type_e_not_automatable,hdef.typename);
|
|
|
|
|
@@ -784,7 +787,7 @@ implementation
|
|
|
end;
|
|
|
|
|
|
|
|
|
- function parse_proc_head(aclass:tobjectdef;potype:tproctypeoption;var pd:tprocdef):boolean;
|
|
|
+ function parse_proc_head(astruct:tabstractrecorddef;potype:tproctypeoption;var pd:tprocdef):boolean;
|
|
|
var
|
|
|
hs : string;
|
|
|
orgsp,sp : TIDString;
|
|
@@ -800,7 +803,7 @@ implementation
|
|
|
popclass : integer;
|
|
|
ImplIntf : TImplementedInterface;
|
|
|
old_parse_generic : boolean;
|
|
|
- old_current_objectdef,
|
|
|
+ old_current_structdef: tabstractrecorddef;
|
|
|
old_current_genericdef,
|
|
|
old_current_specializedef : tobjectdef;
|
|
|
begin
|
|
@@ -825,9 +828,10 @@ implementation
|
|
|
end;
|
|
|
|
|
|
{ examine interface map: function/procedure iname.functionname=locfuncname }
|
|
|
- if assigned(aclass) and
|
|
|
- assigned(aclass.ImplementedInterfaces) and
|
|
|
- (aclass.ImplementedInterfaces.count>0) and
|
|
|
+ if assigned(astruct) and
|
|
|
+ (astruct.typ=objectdef) and
|
|
|
+ assigned(tobjectdef(astruct).ImplementedInterfaces) and
|
|
|
+ (tobjectdef(astruct).ImplementedInterfaces.count>0) and
|
|
|
try_to_consume(_POINT) then
|
|
|
begin
|
|
|
storepos:=current_tokenpos;
|
|
@@ -844,7 +848,7 @@ implementation
|
|
|
ImplIntf:=nil;
|
|
|
if (srsym.typ=typesym) and
|
|
|
(ttypesym(srsym).typedef.typ=objectdef) then
|
|
|
- ImplIntf:=aclass.find_implemented_interface(tobjectdef(ttypesym(srsym).typedef));
|
|
|
+ ImplIntf:=tobjectdef(astruct).find_implemented_interface(tobjectdef(ttypesym(srsym).typedef));
|
|
|
if ImplIntf=nil then
|
|
|
Message(parser_e_interface_id_expected);
|
|
|
consume(_ID);
|
|
@@ -860,14 +864,14 @@ implementation
|
|
|
end;
|
|
|
|
|
|
{ method ? }
|
|
|
- if not assigned(aclass) and
|
|
|
+ if not assigned(astruct) and
|
|
|
(potype<>potype_operator) and
|
|
|
(symtablestack.top.symtablelevel=main_program_level) and
|
|
|
try_to_consume(_POINT) then
|
|
|
begin
|
|
|
repeat
|
|
|
searchagain:=false;
|
|
|
- if not assigned(aclass) then
|
|
|
+ if not assigned(astruct) then
|
|
|
begin
|
|
|
{ search for object name }
|
|
|
storepos:=current_tokenpos;
|
|
@@ -887,19 +891,19 @@ implementation
|
|
|
consume(_ID);
|
|
|
{ qualifier is class name ? }
|
|
|
if (srsym.typ=typesym) and
|
|
|
- (ttypesym(srsym).typedef.typ=objectdef) then
|
|
|
+ (ttypesym(srsym).typedef.typ in [objectdef,recorddef]) then
|
|
|
begin
|
|
|
- aclass:=tobjectdef(ttypesym(srsym).typedef);
|
|
|
+ astruct:=tabstractrecorddef(ttypesym(srsym).typedef);
|
|
|
if (token<>_POINT) and (potype in [potype_class_constructor,potype_class_destructor]) then
|
|
|
sp := lower(sp);
|
|
|
- srsym:=tsym(aclass.symtable.Find(sp));
|
|
|
+ srsym:=tsym(astruct.symtable.Find(sp));
|
|
|
if assigned(srsym) then
|
|
|
begin
|
|
|
if srsym.typ=procsym then
|
|
|
aprocsym:=tprocsym(srsym)
|
|
|
else
|
|
|
if (srsym.typ=typesym) and
|
|
|
- (ttypesym(srsym).typedef.typ=objectdef) then
|
|
|
+ (ttypesym(srsym).typedef.typ in [objectdef,recorddef]) then
|
|
|
begin
|
|
|
searchagain:=true;
|
|
|
consume(_POINT);
|
|
@@ -920,7 +924,7 @@ implementation
|
|
|
begin
|
|
|
Message(parser_e_methode_id_expected);
|
|
|
{ recover by making it a normal procedure instead of method }
|
|
|
- aclass:=nil;
|
|
|
+ astruct:=nil;
|
|
|
end;
|
|
|
end
|
|
|
else
|
|
@@ -1013,27 +1017,27 @@ implementation
|
|
|
checkstack:=checkstack^.next;
|
|
|
end;
|
|
|
pd:=tprocdef.create(st.symtablelevel+1);
|
|
|
- pd._class:=aclass;
|
|
|
+ pd.struct:=astruct;
|
|
|
pd.procsym:=aprocsym;
|
|
|
pd.proctypeoption:=potype;
|
|
|
|
|
|
{ methods inherit df_generic or df_specialization from the objectdef }
|
|
|
- if assigned(pd._class) and
|
|
|
+ if assigned(pd.struct) and
|
|
|
(pd.parast.symtablelevel=normal_function_level) then
|
|
|
begin
|
|
|
- if (df_generic in pd._class.defoptions) then
|
|
|
+ if (df_generic in pd.struct.defoptions) then
|
|
|
begin
|
|
|
include(pd.defoptions,df_generic);
|
|
|
parse_generic:=true;
|
|
|
end;
|
|
|
- if (df_specialization in pd._class.defoptions) then
|
|
|
+ if (df_specialization in pd.struct.defoptions) then
|
|
|
begin
|
|
|
include(pd.defoptions,df_specialization);
|
|
|
{ Find corresponding genericdef, we need it later to
|
|
|
replay the tokens to generate the body }
|
|
|
- if not assigned(pd._class.genericdef) then
|
|
|
+ if not assigned(pd.struct.genericdef) then
|
|
|
internalerror(200512113);
|
|
|
- genericst:=pd._class.genericdef.GetSymtable(gs_record);
|
|
|
+ genericst:=pd.struct.genericdef.GetSymtable(gs_record);
|
|
|
if not assigned(genericst) then
|
|
|
internalerror(200512114);
|
|
|
{ We are parsing the same objectdef, the def index numbers
|
|
@@ -1046,9 +1050,9 @@ implementation
|
|
|
end;
|
|
|
|
|
|
{ methods need to be exported }
|
|
|
- if assigned(aclass) and
|
|
|
+ if assigned(astruct) and
|
|
|
(
|
|
|
- (symtablestack.top.symtabletype=ObjectSymtable) or
|
|
|
+ (symtablestack.top.symtabletype in [ObjectSymtable,recordsymtable]) or
|
|
|
(symtablestack.top.symtablelevel=main_program_level)
|
|
|
) then
|
|
|
include(pd.procoptions,po_global);
|
|
@@ -1064,19 +1068,19 @@ implementation
|
|
|
begin
|
|
|
{ Add ObjectSymtable to be able to find nested type definitions }
|
|
|
popclass:=0;
|
|
|
- if assigned(pd._class) and
|
|
|
+ if assigned(pd.struct) and
|
|
|
(pd.parast.symtablelevel=normal_function_level) and
|
|
|
- (symtablestack.top.symtabletype<>ObjectSymtable) then
|
|
|
+ not(symtablestack.top.symtabletype in [ObjectSymtable,recordsymtable]) then
|
|
|
begin
|
|
|
- popclass:=push_nested_hierarchy(pd._class);
|
|
|
- old_current_objectdef:=current_objectdef;
|
|
|
+ popclass:=push_nested_hierarchy(pd.struct);
|
|
|
+ old_current_structdef:=current_structdef;
|
|
|
old_current_genericdef:=current_genericdef;
|
|
|
old_current_specializedef:=current_specializedef;
|
|
|
- current_objectdef:=pd._class;
|
|
|
- if assigned(current_objectdef) and (df_generic in current_objectdef.defoptions) then
|
|
|
- current_genericdef:=current_objectdef;
|
|
|
- if assigned(current_objectdef) and (df_specialization in current_objectdef.defoptions) then
|
|
|
- current_specializedef:=current_objectdef;
|
|
|
+ current_structdef:=pd.struct;
|
|
|
+ if assigned(current_structdef) and (df_generic in current_structdef.defoptions) then
|
|
|
+ current_genericdef:=tobjectdef(current_structdef);
|
|
|
+ if assigned(current_structdef) and (df_specialization in current_structdef.defoptions) then
|
|
|
+ current_specializedef:=tobjectdef(current_structdef);
|
|
|
end;
|
|
|
{ Add parameter symtable }
|
|
|
if pd.parast.symtabletype<>staticsymtable then
|
|
@@ -1086,10 +1090,10 @@ implementation
|
|
|
symtablestack.pop(pd.parast);
|
|
|
if popclass>0 then
|
|
|
begin
|
|
|
- current_objectdef:=old_current_objectdef;
|
|
|
+ current_structdef:=old_current_structdef;
|
|
|
current_genericdef:=old_current_genericdef;
|
|
|
current_specializedef:=old_current_specializedef;
|
|
|
- dec(popclass,pop_nested_hierarchy(pd._class));
|
|
|
+ dec(popclass,pop_nested_hierarchy(pd.struct));
|
|
|
if popclass<>0 then
|
|
|
internalerror(201011260); // 11 nov 2010 index 0
|
|
|
end;
|
|
@@ -1100,13 +1104,13 @@ implementation
|
|
|
end;
|
|
|
|
|
|
|
|
|
- function parse_proc_dec(isclassmethod:boolean; aclass:tobjectdef):tprocdef;
|
|
|
+ function parse_proc_dec(isclassmethod:boolean;astruct:tabstractrecorddef):tprocdef;
|
|
|
var
|
|
|
pd : tprocdef;
|
|
|
locationstr: string;
|
|
|
old_parse_generic: boolean;
|
|
|
popclass: integer;
|
|
|
- old_current_objectdef,
|
|
|
+ old_current_structdef: tabstractrecorddef;
|
|
|
old_current_genericdef,
|
|
|
old_current_specializedef: tobjectdef;
|
|
|
begin
|
|
@@ -1116,7 +1120,7 @@ implementation
|
|
|
_FUNCTION :
|
|
|
begin
|
|
|
consume(_FUNCTION);
|
|
|
- if parse_proc_head(aclass,potype_function,pd) then
|
|
|
+ if parse_proc_head(astruct,potype_function,pd) then
|
|
|
begin
|
|
|
{ pd=nil when it is a interface mapping }
|
|
|
if assigned(pd) then
|
|
@@ -1127,32 +1131,32 @@ implementation
|
|
|
inc(testcurobject);
|
|
|
{ Add ObjectSymtable to be able to find generic type definitions }
|
|
|
popclass:=0;
|
|
|
- if assigned(pd._class) and
|
|
|
+ if assigned(pd.struct) and
|
|
|
(pd.parast.symtablelevel=normal_function_level) and
|
|
|
- (symtablestack.top.symtabletype<>ObjectSymtable) then
|
|
|
+ not (symtablestack.top.symtabletype in [ObjectSymtable,recordsymtable]) then
|
|
|
begin
|
|
|
- popclass:=push_nested_hierarchy(pd._class);
|
|
|
- parse_generic:=(df_generic in pd._class.defoptions);
|
|
|
- old_current_objectdef:=current_objectdef;
|
|
|
+ popclass:=push_nested_hierarchy(pd.struct);
|
|
|
+ parse_generic:=(df_generic in pd.struct.defoptions);
|
|
|
+ old_current_structdef:=current_structdef;
|
|
|
old_current_genericdef:=current_genericdef;
|
|
|
old_current_specializedef:=current_specializedef;
|
|
|
- current_objectdef:=pd._class;
|
|
|
- if assigned(current_objectdef) and (df_generic in current_objectdef.defoptions) then
|
|
|
- current_genericdef:=current_objectdef;
|
|
|
- if assigned(current_objectdef) and (df_specialization in current_objectdef.defoptions) then
|
|
|
- current_specializedef:=current_objectdef;
|
|
|
+ current_structdef:=pd.struct;
|
|
|
+ if assigned(current_structdef) and (df_generic in current_structdef.defoptions) then
|
|
|
+ current_genericdef:=tobjectdef(current_structdef);
|
|
|
+ if assigned(current_structdef) and (df_specialization in current_structdef.defoptions) then
|
|
|
+ current_specializedef:=tobjectdef(current_structdef);
|
|
|
end;
|
|
|
single_type(pd.returndef,false,false);
|
|
|
|
|
|
- if is_dispinterface(pd._class) and not is_automatable(pd.returndef) then
|
|
|
+ if is_dispinterface(pd.struct) and not is_automatable(pd.returndef) then
|
|
|
Message1(type_e_not_automatable,pd.returndef.typename);
|
|
|
|
|
|
if popclass>0 then
|
|
|
begin
|
|
|
- current_objectdef:=old_current_objectdef;
|
|
|
+ current_structdef:=old_current_structdef;
|
|
|
current_genericdef:=old_current_genericdef;
|
|
|
current_specializedef:=old_current_specializedef;
|
|
|
- dec(popclass,pop_nested_hierarchy(pd._class));
|
|
|
+ dec(popclass,pop_nested_hierarchy(pd.struct));
|
|
|
if popclass<>0 then
|
|
|
internalerror(201012020);
|
|
|
end;
|
|
@@ -1187,7 +1191,7 @@ implementation
|
|
|
begin
|
|
|
if (
|
|
|
parse_only and
|
|
|
- not(is_interface(pd._class))
|
|
|
+ not(is_interface(pd.struct))
|
|
|
) or
|
|
|
(m_repeat_forward in current_settings.modeswitches) then
|
|
|
begin
|
|
@@ -1210,7 +1214,7 @@ implementation
|
|
|
_PROCEDURE :
|
|
|
begin
|
|
|
consume(_PROCEDURE);
|
|
|
- if parse_proc_head(aclass,potype_procedure,pd) then
|
|
|
+ if parse_proc_head(astruct,potype_procedure,pd) then
|
|
|
begin
|
|
|
{ pd=nil when it is an interface mapping }
|
|
|
if assigned(pd) then
|
|
@@ -1226,17 +1230,17 @@ implementation
|
|
|
begin
|
|
|
consume(_CONSTRUCTOR);
|
|
|
if isclassmethod then
|
|
|
- parse_proc_head(aclass,potype_class_constructor,pd)
|
|
|
+ parse_proc_head(astruct,potype_class_constructor,pd)
|
|
|
else
|
|
|
- parse_proc_head(aclass,potype_constructor,pd);
|
|
|
+ parse_proc_head(astruct,potype_constructor,pd);
|
|
|
if not isclassmethod and
|
|
|
assigned(pd) and
|
|
|
- assigned(pd._class) then
|
|
|
+ assigned(pd.struct) then
|
|
|
begin
|
|
|
{ Set return type, class constructors return the
|
|
|
created instance, object constructors return boolean }
|
|
|
- if is_class(pd._class) then
|
|
|
- pd.returndef:=pd._class
|
|
|
+ if is_class(pd.struct) then
|
|
|
+ pd.returndef:=pd.struct
|
|
|
else
|
|
|
{$ifdef CPU64bitaddr}
|
|
|
pd.returndef:=bool64type;
|
|
@@ -1252,9 +1256,9 @@ implementation
|
|
|
begin
|
|
|
consume(_DESTRUCTOR);
|
|
|
if isclassmethod then
|
|
|
- parse_proc_head(aclass,potype_class_destructor,pd)
|
|
|
+ parse_proc_head(astruct,potype_class_destructor,pd)
|
|
|
else
|
|
|
- parse_proc_head(aclass,potype_destructor,pd);
|
|
|
+ parse_proc_head(astruct,potype_destructor,pd);
|
|
|
if assigned(pd) then
|
|
|
pd.returndef:=voidtype;
|
|
|
end;
|
|
@@ -1286,7 +1290,7 @@ implementation
|
|
|
end;
|
|
|
end;
|
|
|
consume(token);
|
|
|
- parse_proc_head(aclass,potype_operator,pd);
|
|
|
+ parse_proc_head(astruct,potype_operator,pd);
|
|
|
if assigned(pd) then
|
|
|
begin
|
|
|
{ operators always need to be searched in all units }
|
|
@@ -1375,7 +1379,7 @@ procedure pd_export(pd:tabstractprocdef);
|
|
|
begin
|
|
|
if pd.typ<>procdef then
|
|
|
internalerror(200304264);
|
|
|
- if assigned(tprocdef(pd)._class) then
|
|
|
+ if assigned(tprocdef(pd).struct) then
|
|
|
Message(parser_e_methods_dont_be_export);
|
|
|
if pd.parast.symtablelevel>normal_function_level then
|
|
|
Message(parser_e_dont_nest_export);
|
|
@@ -1473,7 +1477,9 @@ procedure pd_abstract(pd:tabstractprocdef);
|
|
|
begin
|
|
|
if pd.typ<>procdef then
|
|
|
internalerror(200304269);
|
|
|
- if oo_is_sealed in tprocdef(pd)._class.objectoptions then
|
|
|
+ if assigned(tprocdef(pd).struct) and
|
|
|
+ (tprocdef(pd).struct.typ=objectdef) and
|
|
|
+ (oo_is_sealed in tobjectdef(tprocdef(pd).struct).objectoptions) then
|
|
|
Message(parser_e_sealed_class_cannot_have_abstract_methods)
|
|
|
else
|
|
|
if (po_virtualmethod in pd.procoptions) then
|
|
@@ -1502,13 +1508,13 @@ begin
|
|
|
begin
|
|
|
if pattern='MOVENEXT' then
|
|
|
begin
|
|
|
- if oo_has_enumerator_movenext in tprocdef(pd)._class.objectoptions then
|
|
|
+ if oo_has_enumerator_movenext in tobjectdef(tprocdef(pd).struct).objectoptions then
|
|
|
message(parser_e_only_one_enumerator_movenext);
|
|
|
pd.calcparas;
|
|
|
if (pd.proctypeoption = potype_function) and is_boolean(pd.returndef) and
|
|
|
(pd.minparacount = 0) then
|
|
|
begin
|
|
|
- include(tprocdef(pd)._class.objectoptions, oo_has_enumerator_movenext);
|
|
|
+ include(tobjectdef(tprocdef(pd).struct).objectoptions, oo_has_enumerator_movenext);
|
|
|
include(pd.procoptions,po_enumerator_movenext);
|
|
|
end
|
|
|
else
|
|
@@ -1531,10 +1537,10 @@ begin
|
|
|
if pd.typ<>procdef then
|
|
|
internalerror(2003042610);
|
|
|
if (pd.proctypeoption=potype_constructor) and
|
|
|
- is_object(tprocdef(pd)._class) then
|
|
|
+ is_object(tprocdef(pd).struct) then
|
|
|
Message(parser_e_constructor_cannot_be_not_virtual);
|
|
|
{$ifdef WITHDMT}
|
|
|
- if is_object(tprocdef(pd)._class) and
|
|
|
+ if is_object(tprocdef(pd).struct) and
|
|
|
(token<>_SEMICOLON) then
|
|
|
begin
|
|
|
{ any type of parameter is allowed here! }
|
|
@@ -1559,7 +1565,7 @@ var pt:Tnode;
|
|
|
begin
|
|
|
if pd.typ<>procdef then
|
|
|
internalerror(200604301);
|
|
|
- pt:=comp_expr(true);
|
|
|
+ pt:=comp_expr(true,false);
|
|
|
if is_constintnode(pt) then
|
|
|
if (Tordconstnode(pt).value<int64(low(longint))) or (Tordconstnode(pt).value>int64(high(longint))) then
|
|
|
message(parser_e_range_check_error)
|
|
@@ -1582,9 +1588,9 @@ procedure pd_override(pd:tabstractprocdef);
|
|
|
begin
|
|
|
if pd.typ<>procdef then
|
|
|
internalerror(2003042611);
|
|
|
- if not(is_class_or_interface_or_objc(tprocdef(pd)._class)) then
|
|
|
+ if not(is_class_or_interface_or_objc(tprocdef(pd).struct)) then
|
|
|
Message(parser_e_no_object_override)
|
|
|
- else if is_objccategory(tprocdef(pd)._class) then
|
|
|
+ else if is_objccategory(tprocdef(pd).struct) then
|
|
|
Message(parser_e_no_category_override);
|
|
|
end;
|
|
|
|
|
@@ -1602,20 +1608,20 @@ var
|
|
|
begin
|
|
|
if pd.typ<>procdef then
|
|
|
internalerror(2003042613);
|
|
|
- if not is_class(tprocdef(pd)._class) and
|
|
|
- not is_objc_class_or_protocol(tprocdef(pd)._class) then
|
|
|
+ if not is_class(tprocdef(pd).struct) and
|
|
|
+ not is_objc_class_or_protocol(tprocdef(pd).struct) then
|
|
|
Message(parser_e_msg_only_for_classes);
|
|
|
if ([po_msgstr,po_msgint]*pd.procoptions)<>[] then
|
|
|
Message(parser_e_multiple_messages);
|
|
|
{ check parameter type }
|
|
|
- if not is_objc_class_or_protocol(tprocdef(pd)._class) then
|
|
|
+ if not is_objc_class_or_protocol(tprocdef(pd).struct) then
|
|
|
begin
|
|
|
paracnt:=0;
|
|
|
pd.parast.SymList.ForEachCall(@check_msg_para,@paracnt);
|
|
|
if paracnt<>1 then
|
|
|
Message(parser_e_ill_msg_param);
|
|
|
end;
|
|
|
- pt:=comp_expr(true);
|
|
|
+ pt:=comp_expr(true,false);
|
|
|
{ message is 1-character long }
|
|
|
if is_constcharnode(pt) then
|
|
|
begin
|
|
@@ -1631,7 +1637,7 @@ begin
|
|
|
end
|
|
|
else
|
|
|
if is_constintnode(pt) and
|
|
|
- is_class(tprocdef(pd)._class) then
|
|
|
+ is_class(tprocdef(pd).struct) then
|
|
|
begin
|
|
|
include(pd.procoptions,po_msgint);
|
|
|
if (Tordconstnode(pt).value<int64(low(Tprocdef(pd).messageinf.i))) or
|
|
@@ -1644,7 +1650,7 @@ begin
|
|
|
Message(parser_e_ill_msg_expr);
|
|
|
{ check whether the selector name is valid in case of Objective-C }
|
|
|
if (po_msgstr in pd.procoptions) and
|
|
|
- is_objc_class_or_protocol(tprocdef(pd)._class) and
|
|
|
+ is_objc_class_or_protocol(tprocdef(pd).struct) and
|
|
|
not objcvalidselectorname(@tprocdef(pd).messageinf.str^[1],length(tprocdef(pd).messageinf.str^)) then
|
|
|
Message1(type_e_invalid_objc_selector_name,tprocdef(pd).messageinf.str^);
|
|
|
pt.free;
|
|
@@ -1655,8 +1661,8 @@ procedure pd_reintroduce(pd:tabstractprocdef);
|
|
|
begin
|
|
|
if pd.typ<>procdef then
|
|
|
internalerror(200401211);
|
|
|
- if not(is_class_or_interface_or_object(tprocdef(pd)._class)) and
|
|
|
- not(is_objccategory(tprocdef(pd)._class)) then
|
|
|
+ if not(is_class_or_interface_or_object(tprocdef(pd).struct)) and
|
|
|
+ not(is_objccategory(tprocdef(pd).struct)) then
|
|
|
Message(parser_e_no_object_reintroduce);
|
|
|
end;
|
|
|
|
|
@@ -1937,7 +1943,7 @@ const
|
|
|
(
|
|
|
(
|
|
|
idtok:_ABSTRACT;
|
|
|
- pd_flags : [pd_interface,pd_object,pd_notobjintf];
|
|
|
+ pd_flags : [pd_interface,pd_object,pd_notobjintf,pd_notrecord];
|
|
|
handler : @pd_abstract;
|
|
|
pocall : pocall_none;
|
|
|
pooption : [po_abstractmethod];
|
|
@@ -2000,7 +2006,7 @@ const
|
|
|
mutexclpo : [po_interrupt,po_external,po_inline]
|
|
|
),(
|
|
|
idtok:_DYNAMIC;
|
|
|
- pd_flags : [pd_interface,pd_object,pd_notobjintf];
|
|
|
+ pd_flags : [pd_interface,pd_object,pd_notobjintf,pd_notrecord];
|
|
|
handler : @pd_virtual;
|
|
|
pocall : pocall_none;
|
|
|
pooption : [po_virtualmethod];
|
|
@@ -2009,7 +2015,7 @@ const
|
|
|
mutexclpo : [po_exports,po_interrupt,po_external,po_overridingmethod,po_inline]
|
|
|
),(
|
|
|
idtok:_EXPORT;
|
|
|
- pd_flags : [pd_body,pd_interface,pd_implemen,pd_notobjintf];
|
|
|
+ pd_flags : [pd_body,pd_interface,pd_implemen,pd_notobjintf,pd_notrecord];
|
|
|
handler : @pd_export;
|
|
|
pocall : pocall_none;
|
|
|
pooption : [po_exports,po_global];
|
|
@@ -2018,7 +2024,7 @@ const
|
|
|
mutexclpo : [po_external,po_interrupt,po_inline]
|
|
|
),(
|
|
|
idtok:_EXTERNAL;
|
|
|
- pd_flags : [pd_implemen,pd_interface,pd_notobject,pd_notobjintf,pd_cppobject];
|
|
|
+ pd_flags : [pd_implemen,pd_interface,pd_notobject,pd_notobjintf,pd_cppobject,pd_notrecord];
|
|
|
handler : @pd_external;
|
|
|
pocall : pocall_none;
|
|
|
pooption : [po_external];
|
|
@@ -2028,7 +2034,7 @@ const
|
|
|
mutexclpo : [po_public,po_exports,po_interrupt,po_assembler,po_inline]
|
|
|
),(
|
|
|
idtok:_FAR;
|
|
|
- pd_flags : [pd_implemen,pd_body,pd_interface,pd_procvar,pd_notobject,pd_notobjintf];
|
|
|
+ pd_flags : [pd_implemen,pd_body,pd_interface,pd_procvar,pd_notobject,pd_notobjintf,pd_notrecord];
|
|
|
handler : @pd_far;
|
|
|
pocall : pocall_none;
|
|
|
pooption : [];
|
|
@@ -2037,7 +2043,7 @@ const
|
|
|
mutexclpo : [po_inline]
|
|
|
),(
|
|
|
idtok:_FAR16;
|
|
|
- pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar,pd_notobject];
|
|
|
+ pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar,pd_notobject,pd_notrecord];
|
|
|
handler : nil;
|
|
|
pocall : pocall_far16;
|
|
|
pooption : [];
|
|
@@ -2046,7 +2052,7 @@ const
|
|
|
mutexclpo : [po_external]
|
|
|
),(
|
|
|
idtok:_FINAL;
|
|
|
- pd_flags : [pd_interface,pd_object,pd_notobjintf];
|
|
|
+ pd_flags : [pd_interface,pd_object,pd_notobjintf,pd_notrecord];
|
|
|
handler : @pd_final;
|
|
|
pocall : pocall_none;
|
|
|
pooption : [po_finalmethod];
|
|
@@ -2055,7 +2061,7 @@ const
|
|
|
mutexclpo : [po_exports,po_interrupt,po_external,po_inline]
|
|
|
),(
|
|
|
idtok:_FORWARD;
|
|
|
- pd_flags : [pd_implemen,pd_notobject,pd_notobjintf];
|
|
|
+ pd_flags : [pd_implemen,pd_notobject,pd_notobjintf,pd_notrecord];
|
|
|
handler : @pd_forward;
|
|
|
pocall : pocall_none;
|
|
|
pooption : [];
|
|
@@ -2082,7 +2088,7 @@ const
|
|
|
mutexclpo : [po_exports,po_external,po_interrupt,po_virtualmethod]
|
|
|
),(
|
|
|
idtok:_INTERNCONST;
|
|
|
- pd_flags : [pd_interface,pd_body,pd_notobject,pd_notobjintf];
|
|
|
+ pd_flags : [pd_interface,pd_body,pd_notobject,pd_notobjintf,pd_notrecord];
|
|
|
handler : @pd_internconst;
|
|
|
pocall : pocall_none;
|
|
|
pooption : [po_internconst];
|
|
@@ -2091,7 +2097,7 @@ const
|
|
|
mutexclpo : []
|
|
|
),(
|
|
|
idtok:_INTERNPROC;
|
|
|
- pd_flags : [pd_interface,pd_notobject,pd_notobjintf];
|
|
|
+ pd_flags : [pd_interface,pd_notobject,pd_notobjintf,pd_notrecord];
|
|
|
handler : @pd_internproc;
|
|
|
pocall : pocall_internproc;
|
|
|
pooption : [];
|
|
@@ -2100,7 +2106,7 @@ const
|
|
|
mutexclpo : [po_exports,po_external,po_interrupt,po_assembler,po_iocheck,po_virtualmethod]
|
|
|
),(
|
|
|
idtok:_INTERRUPT;
|
|
|
- pd_flags : [pd_implemen,pd_body,pd_notobject,pd_notobjintf];
|
|
|
+ pd_flags : [pd_implemen,pd_body,pd_notobject,pd_notobjintf,pd_notrecord];
|
|
|
handler : @pd_interrupt;
|
|
|
pocall : pocall_oldfpccall;
|
|
|
pooption : [po_interrupt];
|
|
@@ -2128,7 +2134,7 @@ const
|
|
|
mutexclpo : [po_external,po_exports]
|
|
|
),(
|
|
|
idtok:_MESSAGE;
|
|
|
- pd_flags : [pd_interface,pd_object,pd_notobjintf,pd_objcclass, pd_objcprot];
|
|
|
+ pd_flags : [pd_interface,pd_object,pd_notobjintf,pd_objcclass,pd_objcprot,pd_notrecord];
|
|
|
handler : @pd_message;
|
|
|
pocall : pocall_none;
|
|
|
pooption : []; { can be po_msgstr or po_msgint }
|
|
@@ -2146,7 +2152,7 @@ const
|
|
|
mutexclpo : []
|
|
|
),(
|
|
|
idtok:_NEAR;
|
|
|
- pd_flags : [pd_implemen,pd_body,pd_procvar,pd_notobjintf];
|
|
|
+ pd_flags : [pd_implemen,pd_body,pd_procvar,pd_notobjintf,pd_notrecord];
|
|
|
handler : @pd_near;
|
|
|
pocall : pocall_none;
|
|
|
pooption : [];
|
|
@@ -2173,7 +2179,7 @@ const
|
|
|
mutexclpo : []
|
|
|
),(
|
|
|
idtok:_OVERRIDE;
|
|
|
- pd_flags : [pd_interface,pd_object,pd_notobjintf,pd_objcclass];
|
|
|
+ pd_flags : [pd_interface,pd_object,pd_notobjintf,pd_objcclass,pd_notrecord];
|
|
|
handler : @pd_override;
|
|
|
pocall : pocall_none;
|
|
|
pooption : [po_overridingmethod,po_virtualmethod];
|
|
@@ -2191,7 +2197,7 @@ const
|
|
|
mutexclpo : [po_external]
|
|
|
),(
|
|
|
idtok:_PUBLIC;
|
|
|
- pd_flags : [pd_interface,pd_implemen,pd_body,pd_notobject,pd_notobjintf];
|
|
|
+ pd_flags : [pd_interface,pd_implemen,pd_body,pd_notobject,pd_notobjintf,pd_notrecord];
|
|
|
handler : @pd_public;
|
|
|
pocall : pocall_none;
|
|
|
pooption : [po_public,po_global];
|
|
@@ -2209,7 +2215,7 @@ const
|
|
|
mutexclpo : [po_external]
|
|
|
),(
|
|
|
idtok:_REINTRODUCE;
|
|
|
- pd_flags : [pd_interface,pd_object,pd_notobjintf,pd_objcclass];
|
|
|
+ pd_flags : [pd_interface,pd_object,pd_notobjintf,pd_objcclass,pd_notrecord];
|
|
|
handler : @pd_reintroduce;
|
|
|
pocall : pocall_none;
|
|
|
pooption : [po_reintroduce];
|
|
@@ -2238,7 +2244,7 @@ const
|
|
|
mutexclpo : []
|
|
|
),(
|
|
|
idtok:_STATIC;
|
|
|
- pd_flags : [pd_interface,pd_implemen,pd_body,pd_object,pd_notobjintf];
|
|
|
+ pd_flags : [pd_interface,pd_implemen,pd_body,pd_object,pd_record,pd_notobjintf];
|
|
|
handler : @pd_static;
|
|
|
pocall : pocall_none;
|
|
|
pooption : [po_staticmethod];
|
|
@@ -2268,7 +2274,7 @@ const
|
|
|
mutexclpo : [po_external,po_assembler,po_interrupt,po_exports]
|
|
|
),(
|
|
|
idtok:_VIRTUAL;
|
|
|
- pd_flags : [pd_interface,pd_object,pd_notobjintf];
|
|
|
+ pd_flags : [pd_interface,pd_object,pd_notobjintf,pd_notrecord];
|
|
|
handler : @pd_virtual;
|
|
|
pocall : pocall_none;
|
|
|
pooption : [po_virtualmethod];
|
|
@@ -2286,7 +2292,7 @@ const
|
|
|
mutexclpo : [po_assembler,po_external,po_virtualmethod]
|
|
|
),(
|
|
|
idtok:_VARARGS;
|
|
|
- pd_flags : [pd_interface,pd_implemen,pd_procvar,pd_objcclass, pd_objcprot];
|
|
|
+ pd_flags : [pd_interface,pd_implemen,pd_procvar,pd_objcclass,pd_objcprot];
|
|
|
handler : nil;
|
|
|
pocall : pocall_none;
|
|
|
pooption : [po_varargs];
|
|
@@ -2305,7 +2311,7 @@ const
|
|
|
mutexclpo : [po_interrupt]
|
|
|
),(
|
|
|
idtok:_WEAKEXTERNAL;
|
|
|
- pd_flags : [pd_implemen,pd_interface,pd_notobject,pd_notobjintf,pd_cppobject];
|
|
|
+ pd_flags : [pd_implemen,pd_interface,pd_notobject,pd_notobjintf,pd_cppobject,pd_notrecord];
|
|
|
handler : @pd_weakexternal;
|
|
|
pocall : pocall_none;
|
|
|
{ mark it both external and weak external, so we don't have to
|
|
@@ -2392,7 +2398,7 @@ const
|
|
|
begin
|
|
|
{ parsing a procvar type the name can be any
|
|
|
next variable !! }
|
|
|
- if ((pdflags * [pd_procvar,pd_object,pd_objcclass,pd_objcprot])=[]) and
|
|
|
+ if ((pdflags * [pd_procvar,pd_object,pd_record,pd_objcclass,pd_objcprot])=[]) and
|
|
|
not(idtoken=_PROPERTY) then
|
|
|
Message1(parser_w_unknown_proc_directive_ignored,name);
|
|
|
exit;
|
|
@@ -2406,6 +2412,10 @@ const
|
|
|
not(is_cppclass(tdef(symtablestack.top.defowner)) and (pd_cppobject in proc_direcdata[p].pd_flags)) then
|
|
|
exit;
|
|
|
|
|
|
+ if (pd_notrecord in proc_direcdata[p].pd_flags) and
|
|
|
+ (symtablestack.top.symtabletype=recordsymtable) then
|
|
|
+ exit;
|
|
|
+
|
|
|
{ Conflicts between directives ? }
|
|
|
if (pd.proctypeoption in proc_direcdata[p].mutexclpotype) or
|
|
|
(pd.proccalloption in proc_direcdata[p].mutexclpocall) or
|
|
@@ -2439,26 +2449,31 @@ const
|
|
|
begin
|
|
|
{ Check if the directive is only for objects }
|
|
|
if (pd_object in proc_direcdata[p].pd_flags) and
|
|
|
- not assigned(tprocdef(pd)._class) then
|
|
|
+ not assigned(tprocdef(pd).struct) then
|
|
|
+ exit;
|
|
|
+
|
|
|
+ { Check if the directive is only for records }
|
|
|
+ if (pd_record in proc_direcdata[p].pd_flags) and
|
|
|
+ not assigned(tprocdef(pd).struct) then
|
|
|
exit;
|
|
|
|
|
|
{ check if method and directive not for interface }
|
|
|
if (pd_notobjintf in proc_direcdata[p].pd_flags) and
|
|
|
- is_interface(tprocdef(pd)._class) then
|
|
|
+ is_interface(tprocdef(pd).struct) then
|
|
|
exit;
|
|
|
|
|
|
{ check if method and directive not for interface }
|
|
|
- if is_dispinterface(tprocdef(pd)._class) and
|
|
|
+ if is_dispinterface(tprocdef(pd).struct) and
|
|
|
not(pd_dispinterface in proc_direcdata[p].pd_flags) then
|
|
|
exit;
|
|
|
|
|
|
{ check if method and directive not for objcclass }
|
|
|
- if is_objcclass(tprocdef(pd)._class) and
|
|
|
+ if is_objcclass(tprocdef(pd).struct) and
|
|
|
not(pd_objcclass in proc_direcdata[p].pd_flags) then
|
|
|
exit;
|
|
|
|
|
|
{ check if method and directive not for objcprotocol }
|
|
|
- if is_objcprotocol(tprocdef(pd)._class) and
|
|
|
+ if is_objcprotocol(tprocdef(pd).struct) and
|
|
|
not(pd_objcprot in proc_direcdata[p].pd_flags) then
|
|
|
exit;
|
|
|
|
|
@@ -2557,8 +2572,8 @@ const
|
|
|
case pd.proccalloption of
|
|
|
pocall_cdecl :
|
|
|
begin
|
|
|
- if assigned(pd._class) then
|
|
|
- result:=target_info.Cprefix+pd._class.objrealname^+'_'+pd.procsym.realname
|
|
|
+ if assigned(pd.struct) then
|
|
|
+ result:=target_info.Cprefix+pd.struct.objrealname^+'_'+pd.procsym.realname
|
|
|
else
|
|
|
result:=target_info.Cprefix+pd.procsym.realname;
|
|
|
end;
|
|
@@ -2628,8 +2643,8 @@ const
|
|
|
case pd.proccalloption of
|
|
|
pocall_cdecl :
|
|
|
begin
|
|
|
- if assigned(pd._class) then
|
|
|
- pd.aliasnames.insert(target_info.Cprefix+pd._class.objrealname^+'_'+pd.procsym.realname)
|
|
|
+ if assigned(pd.struct) then
|
|
|
+ pd.aliasnames.insert(target_info.Cprefix+pd.struct.objrealname^+'_'+pd.procsym.realname)
|
|
|
else
|
|
|
begin
|
|
|
{ Export names are not mangled on Windows and OS/2, see also pexports.pas }
|
|
@@ -2655,13 +2670,13 @@ const
|
|
|
begin
|
|
|
{ set the default calling convention if none provided }
|
|
|
if (pd.typ=procdef) and
|
|
|
- (is_objc_class_or_protocol(tprocdef(pd)._class) or
|
|
|
- is_cppclass(tprocdef(pd)._class)) then
|
|
|
+ (is_objc_class_or_protocol(tprocdef(pd).struct) or
|
|
|
+ is_cppclass(tprocdef(pd).struct)) then
|
|
|
begin
|
|
|
{ none of the explicit calling conventions should be allowed }
|
|
|
if (po_hascallingconvention in pd.procoptions) then
|
|
|
internalerror(2009032501);
|
|
|
- if is_cppclass(tprocdef(pd)._class) then
|
|
|
+ if is_cppclass(tprocdef(pd).struct) then
|
|
|
pd.proccalloption:=pocall_cppdecl
|
|
|
else
|
|
|
pd.proccalloption:=pocall_cdecl;
|
|
@@ -2716,7 +2731,7 @@ const
|
|
|
(pd.typ=procvardef) or
|
|
|
{ for objcclasses this is checked later, because the entire
|
|
|
class may be external. }
|
|
|
- is_objc_class_or_protocol(tprocdef(pd)._class)) and
|
|
|
+ is_objc_class_or_protocol(tprocdef(pd).struct)) and
|
|
|
not(pd.proccalloption in (cdecl_pocalls + [pocall_mwpascal])) then
|
|
|
Message(parser_e_varargs_need_cdecl_and_external);
|
|
|
end
|
|
@@ -2862,6 +2877,13 @@ const
|
|
|
parse_proc_directives(pd,pdflags);
|
|
|
end;
|
|
|
|
|
|
+ procedure parse_record_proc_directives(pd:tabstractprocdef);
|
|
|
+ var
|
|
|
+ pdflags : tpdflags;
|
|
|
+ begin
|
|
|
+ pdflags:=[pd_record];
|
|
|
+ parse_proc_directives(pd,pdflags);
|
|
|
+ end;
|
|
|
|
|
|
function proc_add_definition(var currpd:tprocdef):boolean;
|
|
|
{
|
|
@@ -3141,7 +3163,7 @@ const
|
|
|
{ check if all procs have overloading, but not if the proc is a method or
|
|
|
already declared forward, then the check is already done }
|
|
|
if not(fwpd.hasforward or
|
|
|
- assigned(currpd._class) or
|
|
|
+ assigned(currpd.struct) or
|
|
|
(currpd.forwarddef<>fwpd.forwarddef) or
|
|
|
((po_overload in currpd.procoptions) and
|
|
|
(po_overload in fwpd.procoptions))) then
|