瀏覽代碼

* moved the tai_*typedconst classes to aasmcnst to make use of def-related
helpers in a cleaner way (defutils would not belong in the uses clause of
aasmtai)

git-svn-id: branches/hlcgllvm@28132 -

Jonas Maebe 11 年之前
父節點
當前提交
9f39188253
共有 3 個文件被更改,包括 146 次插入145 次删除
  1. 145 0
      compiler/aasmcnst.pas
  2. 0 144
      compiler/aasmtai.pas
  3. 1 1
      compiler/llvm/agllvm.pas

+ 145 - 0
compiler/aasmcnst.pas

@@ -32,6 +32,61 @@ uses
   symtype,symdef,symsym;
 
 type
+   { typed const: integer/floating point/string/pointer/... const along with
+     tdef info; tck_simple_procvar2proc is to indicate that we mean the
+     procdef corresponding to the procvar rather than the tmethod-like
+     struct in case of a complex procvar }
+   ttypedconstkind = (tck_simple, tck_simple_procvar2proc, tck_array, tck_record);
+
+   { the type of the element and its def }
+   tai_abstracttypedconst = class abstract (tai)
+    protected
+     fadetyp: ttypedconstkind;
+     { the def of this element }
+     fdef: tdef;
+    public
+     constructor create(_adetyp: ttypedconstkind; _def: tdef);
+     property adetyp: ttypedconstkind read fadetyp;
+     property def: tdef read fdef;
+   end;
+
+   { a simple data element; the value is stored as a tai }
+   tai_simpletypedconst = class(tai_abstracttypedconst)
+    protected
+     fval: tai;
+    public
+     constructor create(_adetyp: ttypedconstkind; _def: tdef; _val: tai);
+     property val: tai read fval;
+   end;
+
+
+   { an aggregate data element (record or array). Values are stored as an
+     array of tsimpledataelement. }
+   tai_aggregatetypedconst = class(tai_abstracttypedconst)
+    public type
+     { iterator to walk over all individual items in the aggregate }
+     tadeenumerator = class(tobject)
+      private
+       fvalues: tfplist;
+       fvaluespos: longint;
+       function getcurrent: tai_abstracttypedconst;
+      public
+       constructor create(data: tai_aggregatetypedconst);
+       function movenext: boolean;
+       procedure reset;
+       property current: tai_abstracttypedconst read getcurrent;
+     end;
+
+    protected
+     fvalues: tfplist;
+    public
+     constructor create(_adetyp: ttypedconstkind; _fdef: tdef);
+     function getenumerator: tadeenumerator;
+     procedure addvalue(val: tai_abstracttypedconst);
+     destructor destroy; override;
+   end;
+
+
    { Warning: never directly create a ttai_typedconstbuilder instance,
      instead create a cai_typedconstbuilder (this class can be overridden) }
    ttai_lowleveltypedconstbuilder = class abstract
@@ -122,6 +177,96 @@ implementation
      verbose,globals,
      symconst,defutil;
 
+
+{****************************************************************************
+                            tai_abstracttypedconst
+ ****************************************************************************}
+
+   constructor tai_abstracttypedconst.create(_adetyp: ttypedconstkind; _def: tdef);
+     begin
+       inherited create;
+       typ:=ait_typedconst;
+       fadetyp:=_adetyp;
+       fdef:=_def;
+     end;
+
+
+{****************************************************************************
+                                tai_simpletypedconst
+ ****************************************************************************}
+
+   constructor tai_simpletypedconst.create(_adetyp: ttypedconstkind; _def: tdef; _val: tai);
+     begin
+       inherited create(_adetyp,_def);
+       fval:=_val;
+     end;
+
+
+{****************************************************************************
+              tai_aggregatetypedconst.tadeenumerator
+ ****************************************************************************}
+
+   constructor tai_aggregatetypedconst.tadeenumerator.create(data: tai_aggregatetypedconst);
+     begin
+       fvalues:=data.fvalues;
+       fvaluespos:=-1;
+     end;
+
+
+   function tai_aggregatetypedconst.tadeenumerator.getcurrent: tai_abstracttypedconst;
+     begin
+       result:=tai_abstracttypedconst(fvalues[fvaluespos]);
+     end;
+
+
+   function tai_aggregatetypedconst.tadeenumerator.movenext: boolean;
+     begin
+       if fvaluespos<pred(fvalues.count) then
+         begin
+           inc(fvaluespos);
+           result:=true
+         end
+       else
+         result:=false;
+     end;
+
+
+   procedure tai_aggregatetypedconst.tadeenumerator.reset;
+     begin
+       fvaluespos:=0
+     end;
+
+
+{****************************************************************************
+                            tai_aggregatetypedconst
+ ****************************************************************************}
+
+   constructor tai_aggregatetypedconst.create(_adetyp: ttypedconstkind; _fdef: tdef);
+     begin
+       inherited;
+       fvalues:=tfplist.create;
+     end;
+
+
+   function tai_aggregatetypedconst.getenumerator: tadeenumerator;
+     begin
+       result:=tadeenumerator.create(self);
+     end;
+
+
+   procedure tai_aggregatetypedconst.addvalue(val: tai_abstracttypedconst);
+     begin
+       fvalues.add(val);
+     end;
+
+
+   destructor tai_aggregatetypedconst.destroy;
+     begin
+       fvalues.free;
+       inherited destroy;
+     end;
+
+
  {*****************************************************************************
                               ttai_lowleveltypedconstbuilder
  *****************************************************************************}

