浏览代码

* optimized previous patch for "byte in set" (Thorsten Engler)
* fixed storing/loading of setdefs to/from ppu + test (Thorsten Engler)
* fixed ppudump for new setdef format in ppus

git-svn-id: trunk@6363 -

Jonas Maebe 18 年之前
父节点
当前提交
f38d29cfab
共有 6 个文件被更改,包括 37 次插入21 次删除
  1. 1 0
      .gitattributes
  2. 2 2
      compiler/ncgset.pas
  3. 6 14
      compiler/symdef.pas
  4. 10 3
      compiler/utils/ppudump.pp
  5. 2 2
      compiler/x86/nx86set.pas
  6. 16 0
      tests/webtbs/tw8258a.pp

+ 1 - 0
.gitattributes

@@ -8033,6 +8033,7 @@ tests/webtbs/tw8222b.pp svneol=native#text/plain
 tests/webtbs/tw8229.pp svneol=native#text/plain
 tests/webtbs/tw8232.pp svneol=native#text/plain
 tests/webtbs/tw8258.pp svneol=native#text/plain
+tests/webtbs/tw8258a.pp svneol=native#text/plain
 tests/webtbs/tw8264.pp svneol=native#text/plain
 tests/webtbs/ub1873.pp svneol=native#text/plain
 tests/webtbs/ub1883.pp svneol=native#text/plain

+ 2 - 2
compiler/ncgset.pas

@@ -467,8 +467,8 @@ implementation
                   location.register := cg.getintregister(current_asmdata.CurrAsmList, uopsize);
 
                   if (opsize >= OS_S8) or { = if signed }
-                     ((left.resultdef.typ=orddef)  and (torddef(left.resultdef).high >= tsetdef(right.resultdef).setmax)) or
-                     ((left.resultdef.typ=enumdef) and (tenumdef(left.resultdef).max >= tsetdef(right.resultdef).setmax)) then
+                     ((left.resultdef.typ=orddef)  and (torddef(left.resultdef).high > tsetdef(right.resultdef).setmax)) or
+                     ((left.resultdef.typ=enumdef) and (tenumdef(left.resultdef).max > tsetdef(right.resultdef).setmax)) then
                     begin
                       current_asmdata.getjumplabel(l);
                       current_asmdata.getjumplabel(l2);

+ 6 - 14
compiler/symdef.pas

@@ -2036,13 +2036,9 @@ implementation
          inherited ppuload(setdef,ppufile);
          ppufile.getderef(elementdefderef);
          settype:=tsettype(ppufile.getbyte);
-         case settype of
-           normset :
-             savesize:=ppufile.getaint;
-           varset,
-           smallset :
-             savesize:=ppufile.getlongint;
-         end;
+         savesize:=ppufile.getaint;
+         setbase:=ppufile.getaint;
+         setmax:=ppufile.getaint;
       end;
 
 
@@ -2060,13 +2056,9 @@ implementation
          inherited ppuwrite(ppufile);
          ppufile.putderef(elementdefderef);
          ppufile.putbyte(byte(settype));
-         case settype of
-           varset,
-           smallset:
-             ppufile.putlongint(savesize);
-           normset:
-             ppufile.putaint(savesize);
-         end;
+         ppufile.putaint(savesize);
+         ppufile.putaint(setbase);
+         ppufile.putaint(setmax);
          ppufile.writeentry(ibsetdef);
       end;
 

+ 10 - 3
compiler/utils/ppudump.pp

@@ -1940,12 +1940,19 @@ begin
              write  (space,'     Element type : ');
              readderef;
              b:=getbyte;
+             // skip savesize
+             getaint;
              case tsettype(b) of
-               smallset : writeln(space,'  Set with 32 Elements');
-               normset  : writeln(space,'  Set with 256 Elements');
-               varset   : writeln(space,'  Set with ',getlongint,' Elements');
+               smallset : write(space,'  SmallSet');
+               normset  : write(space,'  NormalSet');
+               varset   : write(space,'  VarSet');
                else       writeln('!! Warning: Invalid set type ',b);
              end;
+             // set base
+             l:=getaint;
+             // set max
+             j:=getaint;
+             writeln(' with ',j-l,' elements');
            end;
 
          ibvariantdef :

+ 2 - 2
compiler/x86/nx86set.pas

@@ -428,8 +428,8 @@ implementation
                   location_freetemp(current_asmdata.CurrAsmList,left.location);
 
                   if (opsize >= OS_S8) or { = if signed }
-                    ((left.resultdef.typ=orddef)  and (torddef(left.resultdef).high >= tsetdef(right.resultdef).setmax)) or
-                    ((left.resultdef.typ=enumdef) and (tenumdef(left.resultdef).max >= tsetdef(right.resultdef).setmax)) then
+                    ((left.resultdef.typ=orddef)  and (torddef(left.resultdef).high > tsetdef(right.resultdef).setmax)) or
+                    ((left.resultdef.typ=enumdef) and (tenumdef(left.resultdef).max > tsetdef(right.resultdef).setmax)) then
                    begin
 
                     { we have to check if the value is < 0 or > setmax }

+ 16 - 0
tests/webtbs/tw8258a.pp

@@ -0,0 +1,16 @@
+program SetsFUBAR;
+
+uses
+  SysUtils;
+
+var
+  FCommentChars: TSysCharSet;
+  s: string;
+
+begin
+  s := '#';
+  FCommentChars := [';','#'];
+  if not (s[1] in FCommentChars) then
+    halt(1);
+end. 
+