瀏覽代碼

* add "doregister" parameter to tstringdef.create*, and don't register
temporary defs created in the scanner for evaluating compile time
expressions

git-svn-id: trunk@32047 -

Jonas Maebe 9 年之前
父節點
當前提交
e921d7847a
共有 4 個文件被更改,包括 26 次插入26 次删除
  1. 2 2
      compiler/pexpr.pas
  2. 7 7
      compiler/psystem.pas
  3. 1 1
      compiler/scanner.pas
  4. 16 16
      compiler/symdef.pas

+ 2 - 2
compiler/pexpr.pas

@@ -116,11 +116,11 @@ implementation
 {                    t:=cstringdef.createlong(tordconstnode(p).value))}
 {                    t:=cstringdef.createlong(tordconstnode(p).value))}
                     Message(parser_e_invalid_string_size);
                     Message(parser_e_invalid_string_size);
                     tordconstnode(p).value:=255;
                     tordconstnode(p).value:=255;
-                    def:=cstringdef.createshort(int64(tordconstnode(p).value));
+                    def:=cstringdef.createshort(int64(tordconstnode(p).value),true);
                   end
                   end
                 else
                 else
                   if tordconstnode(p).value<>255 then
                   if tordconstnode(p).value<>255 then
-                    def:=cstringdef.createshort(int64(tordconstnode(p).value));
+                    def:=cstringdef.createshort(int64(tordconstnode(p).value),true);
                 consume(_RECKKLAMMER);
                 consume(_RECKKLAMMER);
               end;
               end;
              p.free;
              p.free;

+ 7 - 7
compiler/psystem.pas

@@ -225,17 +225,17 @@ implementation
         bool64type:=corddef.create(bool64bit,low(int64),high(int64),true);
         bool64type:=corddef.create(bool64bit,low(int64),high(int64),true);
         cansichartype:=corddef.create(uchar,0,255,true);
         cansichartype:=corddef.create(uchar,0,255,true);
         cwidechartype:=corddef.create(uwidechar,0,65535,true);
         cwidechartype:=corddef.create(uwidechar,0,65535,true);
-        cshortstringtype:=cstringdef.createshort(255);
+        cshortstringtype:=cstringdef.createshort(255,true);
         { should we give a length to the default long and ansi string definition ?? }
         { should we give a length to the default long and ansi string definition ?? }
-        clongstringtype:=cstringdef.createlong(-1);
-        cansistringtype:=cstringdef.createansi(0);
+        clongstringtype:=cstringdef.createlong(-1,true);
+        cansistringtype:=cstringdef.createansi(0,true);
         if target_info.system in systems_windows then
         if target_info.system in systems_windows then
-          cwidestringtype:=cstringdef.createwide
+          cwidestringtype:=cstringdef.createwide(true)
         else
         else
