Search in sources :

Example 1 with Type

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

the class TreeConverter method convertCastExpression.

private static TreeNode convertCastExpression(org.eclipse.jdt.core.dom.CastExpression node) {
    CastExpression newNode = new CastExpression();
    convertExpression(node, newNode);
    return newNode.setType((Type) convert(node.getType())).setExpression((Expression) convert(node.getExpression()));
}
Also used : ParameterizedType(com.google.devtools.j2objc.ast.ParameterizedType) QualifiedType(com.google.devtools.j2objc.ast.QualifiedType) AnnotatableType(com.google.devtools.j2objc.ast.AnnotatableType) Type(com.google.devtools.j2objc.ast.Type) NameQualifiedType(com.google.devtools.j2objc.ast.NameQualifiedType) SimpleType(com.google.devtools.j2objc.ast.SimpleType) DeclaredType(javax.lang.model.type.DeclaredType) ArrayType(com.google.devtools.j2objc.ast.ArrayType) PrimitiveType(com.google.devtools.j2objc.ast.PrimitiveType) IntersectionType(com.google.devtools.j2objc.ast.IntersectionType) UnionType(com.google.devtools.j2objc.ast.UnionType) ExecutableType(javax.lang.model.type.ExecutableType) CastExpression(com.google.devtools.j2objc.ast.CastExpression)

Example 2 with Type

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

the class TreeConverter method convertVariableExpression.

private VariableDeclarationExpression convertVariableExpression(JCTree.JCVariableDecl node) {
    VarSymbol var = node.sym;
    boolean isVarargs = (node.sym.flags() & Flags.VARARGS) > 0;
    Type newType = convertType(var.asType(), getPosition(node), isVarargs);
    VariableDeclarationFragment fragment = new VariableDeclarationFragment();
    fragment.setVariableElement(var).setInitializer((Expression) convert(node.getInitializer()));
    return new VariableDeclarationExpression().setType(newType).addFragment(fragment);
}
Also used : ParameterizedType(com.google.devtools.j2objc.ast.ParameterizedType) 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) PrimitiveType(com.google.devtools.j2objc.ast.PrimitiveType) UnionType(com.google.devtools.j2objc.ast.UnionType) ExecutableType(javax.lang.model.type.ExecutableType) VariableDeclarationFragment(com.google.devtools.j2objc.ast.VariableDeclarationFragment) VariableDeclarationExpression(com.google.devtools.j2objc.ast.VariableDeclarationExpression) VarSymbol(com.sun.tools.javac.code.Symbol.VarSymbol)

Example 3 with Type

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

the class TreeConverter method convertSingleVariable.

private TreeNode convertSingleVariable(JCTree.JCVariableDecl node) {
    VarSymbol var = node.sym;
    SourcePosition pos = getPosition(node);
    boolean isVarargs = (node.sym.flags() & Flags.VARARGS) > 0;
    Type newType = convertType(var.asType(), pos, isVarargs);
    return new SingleVariableDeclaration().setType(newType).setIsVarargs(isVarargs).setAnnotations(convertAnnotations(node.getModifiers())).setVariableElement(var).setInitializer((Expression) convert(node.getInitializer()));
}
Also used : ParameterizedType(com.google.devtools.j2objc.ast.ParameterizedType) 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) PrimitiveType(com.google.devtools.j2objc.ast.PrimitiveType) UnionType(com.google.devtools.j2objc.ast.UnionType) ExecutableType(javax.lang.model.type.ExecutableType) SingleVariableDeclaration(com.google.devtools.j2objc.ast.SingleVariableDeclaration) SourcePosition(com.google.devtools.j2objc.ast.SourcePosition) VarSymbol(com.sun.tools.javac.code.Symbol.VarSymbol)

Example 4 with Type

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

the class TreeConverter method convertArrayType.

private TreeNode convertArrayType(JCTree.JCArrayTypeTree node) {
    ArrayType newNode = new ArrayType();
    Type componentType = (Type) Type.newType(node.getType().type);
    return newNode.setComponentType(componentType).setTypeMirror(node.type);
}
Also used : ArrayType(com.google.devtools.j2objc.ast.ArrayType) ParameterizedType(com.google.devtools.j2objc.ast.ParameterizedType) 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) PrimitiveType(com.google.devtools.j2objc.ast.PrimitiveType) UnionType(com.google.devtools.j2objc.ast.UnionType) ExecutableType(javax.lang.model.type.ExecutableType)

Example 5 with Type

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

the class OuterReferenceResolver method endVisit.

@Override
public void endVisit(CreationReference node) {
    Type typeNode = node.getType();
    TypeMirror creationType = typeNode.getTypeMirror();
    if (TypeUtil.isArray(creationType)) {
        // Nothing to capture for array creations.
        return;
    }
    TypeElement lambdaType = node.getTypeElement();
    pushType(lambdaType);
    // This is kind of messy, but we use the Type child node as the key for capture scope to be
    // transferred to the inner ClassInstanceCreation. The capture scope of the CreationReference
    // node will be transferred to the ClassInstanceCreation that creates the lambda instance.
    TypeElement creationElement = TypeUtil.asTypeElement(creationType);
    whenNeedsOuterParam(creationElement, () -> {
        TypeElement enclosingTypeElement = ElementUtil.getDeclaringClass(creationElement);
        node.setCreationOuterArg(getOuterPathInherited(enclosingTypeElement));
    });
    if (ElementUtil.isLocal(creationElement)) {
        onExitScope(creationElement, () -> {
            addCaptureArgs(creationElement, node.getCreationCaptureArgs());
        });
    }
    popType();
    endVisitFunctionalExpression(node);
}
Also used : Type(com.google.devtools.j2objc.ast.Type) TypeMirror(javax.lang.model.type.TypeMirror) TypeElement(javax.lang.model.element.TypeElement)

Aggregations

Type (com.google.devtools.j2objc.ast.Type)8 ArrayType (com.google.devtools.j2objc.ast.ArrayType)7 PrimitiveType (com.google.devtools.j2objc.ast.PrimitiveType)7 SimpleType (com.google.devtools.j2objc.ast.SimpleType)7 UnionType (com.google.devtools.j2objc.ast.UnionType)7 ParameterizedType (com.google.devtools.j2objc.ast.ParameterizedType)6 DeclaredType (javax.lang.model.type.DeclaredType)6 ExecutableType (javax.lang.model.type.ExecutableType)6 IntersectionType (com.google.devtools.j2objc.ast.IntersectionType)4 NameQualifiedType (com.google.devtools.j2objc.ast.NameQualifiedType)4 QualifiedType (com.google.devtools.j2objc.ast.QualifiedType)4 AnnotatableType (com.google.devtools.j2objc.ast.AnnotatableType)3 SingleVariableDeclaration (com.google.devtools.j2objc.ast.SingleVariableDeclaration)3 VarSymbol (com.sun.tools.javac.code.Symbol.VarSymbol)2 Annotation (com.google.devtools.j2objc.ast.Annotation)1 CastExpression (com.google.devtools.j2objc.ast.CastExpression)1 MarkerAnnotation (com.google.devtools.j2objc.ast.MarkerAnnotation)1 NormalAnnotation (com.google.devtools.j2objc.ast.NormalAnnotation)1 PropertyAnnotation (com.google.devtools.j2objc.ast.PropertyAnnotation)1 SingleMemberAnnotation (com.google.devtools.j2objc.ast.SingleMemberAnnotation)1