• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java LocalVariableInstruction类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.bcel.generic.LocalVariableInstruction的典型用法代码示例。如果您正苦于以下问题:Java LocalVariableInstruction类的具体用法?Java LocalVariableInstruction怎么用?Java LocalVariableInstruction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LocalVariableInstruction类属于org.apache.bcel.generic包,在下文中一共展示了LocalVariableInstruction类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: rewriteLocal

import org.apache.bcel.generic.LocalVariableInstruction; //导入依赖的package包/类
void rewriteLocal(InstructionHandle fromH, InstructionHandle toH,
    int oldindex, int newindex) {

InstructionHandle h = fromH;
if (h.getPrev() != null) {
    h = h.getPrev();
    // This instruction should contain the store.
}
while (h != null && h != toH) {
    Instruction ins = h.getInstruction();
    if (ins instanceof LocalVariableInstruction) {
	LocalVariableInstruction lins = (LocalVariableInstruction) ins;
	if (lins.getIndex() == oldindex) {
	    lins.setIndex(newindex);
	}
    }
    h = h.getNext();
}
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:20,代码来源:MethodTable.java


示例2: getLocal

import org.apache.bcel.generic.LocalVariableInstruction; //导入依赖的package包/类
final LocalVariableGen getLocal(MethodGen m, LocalVariableInstruction curr,
    int pos) {
int localNr = curr.getIndex();
LocalVariableGen[] lt = getLocalTable(m);

for (int i = 0; i < lt.length; i++) {
    // Watch out. The first initialization seems not to be included in
    // the range given in the local variable table!

    if (localNr == lt[i].getIndex()) {
	// System.err.println("Looking for local " + localNr
	// + " on position " + pos);
	// System.err.println("found one with range "
	// + lt[i].getStart().getPrev().getPosition() + ", "
	// + lt[i].getEnd().getPosition());

	if (pos >= lt[i].getStart().getPrev().getPosition()
		&& pos < (lt[i].getEnd().getPosition())) {
	    return lt[i];
	}
    }
}

return null;
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:26,代码来源:MethodTable.java


示例3: rewriteStore

import org.apache.bcel.generic.LocalVariableInstruction; //导入依赖的package包/类
InstructionHandle rewriteStore(MethodGen m, InstructionList il,
    InstructionHandle i, int maxLocals, String localClassName) {
    LocalVariableInstruction curr = (LocalVariableInstruction) (i
        .getInstruction());
    Type type = mtab.getLocalType(m, curr, i.getPosition());
    if (type == null) {
        return i;
    }
    String name = mtab.getLocalName(m, curr, i.getPosition());
    String fieldName = MethodTable.generatedLocalName(type, name);

    i.setInstruction(new ALOAD(maxLocals));
    i = i.getNext();

    if (type.equals(Type.LONG) || type.equals(Type.DOUBLE)) {
        il.insert(i, new DUP_X2());
        il.insert(i, new POP());
    } else {
        il.insert(i, new SWAP());
    }

    i = il.insert(i, ins_f.createFieldAccess(localClassName, fieldName,
        type, Constants.PUTFIELD));
    return i;
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:26,代码来源:Cashmerec.java


示例4: rewriteLoad

import org.apache.bcel.generic.LocalVariableInstruction; //导入依赖的package包/类
InstructionHandle rewriteLoad(MethodGen m, InstructionList il,
    InstructionHandle i, int maxLocals, String localClassName) {
    LocalVariableInstruction curr = (LocalVariableInstruction) (i
        .getInstruction());
    Type type = mtab.getLocalType(m, curr, i.getPosition());
    if (type == null) {
        return i;
    }
    String name = mtab.getLocalName(m, curr, i.getPosition());
    String fieldName = MethodTable.generatedLocalName(type, name);

    i.setInstruction(new ALOAD(maxLocals));
    i = i.getNext();
    i = il.insert(i, ins_f.createFieldAccess(localClassName, fieldName,
        type, Constants.GETFIELD));

    return i;
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:19,代码来源:Cashmerec.java


示例5: getLocalName

import org.apache.bcel.generic.LocalVariableInstruction; //导入依赖的package包/类
String getLocalName(MethodGen m, LocalVariableInstruction curr, int pos) {
LocalVariableGen a = getLocal(m, curr, pos);

if (a == null) {
    return null;
}

return a.getName();
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:10,代码来源:MethodTable.java


示例6: getLocalType

import org.apache.bcel.generic.LocalVariableInstruction; //导入依赖的package包/类
Type getLocalType(MethodGen m, LocalVariableInstruction curr, int pos) {
LocalVariableGen a = getLocal(m, curr, pos);

if (a == null) {
    return null;
}

return a.getType();
   }
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:10,代码来源:MethodTable.java


示例7: removeUnusedLocals

import org.apache.bcel.generic.LocalVariableInstruction; //导入依赖的package包/类
void removeUnusedLocals(Method mOrig, MethodGen m) {
    InstructionList il = m.getInstructionList();
    InstructionHandle[] ins = il.getInstructionHandles();
    for (int i = 0; i < ins.length; i++) {
        Instruction in = ins[i].getInstruction();

        if (in instanceof LocalVariableInstruction) {
            LocalVariableInstruction curr = (LocalVariableInstruction) in;
            if (mtab.getLocal(m, curr, ins[i].getPosition()) != null
                && curr.getIndex() < m.getMaxLocals() - 5
                && !mtab.isLocalUsedInInlet(mOrig, curr.getIndex())) {
                if (curr instanceof IINC) {
                    ins[i].setInstruction(new NOP());
                } else if (curr instanceof LSTORE || curr instanceof DSTORE) {
                    ins[i].setInstruction(new POP2());
                } else if (curr instanceof StoreInstruction) {
                    ins[i].setInstruction(new POP());
                } else if (curr instanceof ALOAD) {
                    ins[i].setInstruction(new ACONST_NULL());
                } else if (curr instanceof FLOAD) {
                    ins[i].setInstruction(new FCONST((float) 0.0));
                } else if (curr instanceof ILOAD) {
                    ins[i].setInstruction(new ICONST(0));
                } else if (curr instanceof DLOAD) {
                    ins[i].setInstruction(new DCONST(0.0));
                } else if (curr instanceof LLOAD) {
                    ins[i].setInstruction(new LCONST(0L));
                } else {
                    System.out.println("unhandled ins in "
                        + "removeUnusedLocals: " + curr);
                    System.exit(1);
                }
            }
        }
    }
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:37,代码来源:Cashmerec.java


示例8: shiftLocals

import org.apache.bcel.generic.LocalVariableInstruction; //导入依赖的package包/类
void shiftLocals(InstructionList il, int shift) {
    InstructionHandle[] ih = il.getInstructionHandles();
    for (int i = 0; i < ih.length; i++) {
        Instruction ins = ih[i].getInstruction();
        if (ins instanceof LocalVariableInstruction) {
            LocalVariableInstruction l = (LocalVariableInstruction) ins;
            l.setIndex(l.getIndex() + shift);
        }
    }

}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:12,代码来源:Cashmerec.java


示例9: emitLocalVariableInstruction

import org.apache.bcel.generic.LocalVariableInstruction; //导入依赖的package包/类
private void emitLocalVariableInstruction(Element xml_inst,
        LocalVariableInstruction inst) {
    Type type = inst.getType(cpg);
    xml_inst.setAttribute("type", type.toString());
    xml_inst.setAttribute("index", java.lang.String.valueOf(inst.getIndex()));
    String op = inst.toString();
    int i;
    for (i = 0; i < op.length(); i++) {
        char ch = op.toUpperCase().charAt(i);
        if (ch < 'A' || ch > 'Z')
            break;
    }
    op = op.substring(0, i);
    xml_inst.setName(op);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:16,代码来源:ClassToXmlvmProcess.java


示例10: registerInstructionSources

import org.apache.bcel.generic.LocalVariableInstruction; //导入依赖的package包/类
private void registerInstructionSources() throws DataflowAnalysisException {
    for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
        Location location = i.next();
        Instruction instruction = location.getHandle().getInstruction();
        short opcode = instruction.getOpcode();

        int produces = instruction.produceStack(cpg);
        if (instruction instanceof InvokeInstruction) {
            // Model return value
            registerReturnValueSource(location);
        } else if (opcode == Constants.GETFIELD || opcode == Constants.GETSTATIC) {
            // Model field loads
            registerFieldLoadSource(location);
        } else if (instruction instanceof LDC) {
            // Model constant values
            registerLDCValueSource(location);
        } else if (instruction instanceof LDC2_W) {
            // Model constant values
            registerLDC2ValueSource(location);
        } else if (instruction instanceof ConstantPushInstruction) {
            // Model constant values
            registerConstantPushSource(location);
        } else if (instruction instanceof ACONST_NULL) {
            // Model constant values
            registerPushNullSource(location);
        } else  if ((produces == 1 || produces == 2) && !(instruction instanceof LocalVariableInstruction) && !(instruction instanceof CHECKCAST)){
            // Model other sources
            registerOtherSource(location);
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:32,代码来源:ForwardTypeQualifierDataflowAnalysis.java


示例11: getAccessedLocalsIndices

import org.apache.bcel.generic.LocalVariableInstruction; //导入依赖的package包/类
public int[] getAccessedLocalsIndices(){
	//TODO: Implement caching.
	Set acc = new HashSet();
	if (theRET == null && this != TOPLEVEL){
		throw new AssertionViolatedException("This subroutine object must be built up completely before calculating accessed locals.");
	}
	Iterator i = instructions.iterator();
	while (i.hasNext()){
		InstructionHandle ih = (InstructionHandle) i.next();
		// RET is not a LocalVariableInstruction in the current version of BCEL.
		if (ih.getInstruction() instanceof LocalVariableInstruction || ih.getInstruction() instanceof RET){
			int idx = ((IndexedInstruction) (ih.getInstruction())).getIndex();
			acc.add(new Integer(idx));
			// LONG? DOUBLE?.
			try{
				// LocalVariableInstruction instances are typed without the need to look into
				// the constant pool.
				if (ih.getInstruction() instanceof LocalVariableInstruction){
					int s = ((LocalVariableInstruction) ih.getInstruction()).getType(null).getSize();
					if (s==2) {
                              acc.add(new Integer(idx+1));
                          }
				}
			}
			catch(RuntimeException re){
				throw new AssertionViolatedException("Oops. BCEL did not like NULL as a ConstantPoolGen object.");
			}
		}
	}
	
	int[] ret = new int[acc.size()];
	i = acc.iterator();
	int j=-1;
	while (i.hasNext()){
		j++;
		ret[j] = ((Integer) i.next()).intValue();
	}
	return ret;
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:40,代码来源:Subroutines.java


示例12: visitLocalVariableInstruction

import org.apache.bcel.generic.LocalVariableInstruction; //导入依赖的package包/类
public void visitLocalVariableInstruction( LocalVariableInstruction i ) {
    short opcode = i.getOpcode();
    Type type = i.getType(_cp);
    if (opcode == Constants.IINC) {
        _out.println("il.append(new IINC(" + i.getIndex() + ", " + ((IINC) i).getIncrement()
                + "));");
    } else {
        String kind = (opcode < Constants.ISTORE) ? "Load" : "Store";
        _out.println("il.append(_factory.create" + kind + "(" + BCELifier.printType(type)
                + ", " + i.getIndex() + "));");
    }
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:13,代码来源:BCELFactory.java


示例13: getAccessedLocalsIndices

import org.apache.bcel.generic.LocalVariableInstruction; //导入依赖的package包/类
public int[] getAccessedLocalsIndices(){
	//TODO: Implement caching.
	final Set<Integer> acc = new HashSet<Integer>();
	if (theRET == null && this != TOPLEVEL){
		throw new AssertionViolatedException("This subroutine object must be built up completely before calculating accessed locals.");
	}
	for (final InstructionHandle ih : instructions) {
		// RET is not a LocalVariableInstruction in the current version of BCEL.
		if (ih.getInstruction() instanceof LocalVariableInstruction || ih.getInstruction() instanceof RET){
			int idx = IndexedInstruction.class.cast(ih.getInstruction()).getIndex();
			acc.add(idx);
			// LONG? DOUBLE?.
			try {
				// LocalVariableInstruction instances are typed without the need to look into
				// the constant pool.
				if (ih.getInstruction() instanceof LocalVariableInstruction) {
					int s = LocalVariableInstruction.class.cast(ih.getInstruction()).getType(null).getSize();
					if (s == 2) acc.add(idx + 1);
				}
			} catch(final RuntimeException re) {
				throw new AssertionViolatedException("Oops. BCEL did not like NULL as a ConstantPoolGen object.");
			}
		}
	}

	int[] ret = new int[acc.size()];
	int j = 0;
	for (final int v : acc) {
		ret[j++] = v;
	}
	return ret;
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:33,代码来源:Subroutines.java



注:本文中的org.apache.bcel.generic.LocalVariableInstruction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DiagnosticMessage类代码示例发布时间:2022-05-22
下一篇:
Java Transceiver类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap