Search in sources :

Example 76 with Expression

use of com.google.devtools.j2objc.ast.Expression in project j2objc by google.

the class MethodTranslator method visitForEachStatement.

@Override
public TreeNode visitForEachStatement(ForEachStatement node, Void data) {
    EnhancedForStatement forStatement = new EnhancedForStatement();
    AstType astType = node.getVariableType();
    Type type = (Type) astType.acceptVisitor(this, null);
    String varName = node.getVariableName();
    GeneratedVariableElement elem = GeneratedVariableElement.newLocalVar(varName, type.getTypeMirror(), executableElement);
    elem.addModifiers(node.getVariableModifiers());
    localVariableTable.put(varName, elem);
    return forStatement.setParameter(new SingleVariableDeclaration(elem)).setExpression((Expression) node.getInExpression().acceptVisitor(this, null)).setBody((Statement) node.getEmbeddedStatement().acceptVisitor(this, null));
}
Also used : AstType(com.strobel.decompiler.languages.java.ast.AstType) ComposedType(com.strobel.decompiler.languages.java.ast.ComposedType) AstType(com.strobel.decompiler.languages.java.ast.AstType) Type(com.google.devtools.j2objc.ast.Type) SimpleType(com.google.devtools.j2objc.ast.SimpleType) DeclaredType(javax.lang.model.type.DeclaredType) ArrayType(com.google.devtools.j2objc.ast.ArrayType) WildcardType(com.strobel.decompiler.languages.java.ast.WildcardType) ExecutableType(javax.lang.model.type.ExecutableType) GeneratedVariableElement(com.google.devtools.j2objc.types.GeneratedVariableElement) SuperReferenceExpression(com.strobel.decompiler.languages.java.ast.SuperReferenceExpression) PostfixExpression(com.google.devtools.j2objc.ast.PostfixExpression) AnonymousObjectCreationExpression(com.strobel.decompiler.languages.java.ast.AnonymousObjectCreationExpression) Expression(com.google.devtools.j2objc.ast.Expression) TypeReferenceExpression(com.strobel.decompiler.languages.java.ast.TypeReferenceExpression) UnaryOperatorExpression(com.strobel.decompiler.languages.java.ast.UnaryOperatorExpression) ConditionalExpression(com.google.devtools.j2objc.ast.ConditionalExpression) BinaryOperatorExpression(com.strobel.decompiler.languages.java.ast.BinaryOperatorExpression) ClassOfExpression(com.strobel.decompiler.languages.java.ast.ClassOfExpression) ThisReferenceExpression(com.strobel.decompiler.languages.java.ast.ThisReferenceExpression) AssignmentExpression(com.strobel.decompiler.languages.java.ast.AssignmentExpression) InfixExpression(com.google.devtools.j2objc.ast.InfixExpression) PrimitiveExpression(com.strobel.decompiler.languages.java.ast.PrimitiveExpression) ParenthesizedExpression(com.google.devtools.j2objc.ast.ParenthesizedExpression) MemberReferenceExpression(com.strobel.decompiler.languages.java.ast.MemberReferenceExpression) PrefixExpression(com.google.devtools.j2objc.ast.PrefixExpression) ObjectCreationExpression(com.strobel.decompiler.languages.java.ast.ObjectCreationExpression) InvocationExpression(com.strobel.decompiler.languages.java.ast.InvocationExpression) ThisExpression(com.google.devtools.j2objc.ast.ThisExpression) ArrayCreationExpression(com.strobel.decompiler.languages.java.ast.ArrayCreationExpression) MethodGroupExpression(com.strobel.decompiler.languages.java.ast.MethodGroupExpression) IdentifierExpression(com.strobel.decompiler.languages.java.ast.IdentifierExpression) IndexerExpression(com.strobel.decompiler.languages.java.ast.IndexerExpression) NullReferenceExpression(com.strobel.decompiler.languages.java.ast.NullReferenceExpression) ArrayInitializerExpression(com.strobel.decompiler.languages.java.ast.ArrayInitializerExpression) VariableDeclarationExpression(com.google.devtools.j2objc.ast.VariableDeclarationExpression) SingleVariableDeclaration(com.google.devtools.j2objc.ast.SingleVariableDeclaration) EnhancedForStatement(com.google.devtools.j2objc.ast.EnhancedForStatement)

