mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 06:49:13 +02:00
compiler: use current_structdef in more places where current_objectdef was used, change type of current_genericdef and current_specializedef to tabstractrecorddef for future use with generic records
git-svn-id: trunk@16659 -
This commit is contained in:
parent
dc5f5c3f63
commit
ee78cf0f06
@ -225,10 +225,10 @@ implementation
|
|||||||
i : longint;
|
i : longint;
|
||||||
def : tdef;
|
def : tdef;
|
||||||
begin
|
begin
|
||||||
include(current_objectdef.objectoptions,oo_has_virtual);
|
include(current_structdef.objectoptions,oo_has_virtual);
|
||||||
for i:=0 to current_objectdef.symtable.DefList.count-1 do
|
for i:=0 to current_structdef.symtable.DefList.count-1 do
|
||||||
begin
|
begin
|
||||||
def:=tdef(current_objectdef.symtable.DefList[i]);
|
def:=tdef(current_structdef.symtable.DefList[i]);
|
||||||
if assigned(def) and
|
if assigned(def) and
|
||||||
(def.typ=procdef) then
|
(def.typ=procdef) then
|
||||||
begin
|
begin
|
||||||
@ -244,9 +244,9 @@ implementation
|
|||||||
i : longint;
|
i : longint;
|
||||||
def : tdef;
|
def : tdef;
|
||||||
begin
|
begin
|
||||||
for i:=0 to current_objectdef.symtable.DefList.count-1 do
|
for i:=0 to current_structdef.symtable.DefList.count-1 do
|
||||||
begin
|
begin
|
||||||
def:=tdef(current_objectdef.symtable.DefList[i]);
|
def:=tdef(current_structdef.symtable.DefList[i]);
|
||||||
if assigned(def) and
|
if assigned(def) and
|
||||||
(def.typ=procdef) then
|
(def.typ=procdef) then
|
||||||
begin
|
begin
|
||||||
@ -334,7 +334,7 @@ implementation
|
|||||||
if (current_objectdef.objecttype in [odt_interfacecom,odt_dispinterface]) and
|
if (current_objectdef.objecttype in [odt_interfacecom,odt_dispinterface]) and
|
||||||
not valid then
|
not valid then
|
||||||
Message(parser_e_improper_guid_syntax);
|
Message(parser_e_improper_guid_syntax);
|
||||||
include(current_objectdef.objectoptions,oo_has_valid_guid);
|
include(current_structdef.objectoptions,oo_has_valid_guid);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Message(parser_e_illegal_expression);
|
Message(parser_e_illegal_expression);
|
||||||
@ -348,14 +348,14 @@ implementation
|
|||||||
while true do
|
while true do
|
||||||
begin
|
begin
|
||||||
if try_to_consume(_ABSTRACT) then
|
if try_to_consume(_ABSTRACT) then
|
||||||
include(current_objectdef.objectoptions,oo_is_abstract)
|
include(current_structdef.objectoptions,oo_is_abstract)
|
||||||
else
|
else
|
||||||
if try_to_consume(_SEALED) then
|
if try_to_consume(_SEALED) then
|
||||||
include(current_objectdef.objectoptions,oo_is_sealed)
|
include(current_structdef.objectoptions,oo_is_sealed)
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
if [oo_is_abstract, oo_is_sealed] * current_objectdef.objectoptions = [oo_is_abstract, oo_is_sealed] then
|
if [oo_is_abstract, oo_is_sealed] * current_structdef.objectoptions = [oo_is_abstract, oo_is_sealed] then
|
||||||
Message(parser_e_abstract_and_sealed_conflict);
|
Message(parser_e_abstract_and_sealed_conflict);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -373,7 +373,7 @@ implementation
|
|||||||
|
|
||||||
{ reads the parent class }
|
{ reads the parent class }
|
||||||
if (token=_LKLAMMER) or
|
if (token=_LKLAMMER) or
|
||||||
is_objccategory(current_objectdef) then
|
is_objccategory(current_structdef) then
|
||||||
begin
|
begin
|
||||||
consume(_LKLAMMER);
|
consume(_LKLAMMER);
|
||||||
{ use single_type instead of id_type for specialize support }
|
{ use single_type instead of id_type for specialize support }
|
||||||
@ -383,7 +383,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
if assigned(hdef) then
|
if assigned(hdef) then
|
||||||
Message1(type_e_class_type_expected,hdef.typename)
|
Message1(type_e_class_type_expected,hdef.typename)
|
||||||
else if is_objccategory(current_objectdef) then
|
else if is_objccategory(current_structdef) then
|
||||||
{ a category must specify the class to extend }
|
{ a category must specify the class to extend }
|
||||||
Message(type_e_objcclass_type_expected);
|
Message(type_e_objcclass_type_expected);
|
||||||
end
|
end
|
||||||
@ -426,7 +426,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
if is_objcprotocol(childof) then
|
if is_objcprotocol(childof) then
|
||||||
begin
|
begin
|
||||||
if not(oo_is_classhelper in current_objectdef.objectoptions) then
|
if not(oo_is_classhelper in current_structdef.objectoptions) then
|
||||||
begin
|
begin
|
||||||
intfchildof:=childof;
|
intfchildof:=childof;
|
||||||
childof:=nil;
|
childof:=nil;
|
||||||
@ -499,7 +499,7 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{ remove forward flag, is resolved }
|
{ remove forward flag, is resolved }
|
||||||
exclude(current_objectdef.objectoptions,oo_is_forward);
|
exclude(current_structdef.objectoptions,oo_is_forward);
|
||||||
|
|
||||||
if hasparentdefined then
|
if hasparentdefined then
|
||||||
begin
|
begin
|
||||||
@ -536,16 +536,16 @@ implementation
|
|||||||
i : longint;
|
i : longint;
|
||||||
generictype : ttypesym;
|
generictype : ttypesym;
|
||||||
begin
|
begin
|
||||||
current_objectdef.genericdef:=genericdef;
|
current_structdef.genericdef:=genericdef;
|
||||||
if not assigned(genericlist) then
|
if not assigned(genericlist) then
|
||||||
exit;
|
exit;
|
||||||
for i:=0 to genericlist.count-1 do
|
for i:=0 to genericlist.count-1 do
|
||||||
begin
|
begin
|
||||||
generictype:=ttypesym(genericlist[i]);
|
generictype:=ttypesym(genericlist[i]);
|
||||||
if generictype.typedef.typ=undefineddef then
|
if generictype.typedef.typ=undefineddef then
|
||||||
include(current_objectdef.defoptions,df_generic)
|
include(current_structdef.defoptions,df_generic)
|
||||||
else
|
else
|
||||||
include(current_objectdef.defoptions,df_specialization);
|
include(current_structdef.defoptions,df_specialization);
|
||||||
symtablestack.top.insert(generictype);
|
symtablestack.top.insert(generictype);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -601,12 +601,12 @@ implementation
|
|||||||
|
|
||||||
old_parse_generic:=parse_generic;
|
old_parse_generic:=parse_generic;
|
||||||
|
|
||||||
parse_generic:=(df_generic in current_objectdef.defoptions);
|
parse_generic:=(df_generic in current_structdef.defoptions);
|
||||||
{ in "publishable" classes the default access type is published }
|
{ in "publishable" classes the default access type is published }
|
||||||
if (oo_can_have_published in current_objectdef.objectoptions) then
|
if (oo_can_have_published in current_structdef.objectoptions) then
|
||||||
current_objectdef.symtable.currentvisibility:=vis_published
|
current_structdef.symtable.currentvisibility:=vis_published
|
||||||
else
|
else
|
||||||
current_objectdef.symtable.currentvisibility:=vis_public;
|
current_structdef.symtable.currentvisibility:=vis_public;
|
||||||
has_destructor:=false;
|
has_destructor:=false;
|
||||||
fields_allowed:=true;
|
fields_allowed:=true;
|
||||||
is_classdef:=false;
|
is_classdef:=false;
|
||||||
@ -616,7 +616,7 @@ implementation
|
|||||||
case token of
|
case token of
|
||||||
_TYPE :
|
_TYPE :
|
||||||
begin
|
begin
|
||||||
if (([df_generic,df_specialization]*current_objectdef.defoptions)=[]) and
|
if (([df_generic,df_specialization]*current_structdef.defoptions)=[]) and
|
||||||
not(current_objectdef.objecttype in [odt_class,odt_object]) then
|
not(current_objectdef.objecttype in [odt_class,odt_object]) then
|
||||||
Message(parser_e_type_var_const_only_in_generics_and_classes);
|
Message(parser_e_type_var_const_only_in_generics_and_classes);
|
||||||
consume(_TYPE);
|
consume(_TYPE);
|
||||||
@ -624,7 +624,7 @@ implementation
|
|||||||
end;
|
end;
|
||||||
_VAR :
|
_VAR :
|
||||||
begin
|
begin
|
||||||
if (([df_generic,df_specialization]*current_objectdef.defoptions)=[]) and
|
if (([df_generic,df_specialization]*current_structdef.defoptions)=[]) and
|
||||||
not(current_objectdef.objecttype in [odt_class,odt_object]) then
|
not(current_objectdef.objecttype in [odt_class,odt_object]) then
|
||||||
Message(parser_e_type_var_const_only_in_generics_and_classes);
|
Message(parser_e_type_var_const_only_in_generics_and_classes);
|
||||||
consume(_VAR);
|
consume(_VAR);
|
||||||
@ -635,7 +635,7 @@ implementation
|
|||||||
end;
|
end;
|
||||||
_CONST:
|
_CONST:
|
||||||
begin
|
begin
|
||||||
if (([df_generic,df_specialization]*current_objectdef.defoptions)=[]) and
|
if (([df_generic,df_specialization]*current_structdef.defoptions)=[]) and
|
||||||
not(current_objectdef.objecttype in [odt_class,odt_object]) then
|
not(current_objectdef.objecttype in [odt_class,odt_object]) then
|
||||||
Message(parser_e_type_var_const_only_in_generics_and_classes);
|
Message(parser_e_type_var_const_only_in_generics_and_classes);
|
||||||
consume(_CONST);
|
consume(_CONST);
|
||||||
@ -643,22 +643,22 @@ implementation
|
|||||||
end;
|
end;
|
||||||
_ID :
|
_ID :
|
||||||
begin
|
begin
|
||||||
if is_objcprotocol(current_objectdef) and
|
if is_objcprotocol(current_structdef) and
|
||||||
((idtoken=_REQUIRED) or
|
((idtoken=_REQUIRED) or
|
||||||
(idtoken=_OPTIONAL)) then
|
(idtoken=_OPTIONAL)) then
|
||||||
begin
|
begin
|
||||||
current_objectdef.symtable.currentlyoptional:=(idtoken=_OPTIONAL);
|
current_structdef.symtable.currentlyoptional:=(idtoken=_OPTIONAL);
|
||||||
consume(idtoken)
|
consume(idtoken)
|
||||||
end
|
end
|
||||||
else case idtoken of
|
else case idtoken of
|
||||||
_PRIVATE :
|
_PRIVATE :
|
||||||
begin
|
begin
|
||||||
if is_interface(current_objectdef) or
|
if is_interface(current_structdef) or
|
||||||
is_objc_protocol_or_category(current_objectdef) then
|
is_objc_protocol_or_category(current_structdef) then
|
||||||
Message(parser_e_no_access_specifier_in_interfaces);
|
Message(parser_e_no_access_specifier_in_interfaces);
|
||||||
consume(_PRIVATE);
|
consume(_PRIVATE);
|
||||||
current_objectdef.symtable.currentvisibility:=vis_private;
|
current_structdef.symtable.currentvisibility:=vis_private;
|
||||||
include(current_objectdef.objectoptions,oo_has_private);
|
include(current_structdef.objectoptions,oo_has_private);
|
||||||
fields_allowed:=true;
|
fields_allowed:=true;
|
||||||
is_classdef:=false;
|
is_classdef:=false;
|
||||||
classfields:=false;
|
classfields:=false;
|
||||||
@ -666,12 +666,12 @@ implementation
|
|||||||
end;
|
end;
|
||||||
_PROTECTED :
|
_PROTECTED :
|
||||||
begin
|
begin
|
||||||
if is_interface(current_objectdef) or
|
if is_interface(current_structdef) or
|
||||||
is_objc_protocol_or_category(current_objectdef) then
|
is_objc_protocol_or_category(current_structdef) then
|
||||||
Message(parser_e_no_access_specifier_in_interfaces);
|
Message(parser_e_no_access_specifier_in_interfaces);
|
||||||
consume(_PROTECTED);
|
consume(_PROTECTED);
|
||||||
current_objectdef.symtable.currentvisibility:=vis_protected;
|
current_structdef.symtable.currentvisibility:=vis_protected;
|
||||||
include(current_objectdef.objectoptions,oo_has_protected);
|
include(current_structdef.objectoptions,oo_has_protected);
|
||||||
fields_allowed:=true;
|
fields_allowed:=true;
|
||||||
is_classdef:=false;
|
is_classdef:=false;
|
||||||
classfields:=false;
|
classfields:=false;
|
||||||
@ -679,11 +679,11 @@ implementation
|
|||||||
end;
|
end;
|
||||||
_PUBLIC :
|
_PUBLIC :
|
||||||
begin
|
begin
|
||||||
if is_interface(current_objectdef) or
|
if is_interface(current_structdef) or
|
||||||
is_objc_protocol_or_category(current_objectdef) then
|
is_objc_protocol_or_category(current_structdef) then
|
||||||
Message(parser_e_no_access_specifier_in_interfaces);
|
Message(parser_e_no_access_specifier_in_interfaces);
|
||||||
consume(_PUBLIC);
|
consume(_PUBLIC);
|
||||||
current_objectdef.symtable.currentvisibility:=vis_public;
|
current_structdef.symtable.currentvisibility:=vis_public;
|
||||||
fields_allowed:=true;
|
fields_allowed:=true;
|
||||||
is_classdef:=false;
|
is_classdef:=false;
|
||||||
classfields:=false;
|
classfields:=false;
|
||||||
@ -694,14 +694,14 @@ implementation
|
|||||||
{ we've to check for a pushlished section in non- }
|
{ we've to check for a pushlished section in non- }
|
||||||
{ publishable classes later, if a real declaration }
|
{ publishable classes later, if a real declaration }
|
||||||
{ this is the way, delphi does it }
|
{ this is the way, delphi does it }
|
||||||
if is_interface(current_objectdef) then
|
if is_interface(current_structdef) then
|
||||||
Message(parser_e_no_access_specifier_in_interfaces);
|
Message(parser_e_no_access_specifier_in_interfaces);
|
||||||
{ Objective-C classes do not support "published",
|
{ Objective-C classes do not support "published",
|
||||||
as basically everything is published. }
|
as basically everything is published. }
|
||||||
if is_objc_class_or_protocol(current_objectdef) then
|
if is_objc_class_or_protocol(current_structdef) then
|
||||||
Message(parser_e_no_objc_published);
|
Message(parser_e_no_objc_published);
|
||||||
consume(_PUBLISHED);
|
consume(_PUBLISHED);
|
||||||
current_objectdef.symtable.currentvisibility:=vis_published;
|
current_structdef.symtable.currentvisibility:=vis_published;
|
||||||
fields_allowed:=true;
|
fields_allowed:=true;
|
||||||
is_classdef:=false;
|
is_classdef:=false;
|
||||||
classfields:=false;
|
classfields:=false;
|
||||||
@ -709,8 +709,8 @@ implementation
|
|||||||
end;
|
end;
|
||||||
_STRICT :
|
_STRICT :
|
||||||
begin
|
begin
|
||||||
if is_interface(current_objectdef) or
|
if is_interface(current_structdef) or
|
||||||
is_objc_protocol_or_category(current_objectdef) then
|
is_objc_protocol_or_category(current_structdef) then
|
||||||
Message(parser_e_no_access_specifier_in_interfaces);
|
Message(parser_e_no_access_specifier_in_interfaces);
|
||||||
consume(_STRICT);
|
consume(_STRICT);
|
||||||
if token=_ID then
|
if token=_ID then
|
||||||
@ -719,14 +719,14 @@ implementation
|
|||||||
_PRIVATE:
|
_PRIVATE:
|
||||||
begin
|
begin
|
||||||
consume(_PRIVATE);
|
consume(_PRIVATE);
|
||||||
current_objectdef.symtable.currentvisibility:=vis_strictprivate;
|
current_structdef.symtable.currentvisibility:=vis_strictprivate;
|
||||||
include(current_objectdef.objectoptions,oo_has_strictprivate);
|
include(current_structdef.objectoptions,oo_has_strictprivate);
|
||||||
end;
|
end;
|
||||||
_PROTECTED:
|
_PROTECTED:
|
||||||
begin
|
begin
|
||||||
consume(_PROTECTED);
|
consume(_PROTECTED);
|
||||||
current_objectdef.symtable.currentvisibility:=vis_strictprotected;
|
current_structdef.symtable.currentvisibility:=vis_strictprotected;
|
||||||
include(current_objectdef.objectoptions,oo_has_strictprotected);
|
include(current_structdef.objectoptions,oo_has_strictprotected);
|
||||||
end;
|
end;
|
||||||
else
|
else
|
||||||
message(parser_e_protected_or_private_expected);
|
message(parser_e_protected_or_private_expected);
|
||||||
@ -743,12 +743,12 @@ implementation
|
|||||||
begin
|
begin
|
||||||
if object_member_blocktype=bt_general then
|
if object_member_blocktype=bt_general then
|
||||||
begin
|
begin
|
||||||
if is_interface(current_objectdef) or
|
if is_interface(current_structdef) or
|
||||||
is_objc_protocol_or_category(current_objectdef) then
|
is_objc_protocol_or_category(current_structdef) then
|
||||||
Message(parser_e_no_vars_in_interfaces);
|
Message(parser_e_no_vars_in_interfaces);
|
||||||
|
|
||||||
if (current_objectdef.symtable.currentvisibility=vis_published) and
|
if (current_structdef.symtable.currentvisibility=vis_published) and
|
||||||
not(oo_can_have_published in current_objectdef.objectoptions) then
|
not(oo_can_have_published in current_structdef.objectoptions) then
|
||||||
Message(parser_e_cant_have_published);
|
Message(parser_e_cant_have_published);
|
||||||
if (not fields_allowed) then
|
if (not fields_allowed) then
|
||||||
Message(parser_e_field_not_allowed_here);
|
Message(parser_e_field_not_allowed_here);
|
||||||
@ -784,7 +784,7 @@ implementation
|
|||||||
if not(token in [_FUNCTION,_PROCEDURE,_PROPERTY,_VAR,_CONSTRUCTOR,_DESTRUCTOR]) then
|
if not(token in [_FUNCTION,_PROCEDURE,_PROPERTY,_VAR,_CONSTRUCTOR,_DESTRUCTOR]) then
|
||||||
Message(parser_e_procedure_or_function_expected);
|
Message(parser_e_procedure_or_function_expected);
|
||||||
|
|
||||||
if is_interface(current_objectdef) then
|
if is_interface(current_structdef) then
|
||||||
Message(parser_e_no_static_method_in_interfaces)
|
Message(parser_e_no_static_method_in_interfaces)
|
||||||
else
|
else
|
||||||
{ class methods are also allowed for Objective-C protocols }
|
{ class methods are also allowed for Objective-C protocols }
|
||||||
@ -794,13 +794,13 @@ implementation
|
|||||||
_PROCEDURE,
|
_PROCEDURE,
|
||||||
_FUNCTION:
|
_FUNCTION:
|
||||||
begin
|
begin
|
||||||
if (current_objectdef.symtable.currentvisibility=vis_published) and
|
if (current_structdef.symtable.currentvisibility=vis_published) and
|
||||||
not(oo_can_have_published in current_objectdef.objectoptions) then
|
not(oo_can_have_published in current_structdef.objectoptions) then
|
||||||
Message(parser_e_cant_have_published);
|
Message(parser_e_cant_have_published);
|
||||||
|
|
||||||
oldparse_only:=parse_only;
|
oldparse_only:=parse_only;
|
||||||
parse_only:=true;
|
parse_only:=true;
|
||||||
pd:=parse_proc_dec(is_classdef,current_objectdef);
|
pd:=parse_proc_dec(is_classdef,current_structdef);
|
||||||
|
|
||||||
{ this is for error recovery as well as forward }
|
{ this is for error recovery as well as forward }
|
||||||
{ interface mappings, i.e. mapping to a method }
|
{ interface mappings, i.e. mapping to a method }
|
||||||
@ -829,11 +829,11 @@ implementation
|
|||||||
|
|
||||||
{ add procdef options to objectdef options }
|
{ add procdef options to objectdef options }
|
||||||
if (po_msgint in pd.procoptions) then
|
if (po_msgint in pd.procoptions) then
|
||||||
include(current_objectdef.objectoptions,oo_has_msgint);
|
include(current_structdef.objectoptions,oo_has_msgint);
|
||||||
if (po_msgstr in pd.procoptions) then
|
if (po_msgstr in pd.procoptions) then
|
||||||
include(current_objectdef.objectoptions,oo_has_msgstr);
|
include(current_structdef.objectoptions,oo_has_msgstr);
|
||||||
if (po_virtualmethod in pd.procoptions) then
|
if (po_virtualmethod in pd.procoptions) then
|
||||||
include(current_objectdef.objectoptions,oo_has_virtual);
|
include(current_structdef.objectoptions,oo_has_virtual);
|
||||||
|
|
||||||
chkcpp(pd);
|
chkcpp(pd);
|
||||||
chkobjc(pd);
|
chkobjc(pd);
|
||||||
@ -847,23 +847,23 @@ implementation
|
|||||||
end;
|
end;
|
||||||
_CONSTRUCTOR :
|
_CONSTRUCTOR :
|
||||||
begin
|
begin
|
||||||
if (current_objectdef.symtable.currentvisibility=vis_published) and
|
if (current_structdef.symtable.currentvisibility=vis_published) and
|
||||||
not(oo_can_have_published in current_objectdef.objectoptions) then
|
not(oo_can_have_published in current_structdef.objectoptions) then
|
||||||
Message(parser_e_cant_have_published);
|
Message(parser_e_cant_have_published);
|
||||||
|
|
||||||
if not is_classdef and not(current_objectdef.symtable.currentvisibility in [vis_public,vis_published]) then
|
if not is_classdef and not(current_structdef.symtable.currentvisibility in [vis_public,vis_published]) then
|
||||||
Message(parser_w_constructor_should_be_public);
|
Message(parser_w_constructor_should_be_public);
|
||||||
|
|
||||||
if is_interface(current_objectdef) then
|
if is_interface(current_structdef) then
|
||||||
Message(parser_e_no_con_des_in_interfaces);
|
Message(parser_e_no_con_des_in_interfaces);
|
||||||
|
|
||||||
{ Objective-C does not know the concept of a constructor }
|
{ Objective-C does not know the concept of a constructor }
|
||||||
if is_objc_class_or_protocol(current_objectdef) then
|
if is_objc_class_or_protocol(current_structdef) then
|
||||||
Message(parser_e_objc_no_constructor_destructor);
|
Message(parser_e_objc_no_constructor_destructor);
|
||||||
|
|
||||||
{ only 1 class constructor is allowed }
|
{ only 1 class constructor is allowed }
|
||||||
if is_classdef and (oo_has_class_constructor in current_objectdef.objectoptions) then
|
if is_classdef and (oo_has_class_constructor in current_structdef.objectoptions) then
|
||||||
Message1(parser_e_only_one_class_constructor_allowed, current_objectdef.objrealname^);
|
Message1(parser_e_only_one_class_constructor_allowed, current_structdef.objrealname^);
|
||||||
|
|
||||||
oldparse_only:=parse_only;
|
oldparse_only:=parse_only;
|
||||||
parse_only:=true;
|
parse_only:=true;
|
||||||
@ -879,7 +879,7 @@ implementation
|
|||||||
|
|
||||||
{ add procdef options to objectdef options }
|
{ add procdef options to objectdef options }
|
||||||
if (po_virtualmethod in pd.procoptions) then
|
if (po_virtualmethod in pd.procoptions) then
|
||||||
include(current_objectdef.objectoptions,oo_has_virtual);
|
include(current_structdef.objectoptions,oo_has_virtual);
|
||||||
chkcpp(pd);
|
chkcpp(pd);
|
||||||
maybe_parse_hint_directives(pd);
|
maybe_parse_hint_directives(pd);
|
||||||
|
|
||||||
@ -889,8 +889,8 @@ implementation
|
|||||||
end;
|
end;
|
||||||
_DESTRUCTOR :
|
_DESTRUCTOR :
|
||||||
begin
|
begin
|
||||||
if (current_objectdef.symtable.currentvisibility=vis_published) and
|
if (current_structdef.symtable.currentvisibility=vis_published) and
|
||||||
not(oo_can_have_published in current_objectdef.objectoptions) then
|
not(oo_can_have_published in current_structdef.objectoptions) then
|
||||||
Message(parser_e_cant_have_published);
|
Message(parser_e_cant_have_published);
|
||||||
|
|
||||||
if not is_classdef then
|
if not is_classdef then
|
||||||
@ -899,19 +899,19 @@ implementation
|
|||||||
else
|
else
|
||||||
has_destructor:=true;
|
has_destructor:=true;
|
||||||
|
|
||||||
if is_interface(current_objectdef) then
|
if is_interface(current_structdef) then
|
||||||
Message(parser_e_no_con_des_in_interfaces);
|
Message(parser_e_no_con_des_in_interfaces);
|
||||||
|
|
||||||
if not is_classdef and (current_objectdef.symtable.currentvisibility<>vis_public) then
|
if not is_classdef and (current_structdef.symtable.currentvisibility<>vis_public) then
|
||||||
Message(parser_w_destructor_should_be_public);
|
Message(parser_w_destructor_should_be_public);
|
||||||
|
|
||||||
{ Objective-C does not know the concept of a destructor }
|
{ Objective-C does not know the concept of a destructor }
|
||||||
if is_objc_class_or_protocol(current_objectdef) then
|
if is_objc_class_or_protocol(current_structdef) then
|
||||||
Message(parser_e_objc_no_constructor_destructor);
|
Message(parser_e_objc_no_constructor_destructor);
|
||||||
|
|
||||||
{ only 1 class destructor is allowed }
|
{ only 1 class destructor is allowed }
|
||||||
if is_classdef and (oo_has_class_destructor in current_objectdef.objectoptions) then
|
if is_classdef and (oo_has_class_destructor in current_structdef.objectoptions) then
|
||||||
Message1(parser_e_only_one_class_destructor_allowed, current_objectdef.objrealname^);
|
Message1(parser_e_only_one_class_destructor_allowed, current_structdef.objrealname^);
|
||||||
|
|
||||||
oldparse_only:=parse_only;
|
oldparse_only:=parse_only;
|
||||||
parse_only:=true;
|
parse_only:=true;
|
||||||
@ -927,7 +927,7 @@ implementation
|
|||||||
|
|
||||||
{ add procdef options to objectdef options }
|
{ add procdef options to objectdef options }
|
||||||
if (po_virtualmethod in pd.procoptions) then
|
if (po_virtualmethod in pd.procoptions) then
|
||||||
include(current_objectdef.objectoptions,oo_has_virtual);
|
include(current_structdef.objectoptions,oo_has_virtual);
|
||||||
|
|
||||||
chkcpp(pd);
|
chkcpp(pd);
|
||||||
maybe_parse_hint_directives(pd);
|
maybe_parse_hint_directives(pd);
|
||||||
@ -953,15 +953,15 @@ implementation
|
|||||||
|
|
||||||
function object_dec(objecttype:tobjecttyp;const n:tidstring;genericdef:tstoreddef;genericlist:TFPObjectList;fd : tobjectdef) : tobjectdef;
|
function object_dec(objecttype:tobjecttyp;const n:tidstring;genericdef:tstoreddef;genericlist:TFPObjectList;fd : tobjectdef) : tobjectdef;
|
||||||
var
|
var
|
||||||
old_current_objectdef : tobjectdef;
|
old_current_structdef,
|
||||||
old_current_genericdef : tobjectdef;
|
old_current_genericdef,
|
||||||
old_current_specializedef : tobjectdef;
|
old_current_specializedef: tabstractrecorddef;
|
||||||
begin
|
begin
|
||||||
old_current_objectdef:=current_objectdef;
|
old_current_structdef:=current_structdef;
|
||||||
old_current_genericdef:=current_genericdef;
|
old_current_genericdef:=current_genericdef;
|
||||||
old_current_specializedef:=current_specializedef;
|
old_current_specializedef:=current_specializedef;
|
||||||
|
|
||||||
current_objectdef:=nil;
|
current_structdef:=nil;
|
||||||
current_genericdef:=nil;
|
current_genericdef:=nil;
|
||||||
current_specializedef:=nil;
|
current_specializedef:=nil;
|
||||||
|
|
||||||
@ -977,11 +977,11 @@ implementation
|
|||||||
begin
|
begin
|
||||||
Message(parser_e_forward_mismatch);
|
Message(parser_e_forward_mismatch);
|
||||||
{ recover }
|
{ recover }
|
||||||
current_objectdef:=tobjectdef.create(current_objectdef.objecttype,n,nil);
|
current_structdef:=tobjectdef.create(current_objectdef.objecttype,n,nil);
|
||||||
include(current_objectdef.objectoptions,oo_is_forward);
|
include(current_structdef.objectoptions,oo_is_forward);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
current_objectdef:=fd
|
current_structdef:=fd
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
@ -990,20 +990,20 @@ implementation
|
|||||||
Message(parser_f_no_anonym_objects);
|
Message(parser_f_no_anonym_objects);
|
||||||
|
|
||||||
{ create new class }
|
{ create new class }
|
||||||
current_objectdef:=tobjectdef.create(objecttype,n,nil);
|
current_structdef:=tobjectdef.create(objecttype,n,nil);
|
||||||
|
|
||||||
{ include always the forward flag, it'll be removed after the parent class have been
|
{ include always the forward flag, it'll be removed after the parent class have been
|
||||||
added. This is to prevent circular childof loops }
|
added. This is to prevent circular childof loops }
|
||||||
include(current_objectdef.objectoptions,oo_is_forward);
|
include(current_structdef.objectoptions,oo_is_forward);
|
||||||
|
|
||||||
if (cs_compilesystem in current_settings.moduleswitches) then
|
if (cs_compilesystem in current_settings.moduleswitches) then
|
||||||
begin
|
begin
|
||||||
case current_objectdef.objecttype of
|
case current_objectdef.objecttype of
|
||||||
odt_interfacecom :
|
odt_interfacecom :
|
||||||
if (current_objectdef.objname^='IUNKNOWN') then
|
if (current_structdef.objname^='IUNKNOWN') then
|
||||||
interface_iunknown:=current_objectdef;
|
interface_iunknown:=current_objectdef;
|
||||||
odt_class :
|
odt_class :
|
||||||
if (current_objectdef.objname^='TOBJECT') then
|
if (current_structdef.objname^='TOBJECT') then
|
||||||
class_tobject:=current_objectdef;
|
class_tobject:=current_objectdef;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1019,16 +1019,16 @@ implementation
|
|||||||
|
|
||||||
{ usage of specialized type inside its generic template }
|
{ usage of specialized type inside its generic template }
|
||||||
if assigned(genericdef) then
|
if assigned(genericdef) then
|
||||||
current_specializedef:=current_objectdef
|
current_specializedef:=current_structdef
|
||||||
{ reject declaration of generic class inside generic class }
|
{ reject declaration of generic class inside generic class }
|
||||||
else if assigned(genericlist) then
|
else if assigned(genericlist) then
|
||||||
current_genericdef:=current_objectdef;
|
current_genericdef:=current_structdef;
|
||||||
|
|
||||||
{ set published flag in $M+ mode, it can also be inherited and will
|
{ set published flag in $M+ mode, it can also be inherited and will
|
||||||
be added when the parent class set with tobjectdef.set_parent (PFV) }
|
be added when the parent class set with tobjectdef.set_parent (PFV) }
|
||||||
if (cs_generate_rtti in current_settings.localswitches) and
|
if (cs_generate_rtti in current_settings.localswitches) and
|
||||||
(current_objectdef.objecttype in [odt_interfacecom,odt_class]) then
|
(current_objectdef.objecttype in [odt_interfacecom,odt_class]) then
|
||||||
include(current_objectdef.objectoptions,oo_can_have_published);
|
include(current_structdef.objectoptions,oo_can_have_published);
|
||||||
|
|
||||||
{ forward def? }
|
{ forward def? }
|
||||||
if not assigned(fd) and
|
if not assigned(fd) and
|
||||||
@ -1036,7 +1036,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
{ add to the list of definitions to check that the forward
|
{ add to the list of definitions to check that the forward
|
||||||
is resolved. this is required for delphi mode }
|
is resolved. this is required for delphi mode }
|
||||||
current_module.checkforwarddefs.add(current_objectdef);
|
current_module.checkforwarddefs.add(current_structdef);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
@ -1044,7 +1044,7 @@ implementation
|
|||||||
if (objecttype=odt_objccategory) then
|
if (objecttype=odt_objccategory) then
|
||||||
begin
|
begin
|
||||||
current_objectdef.objecttype:=odt_objcclass;
|
current_objectdef.objecttype:=odt_objcclass;
|
||||||
include(current_objectdef.objectoptions,oo_is_classhelper);
|
include(current_structdef.objectoptions,oo_is_classhelper);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ parse list of options (abstract / sealed) }
|
{ parse list of options (abstract / sealed) }
|
||||||
@ -1056,40 +1056,40 @@ implementation
|
|||||||
{ parse optional GUID for interfaces }
|
{ parse optional GUID for interfaces }
|
||||||
parse_guid;
|
parse_guid;
|
||||||
|
|
||||||
symtablestack.push(current_objectdef.symtable);
|
symtablestack.push(current_structdef.symtable);
|
||||||
insert_generic_parameter_types(genericdef,genericlist);
|
insert_generic_parameter_types(genericdef,genericlist);
|
||||||
{ parse and insert object members }
|
{ parse and insert object members }
|
||||||
parse_object_members;
|
parse_object_members;
|
||||||
symtablestack.pop(current_objectdef.symtable);
|
symtablestack.pop(current_structdef.symtable);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ generate vmt space if needed }
|
{ generate vmt space if needed }
|
||||||
if not(oo_has_vmt in current_objectdef.objectoptions) and
|
if not(oo_has_vmt in current_structdef.objectoptions) and
|
||||||
not(oo_is_forward in current_objectdef.objectoptions) and
|
not(oo_is_forward in current_structdef.objectoptions) and
|
||||||
(
|
(
|
||||||
([oo_has_virtual,oo_has_constructor,oo_has_destructor]*current_objectdef.objectoptions<>[]) or
|
([oo_has_virtual,oo_has_constructor,oo_has_destructor]*current_structdef.objectoptions<>[]) or
|
||||||
(current_objectdef.objecttype in [odt_class])
|
(current_objectdef.objecttype in [odt_class])
|
||||||
) then
|
) then
|
||||||
current_objectdef.insertvmt;
|
current_objectdef.insertvmt;
|
||||||
|
|
||||||
{ for implemented classes with a vmt check if there is a constructor }
|
{ for implemented classes with a vmt check if there is a constructor }
|
||||||
if (oo_has_vmt in current_objectdef.objectoptions) and
|
if (oo_has_vmt in current_structdef.objectoptions) and
|
||||||
not(oo_is_forward in current_objectdef.objectoptions) and
|
not(oo_is_forward in current_structdef.objectoptions) and
|
||||||
not(oo_has_constructor in current_objectdef.objectoptions) and
|
not(oo_has_constructor in current_structdef.objectoptions) and
|
||||||
not is_objc_class_or_protocol(current_objectdef) then
|
not is_objc_class_or_protocol(current_structdef) then
|
||||||
Message1(parser_w_virtual_without_constructor,current_objectdef.objrealname^);
|
Message1(parser_w_virtual_without_constructor,current_structdef.objrealname^);
|
||||||
|
|
||||||
if is_interface(current_objectdef) or
|
if is_interface(current_structdef) or
|
||||||
is_objcprotocol(current_objectdef) then
|
is_objcprotocol(current_structdef) then
|
||||||
setinterfacemethodoptions
|
setinterfacemethodoptions
|
||||||
else if is_objcclass(current_objectdef) then
|
else if is_objcclass(current_structdef) then
|
||||||
setobjcclassmethodoptions;
|
setobjcclassmethodoptions;
|
||||||
|
|
||||||
{ return defined objectdef }
|
{ return defined objectdef }
|
||||||
result:=current_objectdef;
|
result:=current_objectdef;
|
||||||
|
|
||||||
{ restore old state }
|
{ restore old state }
|
||||||
current_objectdef:=old_current_objectdef;
|
current_structdef:=old_current_structdef;
|
||||||
current_genericdef:=old_current_genericdef;
|
current_genericdef:=old_current_genericdef;
|
||||||
current_specializedef:=old_current_specializedef;
|
current_specializedef:=old_current_specializedef;
|
||||||
end;
|
end;
|
||||||
|
@ -802,9 +802,9 @@ implementation
|
|||||||
popclass : integer;
|
popclass : integer;
|
||||||
ImplIntf : TImplementedInterface;
|
ImplIntf : TImplementedInterface;
|
||||||
old_parse_generic : boolean;
|
old_parse_generic : boolean;
|
||||||
old_current_structdef: tabstractrecorddef;
|
old_current_structdef,
|
||||||
old_current_genericdef,
|
old_current_genericdef,
|
||||||
old_current_specializedef : tobjectdef;
|
old_current_specializedef : tabstractrecorddef;
|
||||||
lasttoken,lastidtoken: ttoken;
|
lasttoken,lastidtoken: ttoken;
|
||||||
|
|
||||||
procedure parse_operator_name;
|
procedure parse_operator_name;
|
||||||
@ -1189,9 +1189,9 @@ implementation
|
|||||||
var
|
var
|
||||||
popclass: integer;
|
popclass: integer;
|
||||||
old_parse_generic: boolean;
|
old_parse_generic: boolean;
|
||||||
old_current_structdef: tabstractrecorddef;
|
old_current_structdef,
|
||||||
old_current_genericdef,
|
old_current_genericdef,
|
||||||
old_current_specializedef: tobjectdef;
|
old_current_specializedef: tabstractrecorddef;
|
||||||
begin
|
begin
|
||||||
old_parse_generic:=parse_generic;
|
old_parse_generic:=parse_generic;
|
||||||
{ Add ObjectSymtable to be able to find generic type definitions }
|
{ Add ObjectSymtable to be able to find generic type definitions }
|
||||||
|
@ -1388,9 +1388,9 @@ implementation
|
|||||||
old_current_procinfo : tprocinfo;
|
old_current_procinfo : tprocinfo;
|
||||||
old_block_type : tblock_type;
|
old_block_type : tblock_type;
|
||||||
st : TSymtable;
|
st : TSymtable;
|
||||||
old_current_structdef: tabstractrecorddef;
|
old_current_structdef,
|
||||||
old_current_genericdef,
|
old_current_genericdef,
|
||||||
old_current_specializedef : tobjectdef;
|
old_current_specializedef: tabstractrecorddef;
|
||||||
begin
|
begin
|
||||||
old_current_procinfo:=current_procinfo;
|
old_current_procinfo:=current_procinfo;
|
||||||
old_block_type:=block_type;
|
old_block_type:=block_type;
|
||||||
@ -1655,9 +1655,9 @@ implementation
|
|||||||
|
|
||||||
var
|
var
|
||||||
old_current_procinfo : tprocinfo;
|
old_current_procinfo : tprocinfo;
|
||||||
old_current_structdef: tabstractrecorddef;
|
old_current_structdef,
|
||||||
old_current_genericdef,
|
old_current_genericdef,
|
||||||
old_current_specializedef : tobjectdef;
|
old_current_specializedef: tabstractrecorddef;
|
||||||
pdflags : tpdflags;
|
pdflags : tpdflags;
|
||||||
pd,firstpd : tprocdef;
|
pd,firstpd : tprocdef;
|
||||||
s : string;
|
s : string;
|
||||||
|
@ -643,8 +643,8 @@ interface
|
|||||||
var
|
var
|
||||||
current_structdef: tabstractrecorddef; { used for private functions check !! }
|
current_structdef: tabstractrecorddef; { used for private functions check !! }
|
||||||
current_objectdef : tobjectdef absolute current_structdef;
|
current_objectdef : tobjectdef absolute current_structdef;
|
||||||
current_genericdef : tobjectdef; { used to reject declaration of generic class inside generic class }
|
current_genericdef : tabstractrecorddef; { used to reject declaration of generic class inside generic class }
|
||||||
current_specializedef : tobjectdef; { used to implement usage of generic class in itself }
|
current_specializedef : tabstractrecorddef; { used to implement usage of generic class in itself }
|
||||||
|
|
||||||
{ default types }
|
{ default types }
|
||||||
generrordef, { error in definition }
|
generrordef, { error in definition }
|
||||||
|
Loading…
Reference in New Issue
Block a user