use of com.google.devtools.j2objc.ast.Expression 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.ast.Expression 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.ast.Expression in project j2objc by google.
the class TreeConverter method convertArrayCreation.
private static TreeNode convertArrayCreation(org.eclipse.jdt.core.dom.ArrayCreation node) {
ArrayCreation newNode = new ArrayCreation();
convertExpression(node, newNode);
List<Expression> dimensions = new ArrayList<>();
for (Object dimension : node.dimensions()) {
dimensions.add((Expression) convert(dimension));
}
return newNode.setType((ArrayType) convert(node.getType())).setDimensions(dimensions).setInitializer((ArrayInitializer) convert(node.getInitializer()));
}
use of com.google.devtools.j2objc.ast.Expression in project j2objc by google.
the class TreeConverter method convertArrayInitializer.
private static TreeNode convertArrayInitializer(org.eclipse.jdt.core.dom.ArrayInitializer node) {
List<Expression> expressions = new ArrayList<>();
for (Object expression : node.expressions()) {
expressions.add((Expression) convert(expression));
}
ArrayInitializer newNode = new ArrayInitializer();
convertExpression(node, newNode);
return newNode.setTypeMirror((JdtArrayType) BindingConverter.getType(node.resolveTypeBinding())).setExpressions(expressions);
}
use of com.google.devtools.j2objc.ast.Expression in project j2objc by google.
the class Functionizer method endVisit.
@Override
public void endVisit(MethodInvocation node) {
ExecutableElement element = node.getExecutableElement();
if (!ElementUtil.isStatic(element) && !functionizableMethods.contains(element)) {
return;
}
FunctionInvocation functionInvocation = new FunctionInvocation(newFunctionElement(element), node.getTypeMirror());
List<Expression> args = functionInvocation.getArguments();
TreeUtil.moveList(node.getArguments(), args);
if (!ElementUtil.isStatic(element)) {
Expression expr = node.getExpression();
if (expr == null) {
expr = new ThisExpression(TreeUtil.getEnclosingTypeElement(node).asType());
}
args.add(0, TreeUtil.remove(expr));
}
node.replaceWith(functionInvocation);
}
Aggregations