浏览代码

* corrected version of r16812: code generation is still handled specially
for assigned(), but the type information is now correct so it doesn't
have to be forced to OS_ADDR anymore

git-svn-id: trunk@16819 -

Jonas Maebe 14 年之前
父节点
当前提交
04e26bfc85
共有 2 个文件被更改,包括 13 次插入6 次删除
  1. 1 3
      compiler/ncginl.pas
  2. 12 3
      compiler/ninl.pas

+ 1 - 3
compiler/ncginl.pas

@@ -640,9 +640,7 @@ implementation
     procedure tcginlinenode.second_assigned;
       begin
         secondpass(tcallparanode(left).left);
-        { force left to be an OS_ADDR, since in case of method procvars }
-        { the size is 2*OS_ADDR (JM)                                    }
-        cg.a_cmp_const_loc_label(current_asmdata.CurrAsmList,OS_ADDR,OC_NE,0,tcallparanode(left).left.location,current_procinfo.CurrTrueLabel);
+        cg.a_cmp_const_loc_label(current_asmdata.CurrAsmList,def_cgsize(left.resultdef),OC_NE,0,tcallparanode(left).left.location,current_procinfo.CurrTrueLabel);
         cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
         location_reset(location,LOC_JUMP,OS_NO);
       end;

+ 12 - 3
compiler/ninl.pas

@@ -2258,9 +2258,18 @@ implementation
                 begin
                   { the parser has already made sure the expression is valid }
 
-                  { there could be a procvar, which is 2*sizeof(pointer), while we }
-                  { must only check the first pointer -> can't just convert to an  }
-                  { add node in all cases                                          }
+                  { in case of a complex procvar, only check the "code" pointer }
+                  if (tcallparanode(left).left.resultdef.typ=procvardef) and
+                     not tprocvardef(tcallparanode(left).left.resultdef).is_addressonly then
+                    begin
+                      inserttypeconv_explicit(tcallparanode(left).left,search_system_type('TMETHOD').typedef);
+                      tcallparanode(left).left:=csubscriptnode.create(tsym(tabstractrecorddef(tcallparanode(left).left.resultdef).symtable.find('CODE')),tcallparanode(left).left);
+                      tcallparanode(left).get_paratype;
+                    end;
+
+                  { converting to an add node is tricky because of differences
+                    in procvar handling between FPC and Delphi handling, so
+                    handle specially }
                   set_varstate(tcallparanode(left).left,vs_read,[vsf_must_be_valid]);
                   resultdef:=booltype;
                 end;