This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: method invocation and parameter access



Dachuan Yu writes:

> Would someone please tell me where the code is in
> GCJ that builds tree nodes of method invocations?

When it builds from sources, it's in parse.y:build_method_invocation.
It takes EXPR_WITH_FILE_LOCATION as arguments to describe in a symbolic
way what the arguments are.

The CALL_EXPR tree will eventually be completed and the invocation
mechanism is installed in build_invokevirtual, build_known_method_ref
and build_invokeinterface. When you build from bytecode, expand_invoke
sorts things out according to the environment and/or the instruction's
opcode and eventually call the same functions.

> I'm looking at the "......build(CALL_EXPR....." in
> the "patch_invoke" function in file
> ".../gcc/java/parse.c". Is this it?

In parse.y rather. Yes, that's where the source FE eventually ends up
when the CALL_EXPR is ready to be turned into something the middle-end
can work on.

> Also, when compiling a method body, how does one refer to the formal
> parameters? It seems that the "...build(PARM_DECL..." in
> ".../gcc/java/parse.c" is used to construct the parameters.

As symbolic names that will be mapped to the actual parameter when
resolved.

> But I don't understand what to do when compiling the part of method
> body where that parameter is used/accessed.

java_complete_lhs does that for you. I suggest you write a very simple
example: class X { int foo () {return 3;} } and put a breakpoint in
java_complete_expand_methods. An ordinary method will be prepared
through a call to java_complete_expand_method, in which the function
body will eventually be expanded through a call to java_complete_tree.

As Tom already said, use debug_tree. If you'd like to know when a tree
gets created, put a conditional breakpoint on the last statement of
tree.c:make_node and test the returned value `t' against what you're
looking for and re-run.

  (gdb) b tree.c:463	   <- it might be different with your sources
  Breakpoint 5 at 0x81deefd: file /home/apbianco/src/egcs-devel/gcc/tree.c, line 463.
  (gdb) cond 5 (t==0x....) <- 0x... is the address of the tree node your want
                              to understand the creation of  
  (gdb) run		   <- Run again, you should stop in make_node when
                              the node is created 	

./A


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]