Java 类com.sun.jdi.IntegerType 实例源码

项目:incubator-netbeans    文件:EvaluatorVisitor.java   
public static ReferenceType adjustBoxingType(ReferenceType type, PrimitiveType primitiveType,
                                              EvaluationContext evaluationContext) {
    Class typeClass = null;
    if (primitiveType instanceof BooleanType) {
        typeClass = Boolean.class;
    } else
    if (primitiveType instanceof ByteType) {
        typeClass = Byte.class;
    } else
    if (primitiveType instanceof CharType) {
        typeClass = Character.class;
    } else
    if (primitiveType instanceof ShortType) {
        typeClass = Short.class;
    } else
    if (primitiveType instanceof IntegerType) {
        typeClass = Integer.class;
    } else
    if (primitiveType instanceof LongType) {
        typeClass = Long.class;
    } else
    if (primitiveType instanceof FloatType) {
        typeClass = Float.class;
    } else
    if (primitiveType instanceof DoubleType) {
        typeClass = Double.class;
    }
    if (typeClass != null) {
        type = evaluationContext.getVMCache().getClass(typeClass.getName());
    }
    return type;
}
项目:incubator-netbeans    文件:EvaluatorVisitor.java   
/** @return true if t2 is an extension of t1 */
private static boolean extendsType(PrimitiveType t1, PrimitiveType t2) {
    // BooleanType, ByteType and CharType can be matched together only.
    if (t2 instanceof ShortType) {
        return t2 instanceof ByteType || t2 instanceof ShortType;
    }
    if (t2 instanceof IntegerType) {
        return t2 instanceof ByteType || t2 instanceof ShortType || t2 instanceof IntegerType;
    }
    if (t2 instanceof LongType) {
        return t2 instanceof ByteType || t2 instanceof ShortType ||
               t2 instanceof IntegerType || t2 instanceof LongType;
    }
    if (t2 instanceof FloatType) {
        return !(t2 instanceof BooleanType || t2 instanceof CharType || t2 instanceof DoubleType);
    }
    if (t2 instanceof DoubleType) {
        return !(t2 instanceof BooleanType || t2 instanceof CharType);
    }
    return false;
}
项目:incubator-netbeans    文件:EvaluatorVisitor.java   
private String toString(Tree arg0, Mirror v, EvaluationContext evaluationContext) {
    if (v instanceof PrimitiveValue) {
        PrimitiveValue pv = (PrimitiveValue) v;
        PrimitiveType t = (PrimitiveType) pv.type();
        if (t instanceof ByteType) {
            return Byte.toString(pv.byteValue());
        }
        if (t instanceof BooleanType) {
            return Boolean.toString(pv.booleanValue());
        }
        if (t instanceof CharType) {
            return Character.toString(pv.charValue());
        }
        if (t instanceof ShortType) {
            return Short.toString(pv.shortValue());
        }
        if (t instanceof IntegerType) {
            return Integer.toString(pv.intValue());
        }
        if (t instanceof LongType) {
            return Long.toString(pv.longValue());
        }
        if (t instanceof FloatType) {
            return Float.toString(pv.floatValue());
        }
        if (t instanceof DoubleType) {
            return Double.toString(pv.doubleValue());
        }
        throw new IllegalStateException("Unknown primitive type: "+t);
    }
    if (v == null) {
        return "" + null;
    }
    ObjectReference ov = (ObjectReference) v;
    if (ov instanceof ArrayReference) {
        return "#" + ov.uniqueID() +
            " " + ov.type().name() +
            "(length=" + ((ArrayReference) ov).length() + ")";
    }
    if (ov instanceof StringReference) {
        return ((StringReference) ov).value();
    }
    // Call toString() method:
    List<? extends TypeMirror> typeArguments = Collections.emptyList();
    Method method;
    try {
        method = getConcreteMethod((ReferenceType) ov.type(), "toString", typeArguments);
    } catch (UnsuitableArgumentsException uaex) {
        throw new IllegalStateException(uaex);
    }
    ((ClassType) ov.type()).methodsByName("toString");
    List<Value> argVals = Collections.emptyList();
    Value sv = invokeMethod(arg0, method, false, null, ov, argVals, evaluationContext, false);
    if (sv instanceof StringReference) {
        return ((StringReference) sv).value();
    } else if (sv == null) {
        return null;
    } else {
        return "Result of toString() call on "+ov+" is not a String, but: "+sv; // NOI18N - should not ever happen.
    }
}
项目:openjdk-jdk10    文件:VirtualMachineImpl.java   
IntegerType theIntegerType() {
    if (theIntegerType == null) {
        synchronized(this) {
            if (theIntegerType == null) {
                theIntegerType = new IntegerTypeImpl(this);
            }
        }
    }
    return theIntegerType;
}
项目:form-follows-function    文件:F3Wrapper.java   
public static F3Type wrap(F3VirtualMachine f3vm, Type type) {
    if (type == null) {
        return null;
    }

    if (type instanceof VoidType) {
        return f3vm.voidType((VoidType)type);
    } else if (type instanceof PrimitiveType) {
        if (type instanceof BooleanType) {
            return f3vm.booleanType((BooleanType)type);
        } else if (type instanceof CharType) {
            return f3vm.charType((CharType)type);
        } else if (type instanceof ByteType) {
            return f3vm.byteType((ByteType)type);
        } else if (type instanceof ShortType) {
            return f3vm.shortType((ShortType)type);
        } else if (type instanceof IntegerType) {
            return f3vm.integerType((IntegerType)type);
        } else if (type instanceof LongType) {
            return f3vm.longType((LongType)type);
        } else if (type instanceof FloatType) {
            return f3vm.floatType((FloatType)type);
        } else if (type instanceof DoubleType) {
            return f3vm.doubleType((DoubleType)type);
        } else {
            throw new IllegalArgumentException("illegal primitive type : " + type);
        }
    } else if (type instanceof ReferenceType) {
        return wrap(f3vm, (ReferenceType)type);
    } else {
        throw new IllegalArgumentException("illegal type: " + type);
    }
}
项目:form-follows-function    文件:F3VirtualMachine.java   
protected Value defaultValue(Type type) {
    if (type instanceof BooleanType) {
        return booleanDefaultValue();
    }
    if (type instanceof ByteType) {
        return byteDefaultValue();
    }
    if (type instanceof CharType) {
        return charDefaultValue();
    }
    if (type instanceof DoubleType) {
        return doubleDefaultValue();
    }
    if (type instanceof FloatType) {
        return floatDefaultValue();
    }
    if (type instanceof IntegerType) {
        return integerDefaultValue();
    }
    if (type instanceof LongType) {
        return longDefaultValue();
    }
    if (type instanceof ShortType) {
        return shortDefaultValue();
    }
    // else it is an object/array/sequence/...
    return null;
}
项目:EclipseTracer    文件:VariableHistory.java   
public static AbstractBreakpointHistory createHistory(IJavaDebugTarget target,
        AbstractBreakpoint absBPoint, ObjectReference instance) {
    if (absBPoint instanceof Breakpoint) {
        return new LineBreakpointHistory(target, (Breakpoint)absBPoint, instance);
    }
    Watchpoint watchPoint = (Watchpoint)absBPoint;
    if (watchPoint.getJavaType() instanceof IntegerType) {
        return new NumericVariableHistory(target, watchPoint, instance);
    }
    else {
        return new VariableHistory(target, watchPoint, instance);
    }
}
项目:incubator-netbeans    文件:EvaluatorVisitor.java   
public static Value unbox(ObjectReference val, PrimitiveType type,
                          ThreadReference thread,
                          EvaluationContext context) throws InvalidTypeException,
                                                            ClassNotLoadedException,
                                                            IncompatibleThreadStateException,
                                                            InvocationException {
    ReferenceType rt = val.referenceType();
    String classType = rt.name();
    PrimitiveValue pv;
    if (classType.equals("java.lang.Boolean")) {
        pv = invokeUnboxingMethod(val, "booleanValue", thread, context);
    } else if (classType.equals("java.lang.Byte")) {
        pv = invokeUnboxingMethod(val, "byteValue", thread, context);
    } else if (classType.equals("java.lang.Character")) {
        pv = invokeUnboxingMethod(val, "charValue", thread, context);
    } else if (classType.equals("java.lang.Short")) {
        pv = invokeUnboxingMethod(val, "shortValue", thread, context);
    } else if (classType.equals("java.lang.Integer")) {
        pv = invokeUnboxingMethod(val, "intValue", thread, context);
    } else if (classType.equals("java.lang.Long")) {
        pv = invokeUnboxingMethod(val, "longValue", thread, context);
    } else if (classType.equals("java.lang.Float")) {
        pv = invokeUnboxingMethod(val, "floatValue", thread, context);
    } else if (classType.equals("java.lang.Double")) {
        pv = invokeUnboxingMethod(val, "doubleValue", thread, context);
    //throw new RuntimeException("Invalid type while unboxing: " + type.signature());    // never happens
    } else {
        return val;
    }
    VirtualMachine vm = pv.virtualMachine();
    if (type instanceof BooleanType && !(pv instanceof BooleanValue)) {
        return vm.mirrorOf(pv.booleanValue());
    }
    if (type instanceof ByteType && !(pv instanceof ByteValue)) {
        return vm.mirrorOf(pv.byteValue());
    }
    if (type instanceof CharType && !(pv instanceof CharValue)) {
        return vm.mirrorOf(pv.charValue());
    }
    if (type instanceof ShortType && !(pv instanceof ShortValue)) {
        return vm.mirrorOf(pv.shortValue());
    }
    if (type instanceof IntegerType && !(pv instanceof IntegerValue)) {
        return vm.mirrorOf(pv.intValue());
    }
    if (type instanceof LongType && !(pv instanceof LongValue)) {
        return vm.mirrorOf(pv.longValue());
    }
    if (type instanceof FloatType && !(pv instanceof FloatValue)) {
        return vm.mirrorOf(pv.floatValue());
    }
    if (type instanceof DoubleType && !(pv instanceof DoubleValue)) {
        return vm.mirrorOf(pv.doubleValue());
    }
    return pv;
}
项目:intellij-ce-playground    文件:AndroidTypedIntegerRenderer.java   
@Override
public boolean isApplicable(Type type) {
  return type != null && type instanceof IntegerType;
}
项目:form-follows-function    文件:F3IntegerType.java   
public F3IntegerType(F3VirtualMachine f3vm, IntegerType underlying) {
    super(f3vm, underlying);
}
项目:form-follows-function    文件:F3IntegerType.java   
@Override
protected IntegerType underlying() {
    return (IntegerType) super.underlying();
}
项目:form-follows-function    文件:F3VirtualMachine.java   
protected synchronized F3IntegerType integerType(IntegerType it) {
    if (integerType == null) {
        integerType = new F3IntegerType(this, it);
    }
    return integerType;
}
项目:form-follows-function    文件:VirtualMachineTest.java   
@Test
public void testPrimitiveTypes() {
    VirtualMachine vm = getVM();
    Type booleanType = vm.mirrorOf(false).type();
    Assert.assertEquals(true, booleanType instanceof BooleanType);
    Assert.assertEquals("boolean", booleanType.name());
    Assert.assertEquals("Z", booleanType.signature());

    Type charType = vm.mirrorOf('J').type();
    Assert.assertEquals(true, charType instanceof CharType);
    Assert.assertEquals("char", charType.name());
    Assert.assertEquals("C", charType.signature());

    Type byteType = vm.mirrorOf((byte)0).type();
    Assert.assertEquals(true, byteType instanceof ByteType);
    Assert.assertEquals("byte", byteType.name());
    Assert.assertEquals("B", byteType.signature());

    Type shortType = vm.mirrorOf((short)0).type();
    Assert.assertEquals(true, shortType instanceof ShortType);
    Assert.assertEquals("short", shortType.name());
    Assert.assertEquals("S", shortType.signature());

    Type integerType = vm.mirrorOf(0).type();
    Assert.assertEquals(true, integerType instanceof IntegerType);
    Assert.assertEquals("int", integerType.name());
    Assert.assertEquals("I", integerType.signature());

    Type longType = vm.mirrorOf(0L).type();
    Assert.assertEquals(true, longType instanceof LongType);
    Assert.assertEquals("long", longType.name());
    Assert.assertEquals("J", longType.signature());

    Type floatType = vm.mirrorOf(0.0F).type();
    Assert.assertEquals(true, floatType instanceof FloatType);
    Assert.assertEquals("float", floatType.name());
    Assert.assertEquals("F", floatType.signature());

    Type doubleType = vm.mirrorOf(0.0D).type();
    Assert.assertEquals(true, doubleType instanceof DoubleType);
    Assert.assertEquals("double", doubleType.name());
    Assert.assertEquals("D", doubleType.signature());

    ReferenceType stringType = vm.mirrorOf("JDI").referenceType();
    Assert.assertNotNull(stringType);
    Assert.assertEquals("java.lang.String", stringType.name());
    Assert.assertEquals("Ljava/lang/String;", stringType.signature());
}