2
0
Эх сурвалжийг харах

compiler: don't allow generic object types (interfaces,dispinterfaces,objclasses,...) to have type,var,const sections if regular object types don't have them. currently only objects, classes and records are allowed to have nested type,var,const sections.

git-svn-id: trunk@16669 -
paul 14 жил өмнө
parent
commit
101f545ad0

+ 2 - 2
compiler/msg/errord.msg

@@ -1117,9 +1117,9 @@ parser_e_packed_element_no_loop=03223_E_Bit packed Array-Elemente und Record-Fel
 % (or as \var{packed} in any mode with \var{\{\$bitpacking on\}}), it will
 % be packed at the bit level. For performance reasons, they cannot be
 % used as loop variables.
-parser_e_type_var_const_only_in_generics_and_classes=03224_E_VAR, TYPE und CONST sind nur innerhalb "generics" und Klassen erlaubt
+parser_e_type_var_const_only_in_records_and_classes=03224_E_VAR, TYPE und CONST sind nur innerhalb records, objects und Klassen erlaubt
 % The usage of VAR, TYPE and CONST to declare new types inside an object is allowed only inside
-% generics and classes.
+% records, objects and classes.
 parser_e_cant_create_generics_of_this_type=03225_E_Dieser Typ kann nicht "generic" sein
 % Only Classes, Objects, Interfaces and Records are allowed to be used as generic.
 parser_w_no_lineinfo_use_switch=03226_W_Die LINEINFO Unit nicht manuell laden. Verwende statt dessen den Compilerschalter -gl

+ 2 - 2
compiler/msg/errordu.msg

@@ -1117,9 +1117,9 @@ parser_e_packed_element_no_loop=03223_E_Bit packed Array-Elemente und Record-Fel
 % (or as \var{packed} in any mode with \var{\{\$bitpacking on\}}), it will
 % be packed at the bit level. For performance reasons, they cannot be
 % used as loop variables.
-parser_e_type_var_const_only_in_generics_and_classes=03224_E_VAR, TYPE und CONST sind nur innerhalb "generics" und Klassen erlaubt
+parser_e_type_var_const_only_in_records_and_classes=03224_E_VAR, TYPE und CONST sind nur innerhalb records, objects und Klassen erlaubt
 % The usage of VAR, TYPE and CONST to declare new types inside an object is allowed only inside
-% generics and classes.
+% records, objects and classes.
 parser_e_cant_create_generics_of_this_type=03225_E_Dieser Typ kann nicht "generic" sein
 % Only Classes, Objects, Interfaces and Records are allowed to be used as generic.
 parser_w_no_lineinfo_use_switch=03226_W_Die LINEINFO Unit nicht manuell laden. Verwende statt dessen den Compilerschalter -gl

+ 2 - 2
compiler/msg/errore.msg

@@ -1106,9 +1106,9 @@ parser_e_packed_element_no_loop=03223_E_Bit packed array elements and record fie
 % (or as \var{packed} in any mode with \var{\{\$bitpacking on\}}), it will
 % be packed at the bit level. For performance reasons, they cannot be
 % used as loop variables.
-parser_e_type_var_const_only_in_generics_and_classes=03224_E_VAR, TYPE and CONST are allowed only in generics and classes
+parser_e_type_var_const_only_in_records_and_classes=03224_E_VAR, TYPE and CONST are allowed only in records, objects and classes
 % The usage of VAR, TYPE and CONST to declare new types inside an object is allowed only inside
-% generics and classes.
+% records, objects and classes.
 parser_e_cant_create_generics_of_this_type=03225_E_This type can't be a generic
 % Only Classes, Objects, Interfaces and Records are allowed to be used as generic.
 parser_w_no_lineinfo_use_switch=03226_W_Don't load LINEINFO unit manually, Use the -gl compiler switch instead

+ 2 - 2
compiler/msgidx.inc

