~ubuntu-branches/ubuntu/feisty/fpc/feisty

« back to all changes in this revision

Viewing changes to compiler/nmem.pas

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2007-01-27 20:08:50 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070127200850-9mrptaqqjsx9nwa7
Tags: 2.0.4-5
* Fixed Build-Depends.
* Add myself to Uploaders in debian/control.
* Make sure that the sources are really patched before building them.
* Build unit 'libc' on powerpc too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
{
2
 
    $Id: nmem.pas,v 1.96 2005/04/06 19:39:04 florian Exp $
3
2
    Copyright (c) 2000-2002 by Florian Klaempfl
4
3
 
5
4
    Type checking and register allocation for memory related nodes
230
229
 
231
230
 
232
231
    function tloadparentfpnode.det_resulttype:tnode;
 
232
{$ifdef dummy}
233
233
      var
234
234
        currpi : tprocinfo;
235
235
        hsym   : tparavarsym;
 
236
{$endif dummy}
236
237
      begin
237
238
        result:=nil;
238
239
        resulttype:=voidpointertype;
239
 
        {
240
 
          currently parentfps are never loaded in registers (FK)
 
240
{$ifdef dummy}
 
241
        { currently parentfps are never loaded in registers (FK) }
241
242
 
242
243
        if (current_procinfo.procdef.parast.symtablelevel<>parentpd.parast.symtablelevel) then
243
244
          begin
254
255
                hsym.varregable:=vr_none;
255
256
              end;
256
257
          end;
257
 
        }
 
258
{$endif dummy}
258
259
      end;
259
260
 
260
261
 
355
356
        { Handle @proc special, also @procvar in tp-mode needs
356
357
          special handling }
357
358
        if (left.resulttype.def.deftype=procdef) or
358
 
           ((left.resulttype.def.deftype=procvardef) and
359
 
            (m_tp_procvar in aktmodeswitches)) then
 
359
           (
 
360
            (left.resulttype.def.deftype=procvardef) and
 
361
            ((m_tp_procvar in aktmodeswitches) or
 
362
             (m_mac_procvar in aktmodeswitches))
 
363
           ) then
360
364
          begin
361
365
            isprocvar:=(left.resulttype.def.deftype=procvardef);
362
366
 
369
373
            { In tp procvar mode the result is always a voidpointer. Insert
370
374
              a typeconversion to voidpointer. For methodpointers we need
371
375
              to load the proc field }
372
 
            if (m_tp_procvar in aktmodeswitches) then
 
376
            if (m_tp_procvar in aktmodeswitches) or
 
377
               (m_mac_procvar in aktmodeswitches) then
373
378
              begin
374
379
                if tabstractprocdef(left.resulttype.def).is_addressonly then
375
380
                  begin
425
430
            else
426
431
{$endif i386}
427
432
              if (nf_internal in flags) or
428
 
                 valid_for_addr(left) then
 
433
                 valid_for_addr(left,true) then
429
434
                begin
430
435
                  if not(nf_typedaddr in flags) then
431
436
                    resulttype:=voidpointertype
438
443
 
439
444
         { this is like the function addr }
440
445
         inc(parsing_para_level);
441
 
         set_varstate(left,vs_used,[]);
 
446
         { This is actually only "read", but treat it nevertheless as  }
 
447
         { modified due to the possible use of pointers                }
 
448
         { To avoid false positives regarding "uninitialised"          }
 
449
         { warnings when using arrays, perform it in two steps         }
 
450
         set_varstate(left,vs_written,[]);
 
451
         set_varstate(left,vs_read,[]);
442
452
         dec(parsing_para_level);
443
453
      end;
444
454
 
450
460
         if codegenerror then
451
461
          exit;
452
462
 
453
 
         { we should allow loc_mem for @string }
454
 
         if not(left.expectloc in [LOC_CREFERENCE,LOC_REFERENCE]) then
455
 
           begin
456
 
             aktfilepos:=left.fileinfo;
457
 
             CGMessage(parser_e_illegal_expression);
458
 
           end;
459
 
 
460
463
         registersint:=left.registersint;
461
464
         registersfpu:=left.registersfpu;
462
465
{$ifdef SUPPORT_MMX}
484
487
      begin
485
488
         result:=nil;
486
489
         resulttypepass(left);
487
 
         set_varstate(left,vs_used,[vsf_must_be_valid]);
 
490
         set_varstate(left,vs_read,[vsf_must_be_valid]);
488
491
         if codegenerror then
489
492
          exit;
490
493
 
642
645
         result:=nil;
643
646
         resulttypepass(left);
644
647
         resulttypepass(right);
 
648
 
645
649
         { In p[1] p is always valid, it is not possible to
646
650
           declared a shortstring or normal array that has
647
651
           undefined number of elements. Dynamic array and
648
652
           ansi/widestring needs to be valid }
649
653
         valid:=is_dynamic_array(left.resulttype.def) or
650
654
                is_ansistring(left.resulttype.def) or
651
 
                is_widestring(left.resulttype.def);
 
655
                is_widestring(left.resulttype.def) or
 
656
                { implicit pointer dereference -> pointer is read }
 
657
                (left.resulttype.def.deftype = pointerdef);
652
658
         if valid then
653
 
           set_varstate(left,vs_used,[vsf_must_be_valid])
654
 
         else
655
 
           set_varstate(left,vs_used,[]);
656
 
         set_varstate(right,vs_used,[vsf_must_be_valid]);
 
659
           set_varstate(left,vs_read,[vsf_must_be_valid]);
 
660
{
 
661
         A vecn is, just like a loadn, always part of an expression with its
 
662
         own read/write and must_be_valid semantics. Therefore we don't have
 
663
         to do anything else here, just like for loadn's
 
664
}
 
665
         set_varstate(right,vs_read,[vsf_must_be_valid]);
657
666
         if codegenerror then
658
667
          exit;
659
668
 
660
669
         { maybe type conversion for the index value, but
661
670
           do not convert enums,booleans,char }
662
 
         if (right.resulttype.def.deftype<>enumdef) and
663
 
            not(is_char(right.resulttype.def)) and
664
 
            not(is_boolean(right.resulttype.def)) then
 
671
         if ((right.resulttype.def.deftype<>enumdef) and
 
672
             not(is_char(right.resulttype.def) or is_widechar(right.resulttype.def)) and
 
673
             not(is_boolean(right.resulttype.def))) or
 
674
            (left.resulttype.def.deftype <> arraydef) then
665
675
           begin
666
 
             inserttypeconv(right,s32inttype);
 
676
             inserttypeconv(right,sinttype);
667
677
           end;
668
678
 
669
679
         case left.resulttype.def.deftype of
894
904
        resulttype:=voidtype;
895
905
 
896
906
        resulttypepass(withrefnode);
897
 
        set_varstate(withrefnode,vs_used,[vsf_must_be_valid]);
 
907
        set_varstate(withrefnode,vs_read,[vsf_must_be_valid]);
898
908
        if codegenerror then
899
909
         exit;
900
910
 
904
914
 
905
915
        if assigned(left) then
906
916
          resulttypepass(left);
 
917
 
 
918
        { disable inline }
 
919
        exclude(current_procinfo.procdef.procoptions,po_inline);
907
920
      end;
908
921
 
909
922
 
953
966
  cvecnode := tvecnode;
954
967
  cwithnode := twithnode;
955
968
end.
956
 
{
957
 
  $Log: nmem.pas,v $
958
 
  Revision 1.96  2005/04/06 19:39:04  florian
959
 
    * fixed previous commit
960
 
 
961
 
  Revision 1.95  2005/03/25 22:20:19  peter
962
 
    * add hint when passing an uninitialized variable to a var parameter
963
 
 
964
 
  Revision 1.94  2005/02/14 17:13:06  peter
965
 
    * truncate log
966
 
 
967
 
}