/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This class encapsulates the information required to generate an update to a private
* field referenced from another class, e.g., an inner class. An expression denoting a
* reference to the object to which the field belongs is associated with getter and
* setter methods.
* <p>
* We use this class only for assignment, increment, and decrement operators, in which
* the old value is first retrieved and then a new value is computed and stored.
* Simple assignment expressions in which a value is copied without modification are
* handled by another mechanism.
*
* WARNING: The contents of this source file are not part of any
* supported API. Code that depends on them does so at its own risk:
* they are subject to change or removal without notice.
*/
// Location for reporting errors.
// Errors will always indicate compiler failure, but these will be easier to diagnose
// if the bogus error is localized to the offending assignment.
private long where;
// The field to which this updater applies.
// It would be easy to eliminate the need to store the field here, but we retain it for
// diagnostic purposes.
// Expression denoting the object to which the getter and setter are applied.
// If the field is static, 'base' may be null, but need not be, as a static field
// may be selected from an object reference. Even though the value of the object
// reference will be ignored, it may have side-effects.
// The getter and setter methods, generated by 'getAccessMember' and 'getUpdateMember'.
// The number of words occupied on the stack by the object reference.
// For static fields, this is zero.
private int depth;
/**
* Constructor.
*/
}
/**
* Since the object reference expression may be captured before it has been inlined,
* we must inline it later. A <code>FieldUpdater</code> is inlined essentially as if
* it were a child of the assignment node to which it belongs.
*/
} else {
}
}
return this;
}
}
// Size of 'invokestatic' call for access method is 3 bytes.
// Size of expression to compute 'this' arg if needed.
}
// We ignore the cost of duplicating value in value-needed context.
return cost;
}
/**
* Duplicate <code>items</code> words from the top of the stack, locating them
* below the topmost <code>depth</code> words on the stack.
*/
// This code was cribbed from 'Expression.java'. We cannot reuse that code here,
// because we do not inherit from class 'Expression'.
switch (items) {
case 0:
return;
case 1:
switch (depth) {
case 0:
return;
case 1:
return;
case 2:
return;
}
break;
case 2:
switch (depth) {
case 0:
return;
case 1:
return;
case 2:
return;
}
break;
}
}
/**
* Begin a field update by an assignment, increment, or decrement operator.
* The current value of the field is left at the top of the stack.
* If <code>valNeeded</code> is true, we arrange for the initial value to remain
* on the stack after the update.
*/
throw new CompilerError("startUpdate isStatic");
}
// Provide explicit 'this' argument.
depth = 1;
} else {
// May need to evaluate 'base' for effect.
// If 'base' was a type expression, it should have previously been inlined away.
}
depth = 0;
}
if (valNeeded) {
}
}
/**
* Complete a field update by an assignment, increment, or decrement operator.
* The original value of the field left on the stack by <code>startUpdate</code>
* must have been replaced with the updated value, with no other stack alterations.
* If <code>valNeeded</code> is true, we arrange for the updated value to remain
* on the stack after the update. The <code>valNeeded</code> argument must not be
* true in both <code>startUpdate</code> and <code>finishUpdate</code>.
*/
if (valNeeded) {
}
}
/**
* Like above, but used when assigning a new value independent of the
* old, as in a simple assignment expression. After 'startAssign',
* code must be emitted to leave one additional value on the stack without
* altering any others, followed by 'finishAssign'.
*/
throw new CompilerError("startAssign isStatic");
}
// Provide explicit 'this' argument.
depth = 1;
} else {
// May need to evaluate 'base' for effect.
// If 'base' was a type expression, it should have previously been inlined away.
}
depth = 0;
}
}
if (valNeeded) {
}
}
}