Browse Source

* added st_default stringtype
* genstringconstnode extended with stringtype parameter using st_default
will do the old behaviour

peter 25 years ago
parent
commit
99fe175be6
6 changed files with 60 additions and 23 deletions
  1. 7 2
      compiler/cg386inl.pas
  2. 8 3
      compiler/pexpr.pas
  3. 7 2
      compiler/symconst.pas
  4. 9 4
      compiler/symdef.inc
  5. 7 2
      compiler/tccnv.pas
  6. 22 10
      compiler/tree.pas

+ 7 - 2
compiler/cg386inl.pas

@@ -915,7 +915,7 @@ implementation
                  { lineno }
                  emit_const(A_PUSH,S_L,aktfilepos.line);
                  { filename string }
-                 hp:=genstringconstnode(current_module^.sourcefiles^.get_file_name(aktfilepos.fileindex));
+                 hp:=genstringconstnode(current_module^.sourcefiles^.get_file_name(aktfilepos.fileindex),st_shortstring);
                  secondpass(hp);
                  if codegenerror then
                   exit;
@@ -1510,7 +1510,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.89  2000-01-09 12:35:00  jonas
+  Revision 1.90  2000-01-09 23:16:05  peter
+    * added st_default stringtype
+    * genstringconstnode extended with stringtype parameter using st_default
+      will do the old behaviour
+
+  Revision 1.89  2000/01/09 12:35:00  jonas
     * changed edi allocation to use getexplicitregister32/ungetregister
       (adapted tgeni386 a bit for this) and enabled it by default
     * fixed very big and stupid bug of mine in cg386mat that broke the

+ 8 - 3
compiler/pexpr.pas

@@ -496,7 +496,7 @@ unit pexpr;
               else
                begin
                  { then insert an empty string }
-                 p2:=genstringconstnode('');
+                 p2:=genstringconstnode('',st_default);
                end;
               statement_syssym:=geninlinenode(l,false,gencallparanode(p1,gencallparanode(p2,nil)));
               consume(_RKLAMMER);
@@ -1777,7 +1777,7 @@ unit pexpr;
                   p1:=gentypenode(pd,nil);
                end;
     _CSTRING : begin
-                 p1:=genstringconstnode(pattern);
+                 p1:=genstringconstnode(pattern,st_default);
                  consume(_CSTRING);
                end;
       _CCHAR : begin
@@ -2100,7 +2100,12 @@ _LECKKLAMMER : begin
 end.
 {
   $Log$
-  Revision 1.165  2000-01-07 01:14:28  peter
+  Revision 1.166  2000-01-09 23:16:05  peter
+    * added st_default stringtype
+    * genstringconstnode extended with stringtype parameter using st_default
+      will do the old behaviour
+
+  Revision 1.165  2000/01/07 01:14:28  peter
     * updated copyright to 2000
 
   Revision 1.164  1999/12/20 21:24:29  pierre

+ 7 - 2
compiler/symconst.pas

@@ -61,7 +61,7 @@ type
   );
 
   { string types }
