net.janino
Class Java.FieldAccessExpression

java.lang.Object
  |
  +--net.janino.Java.Located
        |
        +--net.janino.Java.Atom
              |
              +--net.janino.Java.Rvalue
                    |
                    +--net.janino.Java.Lvalue
                          |
                          +--net.janino.Java.FieldAccessExpression
All Implemented Interfaces:
Java.Locatable
Enclosing class:
Java

public static class Java.FieldAccessExpression
extends Java.Lvalue

This class implements class or interface field access, and also the "array length" expression "xy.length".


Fields inherited from class net.janino.Java.Rvalue
CONSTANT_VALUE_NULL, JUMP_IF_FALSE, JUMP_IF_TRUE
 
Constructor Summary
Java.FieldAccessExpression(Scanner.Location location, Java.Atom lhs, java.lang.String fieldName)
           
 
Method Summary
 int compileContext()
          Generates code that determines the context of the Java.Rvalue and puts it on the operand stack.
 IClass compileGet()
          Generates code that determines the value of the Java.Rvalue and puts it on the operand stack.
 void compileSet(IClass valueType, java.lang.Object optionalConstantValue)
          Generates code that stores a value in the Java.Lvalue.
 IClass getType()
           
 
Methods inherited from class net.janino.Java.Lvalue
toLvalue
 
Methods inherited from class net.janino.Java.Rvalue
compile, compileBoolean, compileGetValue, getConstantValue, getNegatedConstantValue, toRvalue
 
Methods inherited from class net.janino.Java.Atom
addConstantFloatInfo, addConstantIntegerInfo, addConstantStringInfo, allocateLocalVariable, compileError, createDummyCodeAttribute, getLocation, isType, newInserter, newOffset, newUnsetOffset, popInserter, pushInserter, restoreLocalVariables, saveLocalVariables, throwParseException, toLvalueOrCE, toLvalueOrPE, toRvalueOrCE, toRvalueOrPE, toType, toTypeOrCE, toTypeOrPE, write, writeBranch, writeByte, writeConstantClassInfo, writeConstantDoubleInfo, writeConstantFieldrefInfo, writeConstantFloatInfo, writeConstantIntegerInfo, writeConstantInterfaceMethodrefInfo, writeConstantLongInfo, writeConstantMethodrefInfo, writeConstantStringInfo, writeInt, writeOffset, writeOpcode, writeShort
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Java.FieldAccessExpression

public Java.FieldAccessExpression(Scanner.Location location,
                                  Java.Atom lhs,
                                  java.lang.String fieldName)
Method Detail

getType

public IClass getType()
               throws Java.CompileException
Overrides:
getType in class Java.Atom

compileContext

public int compileContext()
                   throws Java.CompileException
Description copied from class: Java.Rvalue
Generates code that determines the context of the Java.Rvalue and puts it on the operand stack. Most expressions do not have a "context", but some do. E.g. for "x[y]", the context is "x, y". The bottom line is that for statements like "x[y] += 3" the context is only evaluated once.
Overrides:
compileContext in class Java.Rvalue
Following copied from class: net.janino.Java.Rvalue
Returns:
The size of the context on the operand stack

compileGet

public IClass compileGet()
                  throws Java.CompileException
Description copied from class: Java.Rvalue
Generates code that determines the value of the Java.Rvalue and puts it on the operand stack. This method relies on that the "context" of the Java.Rvalue is on top of the operand stack (see Java.Rvalue.compileContext()).
Overrides:
compileGet in class Java.Rvalue
Following copied from class: net.janino.Java.Rvalue
Returns:
The type of the Java.Rvalue

compileSet

public void compileSet(IClass valueType,
                       java.lang.Object optionalConstantValue)
                throws Java.CompileException
Description copied from class: Java.Lvalue
Generates code that stores a value in the Java.Lvalue. Expects the Java.Lvalue's context (see Java.Rvalue.compileContext()) and a value of type "valueType" on the operand stack.

If optionalConstantValue is not null, then the stack top value is identical to it; this allows for "primitive constant assignment conversion" (JLS 5.2).

Overrides:
compileSet in class Java.Lvalue