Java Reference
In-Depth Information
class
LHSVisitor
extends
NodeVisitor
constructor
LHSV
isitor
(MethodBodyVisitor
valueVisitor
)
this
.
valueVisitor
←
valueVisitor
53
end
procedure
visit
( LocalReferencing
n
)
54
/
Section 11.4.1 on page 437
/
end
procedure
visit
(StaticReferencing
n
)
55
/
Section 11.4.2 on page 438
/
end
procedure
visit
(FieldReferencing
n
)
56
/
Section 11.4.3 on page 439
/
end
procedure
visit
(ArrayReferencing
n
)
57
/
Section 11.4.4 on page 439
/
end
end
Figure 11.3: Structure of the left-hand side visitor.
AST
JVM Instructions
LocalReferencing
;
Instruction saved for later use:
istore 5
a
n
The box shows the instruction saved at Marker
58
if the local reference a is
associated with local 5 and its type is int.
/
Visitor code for Marker
55
/
procedure
visit
(StaticReferencing
n
)
(
new
StaticStore(
n
.
getType(),
n
.
getName( )))
call
set
S
tore
59
end
Code generation for assignments to statics resembles assignments to locals.
Marker
59
creates an instruction that will assign the static name contained
in the StaticReferencingnode. The type of that reference may be required to
generate the appropriate instruction.