Browse Source

+ arrayvar[l..h] now valid parameter for open array.

git-svn-id: trunk@5064 -
daniel 19 years ago
parent
commit
67851f6aba
2 changed files with 19 additions and 10 deletions
  1. 4 1
      compiler/nmem.pas
  2. 15 9
      compiler/pexpr.pas

+ 4 - 1
compiler/nmem.pas

@@ -718,7 +718,10 @@ implementation
                { check type of the index value }
                if (compare_defs(right.resulttype.def,tarraydef(left.resulttype.def).rangetype.def,right.nodetype)=te_incompatible) then
                  IncompatibleTypes(right.resulttype.def,tarraydef(left.resulttype.def).rangetype.def);
-               resulttype:=tarraydef(left.resulttype.def).elementtype;
+               if right.nodetype=rangen then
+                 resulttype:=left.resulttype
+               else
+                 resulttype:=Tarraydef(left.resulttype.def).elementtype;
              end;
            pointerdef :
              begin

+ 15 - 9
compiler/pexpr.pas

@@ -1907,7 +1907,7 @@ implementation
                                 if ok then
                                   begin
                                     p2:=comp_expr(true);
-                                  { support SEG:OFS for go32v2 Mem[] }
+                                    { support SEG:OFS for go32v2 Mem[] }
                                     if (target_info.system in [system_i386_go32v2,system_i386_watcom]) and
                                        (p1.nodetype=loadn) and
                                        assigned(tloadnode(p1).symtableentry) and
@@ -1922,18 +1922,29 @@ implementation
                                            p3:=caddnode.create(muln,cordconstnode.create($10,s32inttype,false),p2);
                                            p2:=comp_expr(true);
                                            p2:=caddnode.create(addn,p2,p3);
+                                           if try_to_consume(_POINTPOINT) then
+                                             { Support mem[$a000:$0000..$07ff] which returns array [0..$7ff] of memtype.}
+                                             p2:=crangenode.create(p2,caddnode.create(addn,comp_expr(true),p3.getcopy));
                                            p1:=cvecnode.create(p1,p2);
                                            include(tvecnode(p1).flags,nf_memseg);
                                            include(tvecnode(p1).flags,nf_memindex);
                                          end
                                         else
                                          begin
+                                           if try_to_consume(_POINTPOINT) then
+                                             { Support mem[$80000000..$80000002] which returns array [0..2] of memtype.}
+                                             p2:=crangenode.create(p2,comp_expr(true));
                                            p1:=cvecnode.create(p1,p2);
                                            include(tvecnode(p1).flags,nf_memindex);
                                          end;
                                       end
                                     else
-                                      p1:=cvecnode.create(p1,p2);
+                                      begin
+                                        if try_to_consume(_POINTPOINT) then
+                                          { Support arrayvar[0..9] which returns array [0..9] of arraytype.}
+                                          p2:=crangenode.create(p2,comp_expr(true));
+                                        p1:=cvecnode.create(p1,p2);
+                                      end;
                                   end;
                               end;
                             else
@@ -1986,13 +1997,8 @@ implementation
                            consume(_ID);
                          end;
                        variantdef:
-                         begin
-                           { dispatch call }
-                           if token=_ID then
-                             begin
-                               consume(_ID);
-                             end;
-                         end;
+                         { dispatch call }
+                         try_to_consume(_ID);
                        classrefdef:
                          begin
                            if token=_ID then