+ 0 - 144
compiler/aasmtai.pas

@@ -662,61 +662,6 @@ interface
           function datasize: word;
        end;
 
-       { typed const: integer/floating point/string/pointer/... const along with
-         tdef info; tck_simple_procvar2proc is to indicate that we mean the
-         procdef corresponding to the procvar rather than the tmethod-like
-         struct in case of a complex procvar }
-       ttypedconstkind = (tck_simple, tck_simple_procvar2proc, tck_array, tck_record);
-
-       { the type of the element and its def }
-       tai_abstracttypedconst = class abstract (tai)
-        protected
-         fadetyp: ttypedconstkind;
-         { the def of this element }
-         fdef: tdef;
-        public
-         constructor create(_adetyp: ttypedconstkind; _def: tdef);
-         property adetyp: ttypedconstkind read fadetyp;
-         property def: tdef read fdef;
-       end;
-
-       { a simple data element; the value is stored as a tai }
-       tai_simpletypedconst = class(tai_abstracttypedconst)
-        protected
-         fval: tai;
-        public
-         constructor create(_adetyp: ttypedconstkind; _def: tdef; _val: tai);
-         property val: tai read fval;
-       end;
-
-
-       { an aggregate data element (record or array). Values are stored as an
-         array of tsimpledataelement. }
-       tai_aggregatetypedconst = class(tai_abstracttypedconst)
-        public type
-         { iterator to walk over all individual items in the aggregate }
-         tadeenumerator = class(tobject)
-          private
-           fvalues: tfplist;
-           fvaluespos: longint;
-           function getcurrent: tai_abstracttypedconst;
-          public
-           constructor create(data: tai_aggregatetypedconst);
-           function movenext: boolean;
-           procedure reset;
-           property current: tai_abstracttypedconst read getcurrent;
-         end;
-
-        protected
-         fvalues: tfplist;
-        public
-         constructor create(_adetyp: ttypedconstkind; _fdef: tdef);
-         function getenumerator: tadeenumerator;
-         procedure addvalue(val: tai_abstracttypedconst);
-         destructor destroy; override;
-       end;
-
-
        { tai_stab }
 
        tai_stab = class(tai)
@@ -2076,95 +2021,6 @@ implementation
       end;
 
 
-{****************************************************************************
-                             tai_abstracttypedconst
- ****************************************************************************}
-
-    constructor tai_abstracttypedconst.create(_adetyp: ttypedconstkind; _def: tdef);
-      begin
-        inherited create;
-        typ:=ait_typedconst;
-        fadetyp:=_adetyp;
-        fdef:=_def;
-      end;
-
-
-    {****************************************************************************
-                                 tai_simpletypedconst
-     ****************************************************************************}
-
-    constructor tai_simpletypedconst.create(_adetyp: ttypedconstkind; _def: tdef; _val: tai);
-      begin
-        inherited create(_adetyp,_def);
-        fval:=_val;
-      end;
-
-
-    {****************************************************************************
-               tai_aggregatetypedconst.tadeenumerator
-     ****************************************************************************}
-
-    constructor tai_aggregatetypedconst.tadeenumerator.create(data: tai_aggregatetypedconst);
-      begin
-        fvalues:=data.fvalues;
-        fvaluespos:=-1;
-      end;
-
-
-    function tai_aggregatetypedconst.tadeenumerator.getcurrent: tai_abstracttypedconst;
-      begin
-        result:=tai_abstracttypedconst(fvalues[fvaluespos]);
-      end;
-
-
-    function tai_aggregatetypedconst.tadeenumerator.movenext: boolean;
-      begin
-        if fvaluespos<pred(fvalues.count) then
-          begin
-            inc(fvaluespos);
-            result:=true
-          end
-        else
-          result:=false;
-      end;
-
-
-    procedure tai_aggregatetypedconst.tadeenumerator.reset;
-      begin
-        fvaluespos:=0
-      end;
-
-
-{****************************************************************************
-                             tai_aggregatetypedconst
- ****************************************************************************}
-
-    constructor tai_aggregatetypedconst.create(_adetyp: ttypedconstkind; _fdef: tdef);
-      begin
-        inherited;
-        fvalues:=tfplist.create;
-      end;
-
-
-    function tai_aggregatetypedconst.getenumerator: tadeenumerator;
-      begin
-        result:=tadeenumerator.create(self);
-      end;
-
-
-    procedure tai_aggregatetypedconst.addvalue(val: tai_abstracttypedconst);
-      begin
-        fvalues.add(val);
-      end;
-
-
-    destructor tai_aggregatetypedconst.destroy;
-      begin
-        fvalues.free;
-        inherited destroy;
-      end;
-
-
 {****************************************************************************
                                TAI_STRING
  ****************************************************************************}

+ 1 - 1
compiler/llvm/agllvm.pas

@@ -83,7 +83,7 @@ implementation
       SysUtils,
       cutils,cfileutl,systems,
       fmodule,verbose,
-      symconst,symdef,
+      aasmcnst,symconst,symdef,
       llvmbase,aasmllvm,itllvm,llvmdef,
       cgbase,cgutils,cpubase;