本文整理汇总了Java中com.sun.org.apache.bcel.internal.generic.PUTFIELD类的典型用法代码示例。如果您正苦于以下问题:Java PUTFIELD类的具体用法?Java PUTFIELD怎么用?Java PUTFIELD使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PUTFIELD类属于com.sun.org.apache.bcel.internal.generic包,在下文中一共展示了PUTFIELD类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: translate
import com.sun.org.apache.bcel.internal.generic.PUTFIELD; //导入依赖的package包/类
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
// Don't generate code for unreferenced variables
if (_refs.isEmpty()) {
_ignore = true;
}
// Make sure that a variable instance is only compiled once
if (_ignore) return;
_ignore = true;
final String name = getEscapedName();
if (isLocal()) {
// Compile variable value computation
translateValue(classGen, methodGen);
// Add a new local variable and store value
boolean createLocal = _local == null;
if (createLocal) {
mapRegister(methodGen);
}
InstructionHandle storeInst =
il.append(_type.STORE(_local.getIndex()));
// If the local is just being created, mark the store as the start
// of its live range. Note that it might have been created by
// initializeVariables already, which would have set the start of
// the live range already.
if (createLocal) {
_local.setStart(storeInst);
}
}
else {
String signature = _type.toSignature();
// Global variables are store in class fields
if (classGen.containsField(name) == null) {
classGen.addField(new Field(ACC_PUBLIC,
cpg.addUtf8(name),
cpg.addUtf8(signature),
null, cpg.getConstantPool()));
// Push a reference to "this" for putfield
il.append(classGen.loadTranslet());
// Compile variable value computation
translateValue(classGen, methodGen);
// Store the variable in the allocated field
il.append(new PUTFIELD(cpg.addFieldref(classGen.getClassName(),
name, signature)));
}
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:56,代码来源:Variable.java
示例2: compileDefault
import com.sun.org.apache.bcel.internal.generic.PUTFIELD; //导入依赖的package包/类
private void compileDefault(ClassGenerator classGen,
MethodGenerator methodGen) {
int index;
ConstantPoolGen cpg = classGen.getConstantPool();
InstructionList il = methodGen.getInstructionList();
int[] fieldIndexes = getXSLTC().getNumberFieldIndexes();
if (fieldIndexes[_level] == -1) {
Field defaultNode = new Field(ACC_PRIVATE,
cpg.addUtf8(FieldNames[_level]),
cpg.addUtf8(NODE_COUNTER_SIG),
null,
cpg.getConstantPool());
// Add a new private field to this class
classGen.addField(defaultNode);
// Get a reference to the newly added field
fieldIndexes[_level] = cpg.addFieldref(classGen.getClassName(),
FieldNames[_level],
NODE_COUNTER_SIG);
}
// Check if field is initialized (runtime)
il.append(classGen.loadTranslet());
il.append(new GETFIELD(fieldIndexes[_level]));
final BranchHandle ifBlock1 = il.append(new IFNONNULL(null));
// Create an instance of DefaultNodeCounter
index = cpg.addMethodref(ClassNames[_level],
"getDefaultNodeCounter",
"(" + TRANSLET_INTF_SIG
+ DOM_INTF_SIG
+ NODE_ITERATOR_SIG
+ ")" + NODE_COUNTER_SIG);
il.append(classGen.loadTranslet());
il.append(methodGen.loadDOM());
il.append(methodGen.loadIterator());
il.append(new INVOKESTATIC(index));
il.append(DUP);
// Store the node counter in the field
il.append(classGen.loadTranslet());
il.append(SWAP);
il.append(new PUTFIELD(fieldIndexes[_level]));
final BranchHandle ifBlock2 = il.append(new GOTO(null));
// Backpatch conditionals
ifBlock1.setTarget(il.append(classGen.loadTranslet()));
il.append(new GETFIELD(fieldIndexes[_level]));
ifBlock2.setTarget(il.append(NOP));
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:55,代码来源:Number.java
示例3: translateFilter
import com.sun.org.apache.bcel.internal.generic.PUTFIELD; //导入依赖的package包/类
/**
* Translate a predicate expression. This translation pushes
* two references on the stack: a reference to a newly created
* filter object and a reference to the predicate's closure.
*/
public void translateFilter(ClassGenerator classGen,
MethodGenerator methodGen)
{
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
// Compile auxiliary class for filter
compileFilter(classGen, methodGen);
// Create new instance of filter
il.append(new NEW(cpg.addClass(_className)));
il.append(DUP);
il.append(new INVOKESPECIAL(cpg.addMethodref(_className,
"<init>", "()V")));
// Initialize closure variables
final int length = (_closureVars == null) ? 0 : _closureVars.size();
for (int i = 0; i < length; i++) {
VariableRefBase varRef = (VariableRefBase) _closureVars.get(i);
VariableBase var = varRef.getVariable();
Type varType = var.getType();
il.append(DUP);
// Find nearest closure implemented as an inner class
Closure variableClosure = _parentClosure;
while (variableClosure != null) {
if (variableClosure.inInnerClass()) break;
variableClosure = variableClosure.getParentClosure();
}
// Use getfield if in an inner class
if (variableClosure != null) {
il.append(ALOAD_0);
il.append(new GETFIELD(
cpg.addFieldref(variableClosure.getInnerClassName(),
var.getEscapedName(), varType.toSignature())));
}
else {
// Use a load of instruction if in translet class
il.append(var.loadInstruction());
}
// Store variable in new closure
il.append(new PUTFIELD(
cpg.addFieldref(_className, var.getEscapedName(),
varType.toSignature())));
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:56,代码来源:Predicate.java
注:本文中的com.sun.org.apache.bcel.internal.generic.PUTFIELD类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论