@@ -313,7 +313,7 @@ const
   parser_e_packed_element_no_var_addr=03221;
   parser_e_packed_dynamic_open_array=03222;
   parser_e_packed_element_no_loop=03223;
-  parser_e_type_var_const_only_in_generics_and_classes=03224;
+  parser_e_type_var_const_only_in_records_and_classes=03224;
   parser_e_cant_create_generics_of_this_type=03225;
   parser_w_no_lineinfo_use_switch=03226;
   parser_e_no_funcret_specified=03227;
@@ -877,7 +877,7 @@ const
   option_info=11024;
   option_help_pages=11025;
 
-  MsgTxtSize = 58270;
+  MsgTxtSize = 58278;
 
   MsgIdxMax : array[1..20] of longint=(
     24,88,304,97,82,54,111,22,202,63,

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 187 - 186
compiler/msgtxt.inc


+ 8 - 11
compiler/pdecobj.pas

@@ -618,17 +618,15 @@ implementation
           case token of
             _TYPE :
               begin
-                if (([df_generic,df_specialization]*current_structdef.defoptions)=[]) and
-                   not(current_objectdef.objecttype in [odt_class,odt_object]) then
-                  Message(parser_e_type_var_const_only_in_generics_and_classes);
-                 consume(_TYPE);
-                 object_member_blocktype:=bt_type;
+                if not(current_objectdef.objecttype in [odt_class,odt_object]) then
+                  Message(parser_e_type_var_const_only_in_records_and_classes);
+                consume(_TYPE);
+                object_member_blocktype:=bt_type;
               end;
             _VAR :
               begin
-                if (([df_generic,df_specialization]*current_structdef.defoptions)=[]) and
-                   not(current_objectdef.objecttype in [odt_class,odt_object]) then
-                  Message(parser_e_type_var_const_only_in_generics_and_classes);
+                if not(current_objectdef.objecttype in [odt_class,odt_object]) then
+                  Message(parser_e_type_var_const_only_in_records_and_classes);
                 consume(_VAR);
                 fields_allowed:=true;
                 object_member_blocktype:=bt_general;
@@ -637,9 +635,8 @@ implementation
               end;
             _CONST:
               begin
-                if (([df_generic,df_specialization]*current_structdef.defoptions)=[]) and
-                   not(current_objectdef.objecttype in [odt_class,odt_object]) then
-                  Message(parser_e_type_var_const_only_in_generics_and_classes);
+                if not(current_objectdef.objecttype in [odt_class,odt_object]) then
+                  Message(parser_e_type_var_const_only_in_records_and_classes);
                 consume(_CONST);
                 object_member_blocktype:=bt_const;
               end;

+ 5 - 11
compiler/pdecvar.pas

@@ -1428,21 +1428,15 @@ implementation
              until not try_to_consume(_COMMA);
              consume(_COLON);
 
-             { Don't search in the recordsymtable for types (can be nested!) }
+             { Don't search for types where they can't be:
+               types can be only in objects, classes and records.
+               This just speedup the search a bit. }
              recstlist.count:=0;
-             if ([df_generic,df_specialization]*tdef(recst.defowner).defoptions=[]) and
-                 not is_class_or_object(tdef(recst.defowner)) and
-                 not is_record(tdef(recst.defowner)) then
+             if not is_class_or_object(tdef(recst.defowner)) and
+                not is_record(tdef(recst.defowner)) then
                begin
                  recstlist.add(recst);
                  symtablestack.pop(recst);
-                 while (symtablestack.top.symtabletype=recordsymtable) and
-                       ([df_generic,df_specialization]*tdef(symtablestack.top.defowner).defoptions=[]) do
-                   begin
-                     recst:=tabstractrecordsymtable(symtablestack.top);
-                     recstlist.add(recst);
-                     symtablestack.pop(recst);
-                   end;
                end;
              read_anon_type(hdef,false);
              { allow only static fields reference to struct where they are declared }

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно