Browse Source

+ tcallnode.createinternmethod() constructor to easily call methods
(both instance and class/static methods)

git-svn-id: branches/jvmbackend@18661 -

Jonas Maebe 14 years ago
parent
commit
9ebf623895
1 changed files with 19 additions and 0 deletions
  1. 19 0
      compiler/ncal.pas

+ 19 - 0
compiler/ncal.pas

@@ -132,6 +132,7 @@ interface
           constructor createinternres(const name: string; params: tnode; res:tdef);
           constructor createinternresfromunit(const fromunit, procname: string; params: tnode; res:tdef);
           constructor createinternreturn(const name: string; params: tnode; returnnode : tnode);
+          constructor createinternmethod(mp: tnode; const name: string; params: tnode);
           destructor destroy;override;
           constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
           procedure ppuwrite(ppufile:tcompilerppufile);override;
@@ -1118,6 +1119,24 @@ implementation
       end;
 
 
+    constructor tcallnode.createinternmethod(mp: tnode; const name: string; params: tnode);
+      var
+        ps: tsym;
+        recdef: tabstractrecorddef;
+      begin
+        typecheckpass(mp);
+        if mp.resultdef.typ=classrefdef then
+          recdef:=tabstractrecorddef(tclassrefdef(mp.resultdef).pointeddef)
+        else
+          recdef:=tabstractrecorddef(mp.resultdef);
+        ps:=search_struct_member(recdef,name);
+        if not assigned(ps) or
+           (ps.typ<>procsym) then
+          internalerror(2011062806);
+        create(params,tprocsym(ps),ps.owner,mp,[]);
+      end;
+
+
     destructor tcallnode.destroy;
       begin
          methodpointer.free;