瀏覽代碼

+ emit_pchar_const() helper for high level typed const builder

git-svn-id: trunk@32899 -
Jonas Maebe 9 年之前
父節點
當前提交
508038a691
共有 1 個文件被更改,包括 14 次插入0 次删除
  1. 14 0
      compiler/aasmcnst.pas

+ 14 - 0
compiler/aasmcnst.pas

@@ -331,6 +331,8 @@ type
 
      { emit a shortstring constant, and return its def }
      function emit_shortstring_const(const str: shortstring): tdef;
+     { emit a pchar string constant (the characters, not a pointer to them), and return its def }
+     function emit_pchar_const(str: pchar; len: pint): tdef;
      { emit a guid constant }
      procedure emit_guid_const(const guid: tguid);
      { emit a procdef constant }
@@ -1522,6 +1524,18 @@ implementation
      end;
 
 
+   function ttai_typedconstbuilder.emit_pchar_const(str: pchar; len: pint): tdef;
+     begin
+       result:=carraydef.getreusable(cansichartype,len+1);
+       maybe_begin_aggregate(result);
+       if len=0 then
+         emit_tai(Tai_const.Create_8bit(0),cansichartype)
+       else
+         emit_tai(Tai_string.Create_pchar(str,len+1),result);
+       maybe_end_aggregate(result);
+     end;
+
+
    procedure ttai_typedconstbuilder.emit_guid_const(const guid: tguid);
      var
        i: longint;