Example 77 with Expression

use of com.google.devtools.j2objc.ast.Expression in project j2objc by google.

the class MethodTranslator method visitConditionalExpression.

@Override
public TreeNode visitConditionalExpression(com.strobel.decompiler.languages.java.ast.ConditionalExpression node, Void data) {
    Expression conditionExpr = (Expression) node.getCondition().acceptVisitor(this, null);
    Expression trueExpr = (Expression) node.getTrueExpression().acceptVisitor(this, null);
    Expression falseExpr = (Expression) node.getFalseExpression().acceptVisitor(this, null);
    TypeMirror trueType = trueExpr.getTypeMirror();
    TypeMirror falseType = falseExpr.getTypeMirror();
    return new ConditionalExpression().setTypeMirror(typeUtil.inferConditionalExpressionType(trueType, falseType)).setExpression(conditionExpr).setThenExpression(trueExpr).setElseExpression(falseExpr);
}
Also used : SuperReferenceExpression(com.strobel.decompiler.languages.java.ast.SuperReferenceExpression) PostfixExpression(com.google.devtools.j2objc.ast.PostfixExpression) AnonymousObjectCreationExpression(com.strobel.decompiler.languages.java.ast.AnonymousObjectCreationExpression) Expression(com.google.devtools.j2objc.ast.Expression) TypeReferenceExpression(com.strobel.decompiler.languages.java.ast.TypeReferenceExpression) UnaryOperatorExpression(com.strobel.decompiler.languages.java.ast.UnaryOperatorExpression) ConditionalExpression(com.google.devtools.j2objc.ast.ConditionalExpression) BinaryOperatorExpression(com.strobel.decompiler.languages.java.ast.BinaryOperatorExpression) ClassOfExpression(com.strobel.decompiler.languages.java.ast.ClassOfExpression) ThisReferenceExpression(com.strobel.decompiler.languages.java.ast.ThisReferenceExpression) AssignmentExpression(com.strobel.decompiler.languages.java.ast.AssignmentExpression) InfixExpression(com.google.devtools.j2objc.ast.InfixExpression) PrimitiveExpression(com.strobel.decompiler.languages.java.ast.PrimitiveExpression) ParenthesizedExpression(com.google.devtools.j2objc.ast.ParenthesizedExpression) MemberReferenceExpression(com.strobel.decompiler.languages.java.ast.MemberReferenceExpression) PrefixExpression(com.google.devtools.j2objc.ast.PrefixExpression) ObjectCreationExpression(com.strobel.decompiler.languages.java.ast.ObjectCreationExpression) InvocationExpression(com.strobel.decompiler.languages.java.ast.InvocationExpression) ThisExpression(com.google.devtools.j2objc.ast.ThisExpression) ArrayCreationExpression(com.strobel.decompiler.languages.java.ast.ArrayCreationExpression) MethodGroupExpression(com.strobel.decompiler.languages.java.ast.MethodGroupExpression) IdentifierExpression(com.strobel.decompiler.languages.java.ast.IdentifierExpression) IndexerExpression(com.strobel.decompiler.languages.java.ast.IndexerExpression) NullReferenceExpression(com.strobel.decompiler.languages.java.ast.NullReferenceExpression) ArrayInitializerExpression(com.strobel.decompiler.languages.java.ast.ArrayInitializerExpression) VariableDeclarationExpression(com.google.devtools.j2objc.ast.VariableDeclarationExpression) TypeMirror(javax.lang.model.type.TypeMirror) ConditionalExpression(com.google.devtools.j2objc.ast.ConditionalExpression)

Example 78 with Expression

use of com.google.devtools.j2objc.ast.Expression in project j2objc by google.

the class MethodTranslator method visitBinaryOperatorExpression.

@Override
public TreeNode visitBinaryOperatorExpression(BinaryOperatorExpression node, Void data) {
    Expression leftExpr = (Expression) node.getLeft().acceptVisitor(this, null);
    Expression rightExpr = (Expression) node.getRight().acceptVisitor(this, null);
    InfixExpression binaryExpr = new InfixExpression().addOperand(leftExpr).addOperand(rightExpr);
    switch(node.getOperator()) {
        case BITWISE_AND:
            binaryExpr.setOperator(InfixExpression.Operator.AND).setTypeMirror(typeUtil.binaryNumericPromotion(leftExpr.getTypeMirror(), rightExpr.getTypeMirror()));
            break;
        case BITWISE_OR:
            binaryExpr.setOperator(InfixExpression.Operator.OR).setTypeMirror(typeUtil.binaryNumericPromotion(leftExpr.getTypeMirror(), rightExpr.getTypeMirror()));
            break;
        case EXCLUSIVE_OR:
            binaryExpr.setOperator(InfixExpression.Operator.XOR).setTypeMirror(typeUtil.binaryNumericPromotion(leftExpr.getTypeMirror(), rightExpr.getTypeMirror()));
            break;
        case LOGICAL_AND:
            binaryExpr.setOperator(InfixExpression.Operator.CONDITIONAL_AND).setTypeMirror(typeUtil.getBoolean());
            break;
        case LOGICAL_OR:
            binaryExpr.setOperator(InfixExpression.Operator.CONDITIONAL_OR).setTypeMirror(typeUtil.getBoolean());
            break;
        case GREATER_THAN:
            binaryExpr.setOperator(InfixExpression.Operator.GREATER).setTypeMirror(typeUtil.getBoolean());
            break;
        case GREATER_THAN_OR_EQUAL:
            binaryExpr.setOperator(InfixExpression.Operator.GREATER_EQUALS).setTypeMirror(typeUtil.getBoolean());
            break;
        case LESS_THAN:
            binaryExpr.setOperator(InfixExpression.Operator.LESS).setTypeMirror(typeUtil.getBoolean());
            break;
        case LESS_THAN_OR_EQUAL:
            binaryExpr.setOperator(InfixExpression.Operator.LESS_EQUALS).setTypeMirror(typeUtil.getBoolean());
            break;
        case EQUALITY:
            binaryExpr.setOperator(InfixExpression.Operator.EQUALS).setTypeMirror(typeUtil.getBoolean());
            break;
        case INEQUALITY:
            binaryExpr.setOperator(InfixExpression.Operator.NOT_EQUALS).setTypeMirror(typeUtil.getBoolean());
            break;
        case ADD:
            binaryExpr.setOperator(InfixExpression.Operator.PLUS).setTypeMirror(typeUtil.binaryNumericPromotion(leftExpr.getTypeMirror(), rightExpr.getTypeMirror()));
            break;
        case SUBTRACT:
            binaryExpr.setOperator(InfixExpression.Operator.MINUS).setTypeMirror(typeUtil.binaryNumericPromotion(leftExpr.getTypeMirror(), rightExpr.getTypeMirror()));
            break;
        case MULTIPLY:
            binaryExpr.setOperator(InfixExpression.Operator.TIMES).setTypeMirror(typeUtil.binaryNumericPromotion(leftExpr.getTypeMirror(), rightExpr.getTypeMirror()));
            break;
        case DIVIDE:
            binaryExpr.setOperator(InfixExpression.Operator.DIVIDE).setTypeMirror(typeUtil.binaryNumericPromotion(leftExpr.getTypeMirror(), rightExpr.getTypeMirror()));
            break;
        case MODULUS:
            binaryExpr.setOperator(InfixExpression.Operator.REMAINDER).setTypeMirror(typeUtil.binaryNumericPromotion(leftExpr.getTypeMirror(), rightExpr.getTypeMirror()));
            break;
        case SHIFT_LEFT:
            binaryExpr.setOperator(InfixExpression.Operator.LEFT_SHIFT).setTypeMirror(typeUtil.unaryNumericPromotion(leftExpr.getTypeMirror()));
            break;
        case SHIFT_RIGHT:
            binaryExpr.setOperator(InfixExpression.Operator.RIGHT_SHIFT_SIGNED).setTypeMirror(typeUtil.unaryNumericPromotion(leftExpr.getTypeMirror()));
            break;
        case UNSIGNED_SHIFT_RIGHT:
            binaryExpr.setOperator(InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED).setTypeMirror(typeUtil.unaryNumericPromotion(leftExpr.getTypeMirror()));
            break;
        default:
            throw new AssertionError("Unsupported infix operator: " + node.getOperator());
    }
    return binaryExpr;
}
Also used : SuperReferenceExpression(com.strobel.decompiler.languages.java.ast.SuperReferenceExpression) PostfixExpression(com.google.devtools.j2objc.ast.PostfixExpression) AnonymousObjectCreationExpression(com.strobel.decompiler.languages.java.ast.AnonymousObjectCreationExpression) Expression(com.google.devtools.j2objc.ast.Expression) TypeReferenceExpression(com.strobel.decompiler.languages.java.ast.TypeReferenceExpression) UnaryOperatorExpression(com.strobel.decompiler.languages.java.ast.UnaryOperatorExpression) ConditionalExpression(com.google.devtools.j2objc.ast.ConditionalExpression) BinaryOperatorExpression(com.strobel.decompiler.languages.java.ast.BinaryOperatorExpression) ClassOfExpression(com.strobel.decompiler.languages.java.ast.ClassOfExpression) ThisReferenceExpression(com.strobel.decompiler.languages.java.ast.ThisReferenceExpression) AssignmentExpression(com.strobel.decompiler.languages.java.ast.AssignmentExpression) InfixExpression(com.google.devtools.j2objc.ast.InfixExpression) PrimitiveExpression(com.strobel.decompiler.languages.java.ast.PrimitiveExpression) ParenthesizedExpression(com.google.devtools.j2objc.ast.ParenthesizedExpression) MemberReferenceExpression(com.strobel.decompiler.languages.java.ast.MemberReferenceExpression) PrefixExpression(com.google.devtools.j2objc.ast.PrefixExpression) ObjectCreationExpression(com.strobel.decompiler.languages.java.ast.ObjectCreationExpression) InvocationExpression(com.strobel.decompiler.languages.java.ast.InvocationExpression) ThisExpression(com.google.devtools.j2objc.ast.ThisExpression) ArrayCreationExpression(com.strobel.decompiler.languages.java.ast.ArrayCreationExpression) MethodGroupExpression(com.strobel.decompiler.languages.java.ast.MethodGroupExpression) IdentifierExpression(com.strobel.decompiler.languages.java.ast.IdentifierExpression) IndexerExpression(com.strobel.decompiler.languages.java.ast.IndexerExpression) NullReferenceExpression(com.strobel.decompiler.languages.java.ast.NullReferenceExpression) ArrayInitializerExpression(com.strobel.decompiler.languages.java.ast.ArrayInitializerExpression) VariableDeclarationExpression(com.google.devtools.j2objc.ast.VariableDeclarationExpression) InfixExpression(com.google.devtools.j2objc.ast.InfixExpression)