-  tstringtype = (
+  tstringtype = (st_default,
     st_shortstring, st_longstring, st_ansistring, st_widestring
   );
 
@@ -212,7 +212,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.9  2000-01-07 01:14:39  peter
+  Revision 1.10  2000-01-09 23:16:06  peter
+    * added st_default stringtype
+    * genstringconstnode extended with stringtype parameter using st_default
+      will do the old behaviour
+
+  Revision 1.9  2000/01/07 01:14:39  peter
     * updated copyright to 2000
 
   Revision 1.8  1999/12/18 14:55:21  florian

+ 9 - 4
compiler/symdef.inc

@@ -595,7 +595,7 @@
 
     function tstringdef.stringtypname:string;
       const
-        typname:array[tstringtype] of string[8]=(
+        typname:array[tstringtype] of string[8]=('',
           'SHORTSTR','LONGSTR','ANSISTR','WIDESTR'
         );
       begin
@@ -689,8 +689,8 @@
     function tstringdef.gettypename : string;
 
       const
-         names : array[tstringtype] of string[20] =
-           ('ShortString','LongString','AnsiString','WideString');
+         names : array[tstringtype] of string[20] = ('',
+           'ShortString','LongString','AnsiString','WideString');
 
       begin
          gettypename:=names[string_typ];
@@ -3854,7 +3854,12 @@ Const local_symtable_index : longint = $8001;
 
 {
   $Log$
-  Revision 1.186  2000-01-07 01:14:39  peter
+  Revision 1.187  2000-01-09 23:16:06  peter
+    * added st_default stringtype
+    * genstringconstnode extended with stringtype parameter using st_default
+      will do the old behaviour
+
+  Revision 1.186  2000/01/07 01:14:39  peter
     * updated copyright to 2000
 
   Revision 1.185  2000/01/03 19:26:03  peter

+ 7 - 2
compiler/tccnv.pas

@@ -298,7 +298,7 @@ implementation
       begin
          if p^.left^.treetype=ordconstn then
            begin
-              hp:=genstringconstnode(chr(p^.left^.value));
+              hp:=genstringconstnode(chr(p^.left^.value),st_default);
               hp^.stringtype:=pstringdef(p^.resulttype)^.string_typ;
               firstpass(hp);
               disposetree(p);
@@ -975,7 +975,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.57  2000-01-07 01:14:44  peter
+  Revision 1.58  2000-01-09 23:16:07  peter
+    * added st_default stringtype
+    * genstringconstnode extended with stringtype parameter using st_default
+      will do the old behaviour
+
+  Revision 1.57  2000/01/07 01:14:44  peter
     * updated copyright to 2000
 
   Revision 1.56  1999/12/19 12:08:27  florian

+ 22 - 10
compiler/tree.pas

@@ -263,7 +263,7 @@ unit tree;
     function genmethodcallnode(v : pprocsym;st : psymtable;mp : ptree) : ptree;
 
     { allow pchar or string for defining a pchar node }
-    function genstringconstnode(const s : string) : ptree;
+    function genstringconstnode(const s : string;st:tstringtype) : ptree;
     { length is required for ansistrings }
     function genpcharconstnode(s : pchar;length : longint) : ptree;
     { helper routine for conststring node }
@@ -850,7 +850,7 @@ unit tree;
       end;
 
 
-    function genstringconstnode(const s : string) : ptree;
+    function genstringconstnode(const s : string;st:tstringtype) : ptree;
 
       var
          p : ptree;
@@ -873,16 +873,23 @@ unit tree;
          move(s[1],p^.value_str^,l);
          p^.value_str[l]:=#0;
          p^.lab_str:=nil;
-         if cs_ansistrings in aktlocalswitches then
+         if st=st_default then
           begin
-            p^.stringtype:=st_ansistring;
-            p^.resulttype:=cansistringdef;
+            if cs_ansistrings in aktlocalswitches then
+             p^.stringtype:=st_ansistring
+            else
+             p^.stringtype:=st_shortstring;
           end
          else
-          begin
-            p^.stringtype:=st_shortstring;
-            p^.resulttype:=cshortstringdef;
-          end;
+          p^.stringtype:=st;
+         case p^.stringtype of
+           st_shortstring :
+             p^.resulttype:=cshortstringdef;
+           st_ansistring :
+            p^.resulttype:=cansistringdef;
+           else
+             internalerror(44990099);
+         end;
          genstringconstnode:=p;
       end;
 
@@ -1911,7 +1918,12 @@ unit tree;
 end.
 {
   $Log$
-  Revision 1.108  2000-01-07 01:14:48  peter
+  Revision 1.109  2000-01-09 23:16:07  peter
+    * added st_default stringtype
+    * genstringconstnode extended with stringtype parameter using st_default
+      will do the old behaviour
+
+  Revision 1.108  2000/01/07 01:14:48  peter
     * updated copyright to 2000
 
   Revision 1.107  2000/01/06 01:10:33  pierre