Jelajahi Sumber

+ array defs. of open arrays are now marked by ado_OpenArray, so (internally!) zero sized array can be declared with 0..-1

git-svn-id: trunk@48758 -
florian 4 tahun lalu
induk
melakukan
34f7c3e6d4
4 mengubah file dengan 11 tambahan dan 7 penghapusan
  1. 1 2
      compiler/defutil.pas
  2. 3 1
      compiler/symconst.pas
  3. 5 3
      compiler/symdef.pas
  4. 2 1
      compiler/utils/ppuutils/ppudump.pp

+ 1 - 2
compiler/defutil.pas

@@ -796,8 +796,7 @@ implementation
            range is also -1 ! (PFV) }
          result:=(p.typ=arraydef) and
                  (tarraydef(p).rangedef=sizesinttype) and
-                 (tarraydef(p).lowrange=0) and
-                 (tarraydef(p).highrange=-1) and
+                 (ado_OpenArray in tarraydef(p).arrayoptions) and
                  ((tarraydef(p).arrayoptions * [ado_IsVariant,ado_IsArrayOfConst,ado_IsConstructor,ado_IsDynamicArray])=[]);
       end;
 

+ 3 - 1
compiler/symconst.pas

@@ -572,7 +572,9 @@ type
     ado_IsConstString,      // string constant
     ado_IsBitPacked,        // bitpacked array
     ado_IsVector,           // Vector
-    ado_IsGeneric           // the index of the array is generic (meaning that the size is not yet known)
+    ado_IsGeneric,          // the index of the array is generic (meaning that the size is not yet known)
+    ado_OpenArray           // open array, replaces the old hack with high being -1 for an open array:
+                            // this is still true, but this flag is set as well
   );
   tarraydefoptions=set of tarraydefoption;
 

+ 5 - 3
compiler/symdef.pas

@@ -4154,6 +4154,7 @@ implementation
          symtable:=tarraysymtable.create(self);
       end;
 
+
     constructor tarraydef.create_vector(l ,h: asizeint; def: tdef);
       begin
         self.create(l,h,def);
@@ -4163,7 +4164,8 @@ implementation
 
     constructor tarraydef.create_openarray;
       begin
-        self.create(0,-1,sizesinttype)
+        self.create(0,-1,sizesinttype);
+        include(arrayoptions,ado_OpenArray);
       end;
 
 
@@ -4367,7 +4369,7 @@ implementation
           end;
 
         { Tarraydef.size may never be called for an open array! }
-        if (highrange=-1) and (lowrange=0) then
+        if ado_OpenArray in arrayoptions then
           internalerror(99080501);
         if not (ado_IsBitPacked in arrayoptions) then
           cachedelesize:=elesize
@@ -4472,7 +4474,7 @@ implementation
            end
          else if (ado_IsDynamicArray in arrayoptions) then
            GetTypeName:='{Dynamic} Array Of '+elementdef.typename
-         else if ((highrange=-1) and (lowrange=0)) then
+         else if (ado_OpenArray in arrayoptions) then
            GetTypeName:='{Open} Array Of '+elementdef.typename
          else
            begin

+ 2 - 1
compiler/utils/ppuutils/ppudump.pp

@@ -3284,7 +3284,8 @@ const
    { ado_IsConstString      } 'ConstString',
    { ado_IsBitPacked        } 'BitPacked',
    { ado_IsVector           } 'Vector',
-   { ado_IsGeneric          } 'Generic'
+   { ado_IsGeneric          } 'Generic',
+   { ado_OpenArray          } 'OpenArray'
   );
 var
   symoptions: tarraydefoptions;