Example 79 with Expression

use of com.google.devtools.j2objc.ast.Expression in project j2objc by google.

the class MethodTranslator method visitArrayCreationExpression.

@Override
public TreeNode visitArrayCreationExpression(ArrayCreationExpression node, Void data) {
    Type baseType = (Type) node.getType().acceptVisitor(this, null);
    AstNodeCollection<com.strobel.decompiler.languages.java.ast.Expression> dimexprs = node.getDimensions();
    ArrayInitializerExpression init = node.getInitializer();
    ArrayType arrayType = new ArrayType(typeUtil.getArrayType(baseType.getTypeMirror(), dimexprs.size() + node.getAdditionalArraySpecifiers().size()));
    if (init.isNull()) {
        List<Expression> dimensions = dimexprs.stream().map(e -> (Expression) e.acceptVisitor(this, null)).collect(Collectors.toList());
        return new ArrayCreation().setType(arrayType).setDimensions(dimensions);
    } else {
        ArrayInitializer arrayInit = (ArrayInitializer) init.acceptVisitor(this, null);
        return new ArrayCreation().setType(arrayType).setInitializer(arrayInit.setTypeMirror(arrayType.getTypeMirror()));
    }
}
Also used : ArrayType(com.google.devtools.j2objc.ast.ArrayType) ComposedType(com.strobel.decompiler.languages.java.ast.ComposedType) TranslationUtil(com.google.devtools.j2objc.util.TranslationUtil) SuperReferenceExpression(com.strobel.decompiler.languages.java.ast.SuperReferenceExpression) PostfixExpression(com.google.devtools.j2objc.ast.PostfixExpression) TypeElement(javax.lang.model.element.TypeElement) AnonymousObjectCreationExpression(com.strobel.decompiler.languages.java.ast.AnonymousObjectCreationExpression) AstType(com.strobel.decompiler.languages.java.ast.AstType) Expression(com.google.devtools.j2objc.ast.Expression) ExpressionStatement(com.google.devtools.j2objc.ast.ExpressionStatement) ForStatement(com.google.devtools.j2objc.ast.ForStatement) Assignment(com.google.devtools.j2objc.ast.Assignment) EnhancedForStatement(com.google.devtools.j2objc.ast.EnhancedForStatement) BlockStatement(com.strobel.decompiler.languages.java.ast.BlockStatement) Map(java.util.Map) ElementUtil(com.google.devtools.j2objc.util.ElementUtil) BreakStatement(com.google.devtools.j2objc.ast.BreakStatement) ClassInstanceCreation(com.google.devtools.j2objc.ast.ClassInstanceCreation) ExecutablePair(com.google.devtools.j2objc.types.ExecutablePair) TranslationEnvironment(com.google.devtools.j2objc.util.TranslationEnvironment) TryCatchStatement(com.strobel.decompiler.languages.java.ast.TryCatchStatement) Element(javax.lang.model.element.Element) TypeReferenceExpression(com.strobel.decompiler.languages.java.ast.TypeReferenceExpression) ContinueStatement(com.google.devtools.j2objc.ast.ContinueStatement) IfElseStatement(com.strobel.decompiler.languages.java.ast.IfElseStatement) UnaryOperatorExpression(com.strobel.decompiler.languages.java.ast.UnaryOperatorExpression) MethodInvocation(com.google.devtools.j2objc.ast.MethodInvocation) CaseLabel(com.strobel.decompiler.languages.java.ast.CaseLabel) ImportDeclaration(com.strobel.decompiler.languages.java.ast.ImportDeclaration) ConditionalExpression(com.google.devtools.j2objc.ast.ConditionalExpression) Type(com.google.devtools.j2objc.ast.Type) BinaryOperatorExpression(com.strobel.decompiler.languages.java.ast.BinaryOperatorExpression) TreeUtil(com.google.devtools.j2objc.ast.TreeUtil) TreeNode(com.google.devtools.j2objc.ast.TreeNode) ConstructorInvocation(com.google.devtools.j2objc.ast.ConstructorInvocation) VariableElement(javax.lang.model.element.VariableElement) VariableDeclarationFragment(com.google.devtools.j2objc.ast.VariableDeclarationFragment) IAstVisitor(com.strobel.decompiler.languages.java.ast.IAstVisitor) ArrayList(java.util.ArrayList) SimpleType(com.google.devtools.j2objc.ast.SimpleType) DoStatement(com.google.devtools.j2objc.ast.DoStatement) InstanceInitializer(com.strobel.decompiler.languages.java.ast.InstanceInitializer) FieldAccess(com.google.devtools.j2objc.ast.FieldAccess) DeclaredType(javax.lang.model.type.DeclaredType) VariableDeclarationStatement(com.google.devtools.j2objc.ast.VariableDeclarationStatement) WhileStatement(com.google.devtools.j2objc.ast.WhileStatement) SimpleName(com.google.devtools.j2objc.ast.SimpleName) ClassOfExpression(com.strobel.decompiler.languages.java.ast.ClassOfExpression) VariableInitializer(com.strobel.decompiler.languages.java.ast.VariableInitializer) TypeReference(com.strobel.assembler.metadata.TypeReference) ArrayAccess(com.google.devtools.j2objc.ast.ArrayAccess) Block(com.google.devtools.j2objc.ast.Block) Statement(com.google.devtools.j2objc.ast.Statement) ThisReferenceExpression(com.strobel.decompiler.languages.java.ast.ThisReferenceExpression) AssignmentExpression(com.strobel.decompiler.languages.java.ast.AssignmentExpression) Pattern(com.strobel.decompiler.patterns.Pattern) ArrayType(com.google.devtools.j2objc.ast.ArrayType) InfixExpression(com.google.devtools.j2objc.ast.InfixExpression) GotoStatement(com.strobel.decompiler.languages.java.ast.GotoStatement) ParameterDeclaration(com.strobel.decompiler.languages.java.ast.ParameterDeclaration) PrimitiveExpression(com.strobel.decompiler.languages.java.ast.PrimitiveExpression) ParenthesizedExpression(com.google.devtools.j2objc.ast.ParenthesizedExpression) MemberReferenceExpression(com.strobel.decompiler.languages.java.ast.MemberReferenceExpression) GeneratedVariableElement(com.google.devtools.j2objc.types.GeneratedVariableElement) PrefixExpression(com.google.devtools.j2objc.ast.PrefixExpression) ObjectCreationExpression(com.strobel.decompiler.languages.java.ast.ObjectCreationExpression) InvocationExpression(com.strobel.decompiler.languages.java.ast.InvocationExpression) DoWhileStatement(com.strobel.decompiler.languages.java.ast.DoWhileStatement) AstNodeCollection(com.strobel.decompiler.languages.java.ast.AstNodeCollection) SingleVariableDeclaration(com.google.devtools.j2objc.ast.SingleVariableDeclaration) ThisExpression(com.google.devtools.j2objc.ast.ThisExpression) ArrayCreationExpression(com.strobel.decompiler.languages.java.ast.ArrayCreationExpression) Collectors(java.util.stream.Collectors) List(java.util.List) MethodGroupExpression(com.strobel.decompiler.languages.java.ast.MethodGroupExpression) ArrayInitializer(com.google.devtools.j2objc.ast.ArrayInitializer) IdentifierExpression(com.strobel.decompiler.languages.java.ast.IdentifierExpression) AbstractTypeDeclaration(com.google.devtools.j2objc.ast.AbstractTypeDeclaration) ErrorUtil(com.google.devtools.j2objc.util.ErrorUtil) AstNode(com.strobel.decompiler.languages.java.ast.AstNode) EnumValueDeclaration(com.strobel.decompiler.languages.java.ast.EnumValueDeclaration) NewLineNode(com.strobel.decompiler.languages.java.ast.NewLineNode) HashSet(java.util.HashSet) IndexerExpression(com.strobel.decompiler.languages.java.ast.IndexerExpression) WildcardType(com.strobel.decompiler.languages.java.ast.WildcardType) TextNode(com.strobel.decompiler.languages.java.ast.TextNode) StringUtilities(com.strobel.core.StringUtilities) Keys(com.strobel.decompiler.languages.java.ast.Keys) IfStatement(com.google.devtools.j2objc.ast.IfStatement) NullLiteral(com.google.devtools.j2objc.ast.NullLiteral) ElementKind(javax.lang.model.element.ElementKind) ExecutableType(javax.lang.model.type.ExecutableType) ArraySpecifier(com.strobel.decompiler.languages.java.ast.ArraySpecifier) SwitchSection(com.strobel.decompiler.languages.java.ast.SwitchSection) TypeParameterDeclaration(com.strobel.decompiler.languages.java.ast.TypeParameterDeclaration) NullReferenceExpression(com.strobel.decompiler.languages.java.ast.NullReferenceExpression) ExecutableElement(javax.lang.model.element.ExecutableElement) ConstructorDeclaration(com.strobel.decompiler.languages.java.ast.ConstructorDeclaration) ArrayInitializerExpression(com.strobel.decompiler.languages.java.ast.ArrayInitializerExpression) JavaTokenNode(com.strobel.decompiler.languages.java.ast.JavaTokenNode) Consumer(java.util.function.Consumer) ReturnStatement(com.google.devtools.j2objc.ast.ReturnStatement) VariableDeclarationExpression(com.google.devtools.j2objc.ast.VariableDeclarationExpression) MethodReference(com.strobel.assembler.metadata.MethodReference) TypeMirror(javax.lang.model.type.TypeMirror) SourcePosition(com.google.devtools.j2objc.ast.SourcePosition) ArrayCreation(com.google.devtools.j2objc.ast.ArrayCreation) TypeUtil(com.google.devtools.j2objc.util.TypeUtil) SuperConstructorInvocation(com.google.devtools.j2objc.ast.SuperConstructorInvocation) ForEachStatement(com.strobel.decompiler.languages.java.ast.ForEachStatement) ComposedType(com.strobel.decompiler.languages.java.ast.ComposedType) AstType(com.strobel.decompiler.languages.java.ast.AstType) Type(com.google.devtools.j2objc.ast.Type) SimpleType(com.google.devtools.j2objc.ast.SimpleType) DeclaredType(javax.lang.model.type.DeclaredType) ArrayType(com.google.devtools.j2objc.ast.ArrayType) WildcardType(com.strobel.decompiler.languages.java.ast.WildcardType) ExecutableType(javax.lang.model.type.ExecutableType) SuperReferenceExpression(com.strobel.decompiler.languages.java.ast.SuperReferenceExpression) PostfixExpression(com.google.devtools.j2objc.ast.PostfixExpression) AnonymousObjectCreationExpression(com.strobel.decompiler.languages.java.ast.AnonymousObjectCreationExpression) Expression(com.google.devtools.j2objc.ast.Expression) TypeReferenceExpression(com.strobel.decompiler.languages.java.ast.TypeReferenceExpression) UnaryOperatorExpression(com.strobel.decompiler.languages.java.ast.UnaryOperatorExpression) ConditionalExpression(com.google.devtools.j2objc.ast.ConditionalExpression) BinaryOperatorExpression(com.strobel.decompiler.languages.java.ast.BinaryOperatorExpression) ClassOfExpression(com.strobel.decompiler.languages.java.ast.ClassOfExpression) ThisReferenceExpression(com.strobel.decompiler.languages.java.ast.ThisReferenceExpression) AssignmentExpression(com.strobel.decompiler.languages.java.ast.AssignmentExpression) InfixExpression(com.google.devtools.j2objc.ast.InfixExpression) PrimitiveExpression(com.strobel.decompiler.languages.java.ast.PrimitiveExpression) ParenthesizedExpression(com.google.devtools.j2objc.ast.ParenthesizedExpression) MemberReferenceExpression(com.strobel.decompiler.languages.java.ast.MemberReferenceExpression) PrefixExpression(com.google.devtools.j2objc.ast.PrefixExpression) ObjectCreationExpression(com.strobel.decompiler.languages.java.ast.ObjectCreationExpression) InvocationExpression(com.strobel.decompiler.languages.java.ast.InvocationExpression) ThisExpression(com.google.devtools.j2objc.ast.ThisExpression) ArrayCreationExpression(com.strobel.decompiler.languages.java.ast.ArrayCreationExpression) MethodGroupExpression(com.strobel.decompiler.languages.java.ast.MethodGroupExpression) IdentifierExpression(com.strobel.decompiler.languages.java.ast.IdentifierExpression) IndexerExpression(com.strobel.decompiler.languages.java.ast.IndexerExpression) NullReferenceExpression(com.strobel.decompiler.languages.java.ast.NullReferenceExpression) ArrayInitializerExpression(com.strobel.decompiler.languages.java.ast.ArrayInitializerExpression) VariableDeclarationExpression(com.google.devtools.j2objc.ast.VariableDeclarationExpression) ArrayCreation(com.google.devtools.j2objc.ast.ArrayCreation) ArrayInitializerExpression(com.strobel.decompiler.languages.java.ast.ArrayInitializerExpression) ArrayInitializer(com.google.devtools.j2objc.ast.ArrayInitializer)

