private static ValueType[] convertSignature(Class<?>... signature) { ValueType[] types = new ValueType[signature.length]; for (int i = 0; i < types.length; ++i) { types[i] = ValueType.parse(signature[i]); } return types; }
public MethodDescriptor(String name, Class<?>... signature) { if (signature.length < 1) { throw new IllegalArgumentException("Signature must be at least 1 element length"); } this.name = name; this.signature = new ValueType[signature.length]; for (int i = 0; i < signature.length; ++i) { this.signature[i] = ValueType.parse(signature[i]); } }
public ValueType parseValueTypeCached(String value) { ValueType result = valueTypeParseCache.get(value); if (result == null) { result = getCached(ValueType.parse(value)); valueTypeParseCache.put(value, result); } return result; } }
private MethodDescriptor getDescriptor(Method method) { ValueType[] signature = Stream.concat(Arrays.stream(method.getParameterTypes()).map(ValueType::parse), Stream.of(ValueType.parse(method.getReturnType()))) .toArray(ValueType[]::new); return new MethodDescriptor(method.getName(), signature); }
public static MethodReference parse(Method method) { ValueType[] signature = Stream.concat(Arrays.stream(method.getParameterTypes()).map(ValueType::parse), Stream.of(ValueType.parse(method.getReturnType()))).toArray(ValueType[]::new); return new MethodReference(method.getDeclaringClass().getName(), method.getName(), signature); }
@SuppressWarnings("unchecked") public <T> ReflectClassImpl<T> findClass(Class<T> cls) { return (ReflectClassImpl<T>) getClass(ValueType.parse(cls)); }
public static ValueType[] parseManyIfPossible(String text) { List<ValueType> types = new ArrayList<>(); int index = 0; while (index < text.length()) { int nextIndex = cut(text, index); ValueType type = parse(text.substring(index, nextIndex)); if (type == null) { return null; } types.add(type); index = nextIndex; } return types.toArray(new ValueType[types.size()]); }
public ValueEmitter getField(Class<?> cls, String fieldName, Class<?> type) { return getField(cls.getName(), fieldName, ValueType.parse(type)); }
public ValueEmitter invoke(Class<?> cls, String methodName, Class<?> resultType, ValueEmitter... arguments) { return invoke(cls.getName(), methodName, ValueType.parse(resultType), arguments); }
public ValueEmitter constructArray(Class<?> type, int size) { return constructArray(ValueType.parse(type), size); }
public PhiEmitter phi(Class<?> cls) { return phi(ValueType.parse(cls)); }
public ValueEmitter assertIs(Class<?> type) { return assertIs(ValueType.parse(type)); }
public ValueEmitter getField(String name, Class<?> type) { return getField(name, ValueType.parse(type)); }
public static ValueType parse(Class<?> cls) { if (cls.isPrimitive()) { return primitiveMap.get(cls); } else if (cls.getComponentType() != null) { return ValueType.arrayOf(ValueType.parse(cls.getComponentType())); } else { return ValueType.object(cls.getName()); } }
private void convertParams(Object[] params) { for (int i = 0; i < params.length; ++i) { if (params[i] instanceof ReflectMethodImpl) { params[i] = ((ReflectMethodImpl) params[i]).method.getReference(); } else if (params[i] instanceof ReflectClassImpl) { params[i] = ((ReflectClassImpl<?>) params[i]).type; } else if (params[i] instanceof ReflectFieldImpl) { params[i] = ((ReflectFieldImpl) params[i]).field.getReference(); } else if (params[i] instanceof Class<?>) { params[i] = ValueType.parse((Class<?>) params[i]); } } }
private FieldHolder readField(DataInput input) throws IOException { FieldHolder field = new FieldHolder(symbolTable.at(input.readInt())); field.setType(ValueType.parse(symbolTable.at(input.readInt()))); field.setLevel(accessLevels[input.readByte()]); field.getModifiers().addAll(unpackModifiers(input.readInt())); field.setInitialValue(readFieldValue(input)); readAnnotations(input, field.getAnnotations()); return field; }
private void reachGetComponentType(DependencyAgent agent, MethodDependency method) { method.getVariable(0).getClassValueNode().addConsumer(t -> { if (!t.getName().startsWith("[")) { return; } String typeName = t.getName().substring(1); if (typeName.charAt(0) == 'L') { typeName = ((ValueType.Object) ValueType.parse(typeName)).getClassName(); } method.getResult().getClassValueNode().propagate(agent.getType(typeName)); }); }
private void addFunctorField(ClassHolder cls, MethodReference method) { if (cls.getAnnotations().get(FunctorImpl.class.getName()) != null) { return; } FieldHolder field = new FieldHolder("$$jso_functor$$"); field.setLevel(AccessLevel.PUBLIC); field.setType(ValueType.parse(JSObject.class)); cls.addField(field); AnnotationHolder annot = new AnnotationHolder(FunctorImpl.class.getName()); annot.getValues().put("value", new AnnotationValue(method.getDescriptor().toString())); cls.getAnnotations().add(annot); }
public FieldHolder parseField(FieldNode node) { FieldHolder field = new FieldHolder(referenceCache.getCached(node.name)); field.setType(referenceCache.getCached(ValueType.parse(node.desc))); field.setInitialValue(node.value); parseModifiers(node.access, field, DECL_FIELD); parseAnnotations(field.getAnnotations(), node.visibleAnnotations, node.invisibleAnnotations); return field; }
private MethodReference getAsyncReference(MethodReference methodRef) { ValueType[] signature = new ValueType[methodRef.parameterCount() + 2]; for (int i = 0; i < methodRef.parameterCount(); ++i) { signature[i] = methodRef.getDescriptor().parameterType(i); } signature[methodRef.parameterCount()] = ValueType.parse(AsyncCallback.class); signature[methodRef.parameterCount() + 1] = ValueType.VOID; return new MethodReference(methodRef.getClassName(), methodRef.getName(), signature); }