Browse Source

+ ttai_typedconstbuilder.emit_ord_const() helper

git-svn-id: branches/hlcgllvm@28775 -
Jonas Maebe 10 years ago
parent
commit
a0decd4a79
1 changed files with 19 additions and 0 deletions
  1. 19 0
      compiler/aasmcnst.pas

+ 19 - 0
compiler/aasmcnst.pas

@@ -230,6 +230,8 @@ type
      function emit_shortstring_const(const str: shortstring): tdef;
      function emit_shortstring_const(const str: shortstring): tdef;
      { emit a guid constant }
      { emit a guid constant }
      procedure emit_guid_const(const guid: tguid);
      procedure emit_guid_const(const guid: tguid);
+     { emit an ordinal constant }
+     procedure emit_ord_const(value: int64; def: tdef);
 
 
      { begin a potential aggregate type. Must be called for any type
      { begin a potential aggregate type. Must be called for any type
        that consists of multiple tai constant data entries, or that
        that consists of multiple tai constant data entries, or that
@@ -1051,6 +1053,23 @@ implementation
      end;
      end;
 
 
 
 
+   procedure ttai_typedconstbuilder.emit_ord_const(value: int64; def: tdef);
+     begin
+       case def.size of
+         1:
+           emit_tai(Tai_const.Create_8bit(byte(value)),def);
+         2:
+           emit_tai(Tai_const.Create_16bit(word(value)),def);
+         4:
+           emit_tai(Tai_const.Create_32bit(longint(value)),def);
+         8:
+           emit_tai(Tai_const.Create_64bit(value),def);
+         else
+           internalerror(2014100501);
+       end;
+     end;
+
+
    procedure ttai_typedconstbuilder.maybe_begin_aggregate(def: tdef);
    procedure ttai_typedconstbuilder.maybe_begin_aggregate(def: tdef);
      begin
      begin
        begin_aggregate_internal(def,false);
        begin_aggregate_internal(def,false);