Package jminusminus
Class LocalContext
java.lang.Object
jminusminus.Context
jminusminus.LocalContext
- Direct Known Subclasses:
MethodContext
A local context is a context (scope) in which local variables (including formal parameters)
can be declared. Local variables are allocated at fixed offsets from the base of the current
method's stack frame; this is done during analysis. The definitions for local variables record
these offsets. The offsets are used in code generation.
-
Field Summary
Fields inherited from class jminusminus.Context
classContext, compilationUnitContext, entries, surroundingContext
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Allocates and returns a new offset (eg, for a parameter or local variable).int
offset()
Returns the "next" offset.void
toJSON
(JSONElement json) Adds information pertaining to this context to the given JSON element.Methods inherited from class jminusminus.Context
addEntry, addType, classContext, compilationUnitContext, definingType, lookup, lookupType, methodContext, names, surroundingContext
-
Field Details
-
offset
protected int offsetNext offset for a local variable.
-
-
Constructor Details
-
LocalContext
Constructs a local context. A local context is constructed for each block.- Parameters:
surrounding
- the surrounding context.
-
-
Method Details
-
offset
public int offset()Returns the "next" offset. Not to be used for allocating new offsets (the nextOffset() method is used for that).- Returns:
- the next available offset.
-
nextOffset
public int nextOffset()Allocates and returns a new offset (eg, for a parameter or local variable).- Returns:
- the next allocated offset.
-
toJSON
Adds information pertaining to this context to the given JSON element.
-