-          cwidestringtype:=cstringdef.createunicode;
-        cunicodestringtype:=cstringdef.createunicode;
+          cwidestringtype:=cstringdef.createunicode(true);
+        cunicodestringtype:=cstringdef.createunicode(true);
         { length=0 for shortstring is open string (needed for readln(string) }
         { length=0 for shortstring is open string (needed for readln(string) }
-        openshortstringtype:=cstringdef.createshort(0);
+        openshortstringtype:=cstringdef.createshort(0,true);
 {$ifdef x86}
 {$ifdef x86}
         create_fpu_types;
         create_fpu_types;
 {$ifndef FPC_SUPPORT_X87_TYPES_ON_WIN64}
 {$ifndef FPC_SUPPORT_X87_TYPES_ON_WIN64}

+ 1 - 1
compiler/scanner.pas

@@ -921,7 +921,7 @@ type
       sintdef:=torddef.create(s64bit,low(int64),high(int64),false);
       sintdef:=torddef.create(s64bit,low(int64),high(int64),false);
       uintdef:=torddef.create(u64bit,low(qword),high(qword),false);
       uintdef:=torddef.create(u64bit,low(qword),high(qword),false);
       booldef:=torddef.create(pasbool8,0,1,false);
       booldef:=torddef.create(pasbool8,0,1,false);
-      strdef:=tstringdef.createansi(0);
+      strdef:=tstringdef.createansi(0,false);
       setdef:=tsetdef.create(sintdef,0,255);
       setdef:=tsetdef.create(sintdef,0,255);
       realdef:=tfloatdef.create(s80real);
       realdef:=tfloatdef.create(s80real);
     end;
     end;

+ 16 - 16
compiler/symdef.pas

@@ -832,15 +832,15 @@ interface
           encoding   : tstringencoding;
           encoding   : tstringencoding;
           stringtype : tstringtype;
           stringtype : tstringtype;
           len        : asizeint;
           len        : asizeint;
-          constructor createshort(l : byte);virtual;
+          constructor createshort(l: byte; doregister: boolean);virtual;
           constructor loadshort(ppufile:tcompilerppufile);
           constructor loadshort(ppufile:tcompilerppufile);
-          constructor createlong(l : asizeint);virtual;
+          constructor createlong(l: asizeint; doregister: boolean);virtual;
           constructor loadlong(ppufile:tcompilerppufile);
           constructor loadlong(ppufile:tcompilerppufile);
-          constructor createansi(aencoding:tstringencoding);virtual;
+          constructor createansi(aencoding: tstringencoding; doregister: boolean);virtual;
           constructor loadansi(ppufile:tcompilerppufile);
           constructor loadansi(ppufile:tcompilerppufile);
-          constructor createwide;virtual;
+          constructor createwide(doregister: boolean);virtual;
           constructor loadwide(ppufile:tcompilerppufile);
           constructor loadwide(ppufile:tcompilerppufile);
-          constructor createunicode;virtual;
+          constructor createunicode(doregister: boolean);virtual;
           constructor loadunicode(ppufile:tcompilerppufile);virtual;
           constructor loadunicode(ppufile:tcompilerppufile);virtual;
           function getcopy : tstoreddef;override;
           function getcopy : tstoreddef;override;
           function  stringtypname:string;
           function  stringtypname:string;
@@ -1194,7 +1194,7 @@ implementation
                 else
                 else
                   symtable:=current_module.localsymtable;
                   symtable:=current_module.localsymtable;
                 symtablestack.push(symtable);
                 symtablestack.push(symtable);
-                current_module.ansistrdef:=cstringdef.createansi(current_settings.sourcecodepage);
+                current_module.ansistrdef:=cstringdef.createansi(current_settings.sourcecodepage,true);
                 symtablestack.pop(symtable);
                 symtablestack.pop(symtable);
               end;
               end;
             result:=tstringdef(current_module.ansistrdef);
             result:=tstringdef(current_module.ansistrdef);
@@ -2168,9 +2168,9 @@ implementation
                                Tstringdef
                                Tstringdef
 ****************************************************************************}
 ****************************************************************************}
 
 
-    constructor tstringdef.createshort(l : byte);
+    constructor tstringdef.createshort(l: byte; doregister: boolean);
       begin
       begin
-         inherited create(stringdef,true);
+         inherited create(stringdef,doregister);
          stringtype:=st_shortstring;
          stringtype:=st_shortstring;
          encoding:=0;
          encoding:=0;
          len:=l;
          len:=l;
@@ -2187,9 +2187,9 @@ implementation
       end;
       end;
 
 
 
 
-    constructor tstringdef.createlong(l : asizeint);
+    constructor tstringdef.createlong(l: asizeint; doregister: boolean);
       begin
       begin
-         inherited create(stringdef,true);
+         inherited create(stringdef,doregister);
          stringtype:=st_longstring;
          stringtype:=st_longstring;
          encoding:=0;
          encoding:=0;
          len:=l;
          len:=l;
@@ -2206,9 +2206,9 @@ implementation
       end;
       end;
 
 
 
 
-    constructor tstringdef.createansi(aencoding:tstringencoding);
+    constructor tstringdef.createansi(aencoding: tstringencoding; doregister: boolean);
       begin
       begin
-         inherited create(stringdef,true);
+         inherited create(stringdef,doregister);
          stringtype:=st_ansistring;
          stringtype:=st_ansistring;
          encoding:=aencoding;
          encoding:=aencoding;
          len:=-1;
          len:=-1;
@@ -2225,9 +2225,9 @@ implementation
       end;
       end;
 
 
 
 
-    constructor tstringdef.createwide;
+    constructor tstringdef.createwide(doregister: boolean);
       begin
       begin
-         inherited create(stringdef,true);
+         inherited create(stringdef,doregister);
          stringtype:=st_widestring;
          stringtype:=st_widestring;
          if target_info.endian=endian_little then
          if target_info.endian=endian_little then
            encoding:=CP_UTF16LE
            encoding:=CP_UTF16LE
@@ -2250,9 +2250,9 @@ implementation
       end;
       end;
 
 
 
 
-    constructor tstringdef.createunicode;
+    constructor tstringdef.createunicode(doregister: boolean);
       begin
       begin
-         inherited create(stringdef,true);
+         inherited create(stringdef,doregister);
          stringtype:=st_unicodestring;
          stringtype:=st_unicodestring;
          if target_info.endian=endian_little then
          if target_info.endian=endian_little then
            encoding:=CP_UTF16LE
            encoding:=CP_UTF16LE