use of com.google.devtools.j2objc.types.ExecutablePair in project j2objc by google.
the class TreeConverter method convertSuperConstructorInvocation.
private static TreeNode convertSuperConstructorInvocation(org.eclipse.jdt.core.dom.SuperConstructorInvocation node) {
IMethodBinding binding = node.resolveConstructorBinding();
SuperConstructorInvocation newNode = new SuperConstructorInvocation().setExecutablePair(new ExecutablePair(BindingConverter.getExecutableElement(binding), BindingConverter.getType(binding))).setVarargsType(getVarargsType(binding, node.arguments()));
for (Object argument : node.arguments()) {
newNode.addArgument((Expression) convert(argument));
}
return newNode.setExpression((Expression) TreeConverter.convert(node.getExpression()));
}
use of com.google.devtools.j2objc.types.ExecutablePair in project j2objc by google.
the class TreeConverter method convertSuperMethodInvocation.
private static TreeNode convertSuperMethodInvocation(org.eclipse.jdt.core.dom.SuperMethodInvocation node) {
SuperMethodInvocation newNode = new SuperMethodInvocation();
convertExpression(node, newNode);
for (Object argument : node.arguments()) {
newNode.addArgument((Expression) TreeConverter.convert(argument));
}
IMethodBinding methodBinding = node.resolveMethodBinding();
return newNode.setExecutablePair(new ExecutablePair(BindingConverter.getExecutableElement(methodBinding), BindingConverter.getType(methodBinding))).setVarargsType(getVarargsType(methodBinding, node.arguments())).setQualifier((Name) TreeConverter.convert(node.getQualifier())).setName((SimpleName) TreeConverter.convert(node.getName()));
}
use of com.google.devtools.j2objc.types.ExecutablePair in project j2objc by google.
the class TreeConverter method convertMethodInvocation.
private static TreeNode convertMethodInvocation(org.eclipse.jdt.core.dom.MethodInvocation node) {
MethodInvocation newNode = new MethodInvocation();
convertExpression(node, newNode);
for (Object argument : node.arguments()) {
newNode.addArgument((Expression) TreeConverter.convert(argument));
}
IMethodBinding methodBinding = node.resolveMethodBinding();
return newNode.setExecutablePair(new ExecutablePair(BindingConverter.getExecutableElement(methodBinding), BindingConverter.getType(methodBinding))).setTypeMirror(BindingConverter.getType(node.resolveTypeBinding())).setName((SimpleName) TreeConverter.convert(node.getName())).setExpression((Expression) TreeConverter.convert(node.getExpression())).setVarargsType(getVarargsType(methodBinding, node.arguments()));
}
use of com.google.devtools.j2objc.types.ExecutablePair in project j2objc by google.
the class TreeConverter method convertClassInstanceCreation.
private static TreeNode convertClassInstanceCreation(org.eclipse.jdt.core.dom.ClassInstanceCreation node) {
ClassInstanceCreation newNode = new ClassInstanceCreation();
convertExpression(node, newNode);
for (Object argument : node.arguments()) {
newNode.addArgument((Expression) TreeConverter.convert(argument));
}
IMethodBinding binding = node.resolveConstructorBinding();
JdtExecutableElement element = (JdtExecutableElement) BindingConverter.getExecutableElement(binding);
JdtExecutableType type = BindingConverter.getType(binding);
newNode.setExecutablePair(new ExecutablePair(element, type)).setVarargsType(getVarargsType(binding, node.arguments())).setType((Type) TreeConverter.convert(node.getType()));
Expression expression = (Expression) TreeConverter.convert(node.getExpression());
org.eclipse.jdt.core.dom.AnonymousClassDeclaration anonymousClassDecl = node.getAnonymousClassDeclaration();
if (anonymousClassDecl != null && expression != null) {
VariableElement superOuterParam = GeneratedVariableElement.newParameter("superOuter$", expression.getTypeMirror(), element);
element.setSuperOuterParam(superOuterParam);
type.setSuperOuterParamType(superOuterParam.asType());
newNode.addArgument(0, expression);
} else {
newNode.setExpression(expression);
}
if (anonymousClassDecl != null) {
newNode.setAnonymousClassDeclaration(convertAnonymousClassDeclaration(anonymousClassDecl, element, binding));
}
return newNode;
}
use of com.google.devtools.j2objc.types.ExecutablePair in project j2objc by google.
the class ArrayRewriter method newMultiDimensionArrayInvocation.
private MethodInvocation newMultiDimensionArrayInvocation(ArrayType arrayType, List<Expression> dimensions, boolean retainedResult) {
assert dimensions.size() > 1;
TypeMirror componentType = arrayType;
for (int i = 0; i < dimensions.size(); i++) {
assert TypeUtil.isArray(componentType);
componentType = ((ArrayType) componentType).getComponentType();
}
TypeElement iosArrayElement = typeUtil.getIosArray(componentType);
ExecutableElement methodElement = getMultiDimensionMethod(componentType, iosArrayElement, retainedResult);
MethodInvocation invocation = new MethodInvocation(new ExecutablePair(methodElement), arrayType, new SimpleName(iosArrayElement));
// Add the dimension count argument.
invocation.addArgument(NumberLiteral.newIntLiteral(dimensions.size(), typeUtil));
// Create the dimensions array.
ArrayInitializer dimensionsArg = new ArrayInitializer(typeUtil.getArrayType(typeUtil.getInt()));
for (Expression e : dimensions) {
dimensionsArg.addExpression(e.copy());
}
invocation.addArgument(dimensionsArg);
if (!componentType.getKind().isPrimitive()) {
invocation.addArgument(new TypeLiteral(componentType, typeUtil));
}
return invocation;
}
Aggregations