当前位置: 首页>>代码示例>>Java>>正文


Java ConstantFloat类代码示例

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


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

示例1: pushByConstant

import org.apache.bcel.classfile.ConstantFloat; //导入依赖的package包/类
private void pushByConstant(DismantleBytecode dbc, Constant c) {
	
if (c instanceof ConstantInteger)
	push(new Item("I", new Integer(((ConstantInteger) c).getBytes())));
else if (c instanceof ConstantString) {
	int s = ((ConstantString) c).getStringIndex();
	push(new Item("Ljava/lang/String;", getStringFromIndex(dbc, s)));
}
else if (c instanceof ConstantFloat)
	push(new Item("F", new Float(((ConstantInteger) c).getBytes())));
else if (c instanceof ConstantDouble)
	push(new Item("D", new Double(((ConstantDouble) c).getBytes())));
else if (c instanceof ConstantLong)
	push(new Item("J", new Long(((ConstantLong) c).getBytes())));
else
	throw new UnsupportedOperationException("Constant type not expected" );
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:18,代码来源:OpcodeStack.java

示例2: pushByConstant

import org.apache.bcel.classfile.ConstantFloat; //导入依赖的package包/类
private void pushByConstant(DismantleBytecode dbc, Constant c) {

        if (c instanceof ConstantClass)
            push(new Item("Ljava/lang/Class;", ((ConstantClass) c).getConstantValue(dbc.getConstantPool())));
        else if (c instanceof ConstantInteger)
            push(new Item("I", Integer.valueOf(((ConstantInteger) c).getBytes())));
        else if (c instanceof ConstantString) {
            int s = ((ConstantString) c).getStringIndex();
            push(new Item("Ljava/lang/String;", getStringFromIndex(dbc, s)));
        } else if (c instanceof ConstantFloat)
            push(new Item("F", Float.valueOf(((ConstantFloat) c).getBytes())));
        else if (c instanceof ConstantDouble)
            push(new Item("D", Double.valueOf(((ConstantDouble) c).getBytes())));
        else if (c instanceof ConstantLong)
            push(new Item("J", Long.valueOf(((ConstantLong) c).getBytes())));
        else
            throw new UnsupportedOperationException("Constant type not expected");
    }
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:19,代码来源:OpcodeStack.java

示例3: pushByConstant

import org.apache.bcel.classfile.ConstantFloat; //导入依赖的package包/类
private void pushByConstant(DismantleBytecode dbc, Constant c) {

        if (c instanceof ConstantClass)
            push(new Item("Ljava/lang/Class;", ((ConstantClass) c).getConstantValue(dbc.getConstantPool())));
        else if (c instanceof ConstantInteger)
            push(new Item("I", Integer.valueOf(((ConstantInteger) c).getBytes())));
        else if (c instanceof ConstantString) {
            int s = ((ConstantString) c).getStringIndex();
            push(new Item("Ljava/lang/String;", getStringFromIndex(dbc, s)));
        } else if (c instanceof ConstantFloat)
            push(new Item("F", Float.valueOf(((ConstantFloat) c).getBytes())));
        else if (c instanceof ConstantDouble)
            push(new Item("D", Double.valueOf(((ConstantDouble) c).getBytes())));
        else if (c instanceof ConstantLong)
            push(new Item("J", Long.valueOf(((ConstantLong) c).getBytes())));
        else
            throw new UnsupportedOperationException("StaticConstant type not expected");
    }
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:19,代码来源:OpcodeStack.java

示例4: visitLDC

import org.apache.bcel.classfile.ConstantFloat; //导入依赖的package包/类
/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
// LDC and LDC_W (LDC_W is a subclass of LDC in BCEL's model)
public void visitLDC(LDC o){
	indexValid(o, o.getIndex());
	Constant c = cpg.getConstant(o.getIndex());
	if (c instanceof ConstantClass){
	  addMessage("Operand of LDC or LDC_W is CONSTANT_Class '"+c+"' - this is only supported in JDK 1.5 and higher.");
	}
	else{
	  if (! ( (c instanceof ConstantInteger)	||
	          (c instanceof ConstantFloat) 		||
              (c instanceof ConstantString) ) ){
          constraintViolated(o, "Operand of LDC or LDC_W must be one of CONSTANT_Integer, CONSTANT_Float or CONSTANT_String, but is '"+c+"'.");
	  }
	}
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:17,代码来源:Pass3aVerifier.java

示例5: CPESSC_Visitor

import org.apache.bcel.classfile.ConstantFloat; //导入依赖的package包/类
private CPESSC_Visitor(JavaClass _jc){
	jc = _jc;
	cp = _jc.getConstantPool();
	cplen = cp.getLength();

	CONST_Class = org.apache.bcel.classfile.ConstantClass.class;
	/*
          CONST_Fieldref = org.apache.bcel.classfile.ConstantFieldref.class;
	CONST_Methodref = org.apache.bcel.classfile.ConstantMethodref.class;
	CONST_InterfaceMethodref = org.apache.bcel.classfile.ConstantInterfaceMethodref.class;
          */
	CONST_String = org.apache.bcel.classfile.ConstantString.class;
	CONST_Integer = org.apache.bcel.classfile.ConstantInteger.class;
	CONST_Float = org.apache.bcel.classfile.ConstantFloat.class;
	CONST_Long = org.apache.bcel.classfile.ConstantLong.class;
	CONST_Double = org.apache.bcel.classfile.ConstantDouble.class;
	CONST_NameAndType = org.apache.bcel.classfile.ConstantNameAndType.class;
	CONST_Utf8 = org.apache.bcel.classfile.ConstantUtf8.class;

	carrier = new DescendingVisitor(_jc, this);
	carrier.visit();
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:23,代码来源:Pass2Verifier.java

示例6: visitLDC

import org.apache.bcel.classfile.ConstantFloat; //导入依赖的package包/类
/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 
public void visitLDC(LDC o){
	Constant c = cpg.getConstant(o.getIndex());
	if (c instanceof ConstantInteger){
		stack().push(Type.INT);
	}
	if (c instanceof ConstantFloat){
		stack().push(Type.FLOAT);
	}
	if (c instanceof ConstantString){
		stack().push(Type.STRING);
	}
       if (c instanceof ConstantClass) {
           stack().push(new ObjectType("java.lang.Class"));
       }
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:17,代码来源:ExecutionVisitor.java

示例7: visitLDC_W

import org.apache.bcel.classfile.ConstantFloat; //导入依赖的package包/类
/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 
public void visitLDC_W(LDC_W o){
	Constant c = cpg.getConstant(o.getIndex());
	if (c instanceof ConstantInteger){
		stack().push(Type.INT);
	}
	if (c instanceof ConstantFloat){
		stack().push(Type.FLOAT);
	}
	if (c instanceof ConstantString){
		stack().push(Type.STRING);
	}
       if (c instanceof ConstantClass) {
           stack().push(new ObjectType("java.lang.Class"));
       }
}
 
开发者ID:jesusc,项目名称:eclectic,代码行数:17,代码来源:ExecutionVisitor.java

示例8: visitLDC

import org.apache.bcel.classfile.ConstantFloat; //导入依赖的package包/类
/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 
public void visitLDC(LDC o){
	Constant c = cpg.getConstant(o.getIndex());
	if (c instanceof ConstantInteger){
		stack().push(Type.INT);
	}
	if (c instanceof ConstantFloat){
		stack().push(Type.FLOAT);
	}
	if (c instanceof ConstantString){
		stack().push(Type.STRING);
	}
}
 
开发者ID:linchaolong,项目名称:ApkToolPlus,代码行数:14,代码来源:ExecutionVisitor.java

示例9: visitLDC_W

import org.apache.bcel.classfile.ConstantFloat; //导入依赖的package包/类
/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 
public void visitLDC_W(LDC_W o){
	Constant c = cpg.getConstant(o.getIndex());
	if (c instanceof ConstantInteger){
		stack().push(Type.INT);
	}
	if (c instanceof ConstantFloat){
		stack().push(Type.FLOAT);
	}
	if (c instanceof ConstantString){
		stack().push(Type.STRING);
	}
}
 
开发者ID:linchaolong,项目名称:ApkToolPlus,代码行数:14,代码来源:ExecutionVisitor.java

示例10: visitLDC

import org.apache.bcel.classfile.ConstantFloat; //导入依赖的package包/类
/**
 * Ensures the specific preconditions of the said instruction.
 */
public void visitLDC(LDC o){
	// visitCPInstruction is called first.
	
	Constant c = cpg.getConstant(o.getIndex());
	if 	(!	(	( c instanceof ConstantInteger) ||
						( c instanceof ConstantFloat	)	||
						( c instanceof ConstantString )	)	){
		constraintViolated(o, "Referenced constant should be a CONSTANT_Integer, a CONSTANT_Float or a CONSTANT_String, but is '"+c+"'.");
	}
}
 
开发者ID:linchaolong,项目名称:ApkToolPlus,代码行数:14,代码来源:InstConstraintVisitor.java

示例11: visitLDC_W

import org.apache.bcel.classfile.ConstantFloat; //导入依赖的package包/类
/**
 * Ensures the specific preconditions of the said instruction.
 */
public void visitLDC_W(LDC_W o){
	// visitCPInstruction is called first.
	
	Constant c = cpg.getConstant(o.getIndex());
	if 	(!	(	( c instanceof ConstantInteger) ||
						( c instanceof ConstantFloat	)	||
						( c instanceof ConstantString )	)	){
		constraintViolated(o, "Referenced constant should be a CONSTANT_Integer, a CONSTANT_Float or a CONSTANT_String, but is '"+c+"'.");
	}
}
 
开发者ID:linchaolong,项目名称:ApkToolPlus,代码行数:14,代码来源:InstConstraintVisitor.java

示例12: getConstantPool

import org.apache.bcel.classfile.ConstantFloat; //导入依赖的package包/类
public static Set<Object> getConstantPool(InputStream is, String name) throws ClassFormatException, IOException {
	HashSet<Object> constants = new HashSet<Object>();
	ClassParser parser = new ClassParser(is, name);
	ConstantPool pool = parser.parse().getConstantPool();
	for (Constant constant : pool.getConstantPool()) {
		//Strings used in code are stored using String constant, they are just references to Utf8 constant
		//but we can't use Utf8 constants because they are used to store field/method/class names and signatures too
		if (constant instanceof ConstantString) {
			String string = (String) ((ConstantString) constant).getConstantValue(pool);
			//skip empty string
			if (string.isEmpty()) {
				continue;
			}
			constants.add(string);
		}
		if (constant instanceof ConstantInteger || constant instanceof ConstantLong || constant instanceof ConstantFloat || constant instanceof ConstantDouble) {
			constants.add(((ConstantObject) constant).getConstantValue(pool));
		}
	}
	return constants;
}
 
开发者ID:MCCarbon,项目名称:DecompileTools,代码行数:22,代码来源:ClassFinderHelpers.java

示例13: sawOpcode

import org.apache.bcel.classfile.ConstantFloat; //导入依赖的package包/类
@Override
public void sawOpcode(int seen) {
    if (state == SEEN_NOTHING) {
        if ((seen == DCONST_0) || (seen == DCONST_1)) {
            constValue = seen - DCONST_0;
            state = SEEN_DCONST;
        } else if ((seen == LDC2_W) || (seen == LDC_W)) {
            state = SEEN_DCONST;
            Constant c = this.getConstantRefOperand();
            if (c instanceof ConstantDouble)
                constValue = ((ConstantDouble) c).getBytes();
            else if (c instanceof ConstantFloat)
                constValue = ((ConstantFloat) c).getBytes();
            else if (c instanceof ConstantLong)
                constValue = ((ConstantLong) c).getBytes();
            else
                state = SEEN_NOTHING;
        }
    } else if (state == SEEN_DCONST) {
        if (seen == INVOKESTATIC) {
            state = SEEN_NOTHING;
            if (getDottedClassConstantOperand().equals("java.lang.Math")) {
                String methodName = getNameConstantOperand();

                if (((constValue == 0.0) && zeroMethods.contains(methodName))
                        || ((constValue == 1.0) && oneMethods.contains(methodName)) || (anyMethods.contains(methodName))) {
                    bugReporter.reportBug(new BugInstance(this, "UM_UNNECESSARY_MATH", LOW_PRIORITY).addClassAndMethod(this)
                            .addSourceLine(this));
                }
            }
        }
        state = SEEN_NOTHING;
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:35,代码来源:UnnecessaryMath.java

示例14: lookupFloat

import org.apache.bcel.classfile.ConstantFloat; //导入依赖的package包/类
/** 
 * Look for ConstantFloat in ConstantPool.
 *
 * @param n Float number to look for
 * @return index on success, -1 otherwise
 */
public int lookupFloat( float n ) {
    int bits = Float.floatToIntBits(n);
    for (int i = 1; i < index; i++) {
        if (constants[i] instanceof ConstantFloat) {
            ConstantFloat c = (ConstantFloat) constants[i];
            if (Float.floatToIntBits(c.getBytes()) == bits) {
                return i;
            }
        }
    }
    return -1;
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:19,代码来源:ConstantPoolGen.java

示例15: addFloat

import org.apache.bcel.classfile.ConstantFloat; //导入依赖的package包/类
/**
 * Add a new Float constant to the ConstantPool, if it is not already in there.
 *
 * @param n Float number to add
 * @return index of entry
 */
public int addFloat( float n ) {
    int ret;
    if ((ret = lookupFloat(n)) != -1) {
        return ret; // Already in CP
    }
    adjustSize();
    ret = index;
    constants[index++] = new ConstantFloat(n);
    return ret;
}
 
开发者ID:Hu6,项目名称:VestaClient,代码行数:17,代码来源:ConstantPoolGen.java


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