Browse Source

+ tai_aggregatetypedconst.changetorecord() to change the type of an
aggregate to a (new) recorddef
o the size of the original type and that of the record must match
o will be used by the LLVM generator in case of a variant record, or
an array of variant records with constant data that does not match
our canonical LLVM definition

git-svn-id: trunk@32718 -

Jonas Maebe 9 years ago
parent
commit
926e62c886
1 changed files with 14 additions and 0 deletions
  1. 14 0
      compiler/aasmcnst.pas

+ 14 - 0
compiler/aasmcnst.pas

@@ -93,6 +93,9 @@ type
      function valuecount: longint;
      procedure insertvaluebeforepos(val: tai_abstracttypedconst; pos: longint);
      function replacevalueatpos(val: tai_abstracttypedconst; pos: longint): tai_abstracttypedconst;
+     { change the type to a record, regardless of how the aggregate was created;
+       the size of the original type and the record must match }
+     procedure changetorecord(_def: trecorddef);
      procedure finish;
      destructor destroy; override;
    end;
@@ -747,6 +750,17 @@ implementation
      end;
 
 
+   procedure tai_aggregatetypedconst.changetorecord(_def: trecorddef);
+     begin
+       { must be a record of the same size as the current data }
+       if assigned(fdef) and
+          (fdef.size<>_def.size) then
+         internalerror(2015122402);
+       fdef:=_def;
+       fadetyp:=tck_record;
+     end;
+
+
    procedure tai_aggregatetypedconst.finish;
      begin
        if fisstring then