Java Reference
In-Depth Information
AST
JVM Instructions
AssignIsh
=
n
;
Code emitted for Computing
iload 5
sipush 250
iadd
ComputeIsh
LocalReferencing
a
plus
;
Code emitted by LHSVisitor
istore 5
ConstantIsh
LocalReferencing
a
250
The results of processing a sample Assigningnode are shown in the box above.
The LHSVisitor determines at Marker 32 that the assignment will store into
the local variable associated with a, but no code is generated yet. All but the
last instruction are generated by recursive application of the visitor to the right
subtree of the Assigning node, initiated at Marker 33 . The final instruction
is generated at Marker 34 . The details of the LHSVisitor are discussed in
Section 11.4.
11.3.6 Method Calls
/
Visitor code for Marker 9
/
procedure
( Invoking n )
sigVisitor
visit
new SignatureVisitor()
call n . accept( sigVisitor )
usageSignature sigVisitor . getSignature()
35
matchedSignature ← find
S
ignature
( usageSignature )
36
if not n . isVoid()
then
loc ← alloc
37
()
call n . setResultLocal( loc )
if not n . isStatic()
then
L
ocal
call n . getInstance() . accept( this )
38
foreach param n . getParams() do call param . accept( this )
39
if n . isVirtual()
then call
40
emit
V
irtual
M
ethod
C
all
( n )
else call
emit
N
on
V
irtual
M
ethod
C
all
( n )
end
 
 
Search WWH ::




Custom Search