Example 80 with Expression

use of com.google.devtools.j2objc.ast.Expression in project j2objc by google.

the class MethodTranslator method visitMemberReferenceExpression.

@Override
public TreeNode visitMemberReferenceExpression(MemberReferenceExpression node, Void data) {
    Expression qualifier = (Expression) node.getFirstChild().acceptVisitor(this, null);
    TypeElement owner = (TypeElement) ((DeclaredType) qualifier.getTypeMirror()).asElement();
    VariableElement field = ElementUtil.findField(owner, node.getMemberName());
    if (field != null) {
        return new FieldAccess(field, qualifier);
    }
    throw new AssertionError("not implemented");
}
Also used : SuperReferenceExpression(com.strobel.decompiler.languages.java.ast.SuperReferenceExpression) PostfixExpression(com.google.devtools.j2objc.ast.PostfixExpression) AnonymousObjectCreationExpression(com.strobel.decompiler.languages.java.ast.AnonymousObjectCreationExpression) Expression(com.google.devtools.j2objc.ast.Expression) TypeReferenceExpression(com.strobel.decompiler.languages.java.ast.TypeReferenceExpression) UnaryOperatorExpression(com.strobel.decompiler.languages.java.ast.UnaryOperatorExpression) ConditionalExpression(com.google.devtools.j2objc.ast.ConditionalExpression) BinaryOperatorExpression(com.strobel.decompiler.languages.java.ast.BinaryOperatorExpression) ClassOfExpression(com.strobel.decompiler.languages.java.ast.ClassOfExpression) ThisReferenceExpression(com.strobel.decompiler.languages.java.ast.ThisReferenceExpression) AssignmentExpression(com.strobel.decompiler.languages.java.ast.AssignmentExpression) InfixExpression(com.google.devtools.j2objc.ast.InfixExpression) PrimitiveExpression(com.strobel.decompiler.languages.java.ast.PrimitiveExpression) ParenthesizedExpression(com.google.devtools.j2objc.ast.ParenthesizedExpression) MemberReferenceExpression(com.strobel.decompiler.languages.java.ast.MemberReferenceExpression) PrefixExpression(com.google.devtools.j2objc.ast.PrefixExpression) ObjectCreationExpression(com.strobel.decompiler.languages.java.ast.ObjectCreationExpression) InvocationExpression(com.strobel.decompiler.languages.java.ast.InvocationExpression) ThisExpression(com.google.devtools.j2objc.ast.ThisExpression) ArrayCreationExpression(com.strobel.decompiler.languages.java.ast.ArrayCreationExpression) MethodGroupExpression(com.strobel.decompiler.languages.java.ast.MethodGroupExpression) IdentifierExpression(com.strobel.decompiler.languages.java.ast.IdentifierExpression) IndexerExpression(com.strobel.decompiler.languages.java.ast.IndexerExpression) NullReferenceExpression(com.strobel.decompiler.languages.java.ast.NullReferenceExpression) ArrayInitializerExpression(com.strobel.decompiler.languages.java.ast.ArrayInitializerExpression) VariableDeclarationExpression(com.google.devtools.j2objc.ast.VariableDeclarationExpression) TypeElement(javax.lang.model.element.TypeElement) VariableElement(javax.lang.model.element.VariableElement) GeneratedVariableElement(com.google.devtools.j2objc.types.GeneratedVariableElement) FieldAccess(com.google.devtools.j2objc.ast.FieldAccess)

Aggregations

Expression (com.google.devtools.j2objc.ast.Expression)139 InfixExpression (com.google.devtools.j2objc.ast.InfixExpression)103 ParenthesizedExpression (com.google.devtools.j2objc.ast.ParenthesizedExpression)95 PrefixExpression (com.google.devtools.j2objc.ast.PrefixExpression)89 ConditionalExpression (com.google.devtools.j2objc.ast.ConditionalExpression)78 CastExpression (com.google.devtools.j2objc.ast.CastExpression)70 PostfixExpression (com.google.devtools.j2objc.ast.PostfixExpression)70 ThisExpression (com.google.devtools.j2objc.ast.ThisExpression)64 VariableDeclarationExpression (com.google.devtools.j2objc.ast.VariableDeclarationExpression)58 InstanceofExpression (com.google.devtools.j2objc.ast.InstanceofExpression)45 TypeMirror (javax.lang.model.type.TypeMirror)41 VariableElement (javax.lang.model.element.VariableElement)40 LambdaExpression (com.google.devtools.j2objc.ast.LambdaExpression)36 CommaExpression (com.google.devtools.j2objc.ast.CommaExpression)34 SimpleName (com.google.devtools.j2objc.ast.SimpleName)29 FunctionalExpression (com.google.devtools.j2objc.ast.FunctionalExpression)24 FunctionInvocation (com.google.devtools.j2objc.ast.FunctionInvocation)22 NativeExpression (com.google.devtools.j2objc.ast.NativeExpression)22 GeneratedVariableElement (com.google.devtools.j2objc.types.GeneratedVariableElement)22 TypeElement (javax.lang.model.element.TypeElement)21