Examples of JCExpression


Examples of com.sun.tools.javac.tree.JCTree.JCExpression

                // Nothing to do for type variables.
                return type;
            } else if (type.getKind() == TypeKind.UNION) {
                // There is a TypeKind, but no TypeTag.
                JCTypeUnion tutree = (JCTypeUnion) typetree;
                JCExpression fst = tutree.alternatives.get(0);
                Type res = typeWithAnnotations(fst, fst.type, annotations, onlyTypeAnnotations);
                fst.type = res;
                // TODO: do we want to set res as first element in uct.alternatives?
                // UnionClassType uct = (com.sun.tools.javac.code.Type.UnionClassType)type;
                // Return the un-annotated union-type.
View Full Code Here

Examples of com.sun.tools.javac.tree.JCTree.JCExpression

            }

            // handle "free" annotations
            // int i = dimAnnosCount == 0 ? 0 : dimAnnosCount - 1;
            // TODO: is depth.size == i here?
            JCExpression elemType = tree.elemtype;
            depth = depth.append(TypePathEntry.ARRAY);
            while (elemType != null) {
                if (elemType.hasTag(JCTree.Tag.ANNOTATED_TYPE)) {
                    JCAnnotatedType at = (JCAnnotatedType)elemType;
                    TypeAnnotationPosition p = new TypeAnnotationPosition();
                    p.type = TargetType.NEW;
                    p.pos = tree.pos;
                    p.onLambda = currentLambda;
                    locateNestedTypes(elemType.type, p);
                    p.location = p.location.prependList(depth.toList());
                    setTypeAnnotationPos(at.annotations, p);
                    elemType = at.underlyingType;
                } else if (elemType.hasTag(JCTree.Tag.TYPEARRAY)) {
                    depth = depth.append(TypePathEntry.ARRAY);
                    elemType = ((JCArrayTypeTree)elemType).elemtype;
                } else if (elemType.hasTag(JCTree.Tag.SELECT)) {
                    elemType = ((JCFieldAccess)elemType).selected;
                } else {
                    break;
                }
            }
View Full Code Here

Examples of com.sun.tools.javac.tree.JCTree.JCExpression

        return false;
    }

    private JCExpression makeCurrentTime(TreeMaker maker, JavacElements utils, Time time) {
        // Создаём вызов System.nanoTime или System.currentTimeMillis
        JCExpression exp = maker.Ident(utils.getName("System"));
        String methodName;
        switch (time.interval()) {
            case NANOSECOND:
                methodName = "nanoTime";
                break;
View Full Code Here

Examples of com.sun.tools.javac.tree.JCTree.JCExpression

        return maker.Apply(List.<JCExpression>nil(), exp, List.<JCExpression>nil());
    }

    protected JCVariableDecl makeTimeStartVar(TreeMaker maker, JavacElements utils, Time time) {
        // Создаём финальную переменную для хранения времени старта. Имя переменной в виде time_start_{random}
        JCExpression currentTime = makeCurrentTime(maker, utils, time);
        String fieldName = fieldName = "time_start_" + (int) (Math.random() * 10000);
        return maker.VarDef(maker.Modifiers(Flags.FINAL), utils.getName(fieldName), maker.TypeIdent(TypeTags.LONG), currentTime);
    }
View Full Code Here

Examples of com.sun.tools.javac.tree.JCTree.JCExpression

    protected JCBlock makePrintBlock(TreeMaker maker, JavacElements utils, Time time, JCVariableDecl var) {
        // Создаём вызов System.out.println

        processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "making print expr");

        JCExpression printlnExpression = maker.Ident(utils.getName("System"));
        printlnExpression = maker.Select(printlnExpression, utils.getName("out"));
        printlnExpression = maker.Select(printlnExpression, utils.getName("println"));

        // Создаём блок вычисления затраченного времени (currentTime - startTime)
        JCExpression currentTime = makeCurrentTime(maker, utils, time);
        JCExpression elapsedTime = maker.Binary(JCTree.MINUS, currentTime, maker.Ident(var.name));

        // Форматируем результат
        JCExpression formatExpression = maker.Ident(utils.getName("String"));
        formatExpression = maker.Select(formatExpression, utils.getName("format"));

        // Собираем все кусочки вместе
        List<JCExpression> formatArgs = List.nil();
        formatArgs.append(maker.Literal(time.format()));
        formatArgs.append(elapsedTime);

        JCExpression format = maker.Apply(List.<JCExpression>nil(), formatExpression, formatArgs);

        List<JCExpression> printlnArgs = List.nil();
        printlnArgs.append(format);

        JCExpression print = maker.Apply(List.<JCExpression>nil(), printlnExpression, printlnArgs);
        JCExpressionStatement stmt = maker.Exec(print);

        List<JCStatement> stmts = List.nil();
        stmts.append(stmt);

        processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "print expr ready: " + print.toString());

        return maker.Block(0, stmts);
    }
View Full Code Here

Examples of com.sun.tools.javac.tree.JCTree.JCExpression

        }
        return tree;
    }

    private JCExpression cast(JCExpression newArg, final Type argType) {
        JCExpression castedNewArg;
        if(newArg instanceof JCMethodInvocation){
            castedNewArg = cast((JCMethodInvocation) newArg, argType);
        }else{
            castedNewArg = newArg;
        }
View Full Code Here

Examples of com.sun.tools.javac.tree.JCTree.JCExpression

        return castedNewArg;
    }

    private Scope getScope(Tree stmt, final CompilationUnitTree cut, Scope validScope) {
        if (stmt instanceof JCVariableDecl) {
            JCExpression exp = ((JCVariableDecl) stmt).init;
            ((JCVariableDecl) stmt).init = null;
            TreePath path = TreePath.getPath(cut, stmt);
            validScope = trees.getScope(path);
            ((JCVariableDecl) stmt).init = exp;
        } else if (stmt instanceof JCEnhancedForLoop) {
View Full Code Here

Examples of com.sun.tools.javac.tree.JCTree.JCExpression

        final StatementTree stmt = n.actual;
        if (stmt instanceof JCVariableDecl) {
            JCVariableDecl varDec = (JCVariableDecl) stmt;
            final boolean accessible = isAccessible(varDec, cut, n);
            if (!accessible) {
                JCExpression reflectedAccess = processCond(varDec.init, cut, n, encBlock);
                Symbol s = rs.getSymbol(reflectedAccess, cut, n);
                final Type t = getType(s);
                ((JCVariableDecl) stmt).init = null;
                varDec.sym = (VarSymbol) rs.getSymbol(cut, n, null, varDec.name, null);
                varDec.type = varDec.sym.type;
View Full Code Here

Examples of com.sun.tools.javac.tree.JCTree.JCExpression

            return fa;
        }

        Symbol s = rs.getSymbol(fa, cut, n);
        reflect(s, cut, n, null, encBlock);
        final JCExpression accessor;
        if (s.isStatic()) {
            accessor = tm.Literal(StringUtils.EMPTY);
        } else {
            accessor = fa.selected;
        }
View Full Code Here

Examples of com.sun.tools.javac.tree.JCTree.JCExpression

    protected JCExpression processCond(JCMethodInvocation mi, final CompilationUnitTree cut, Node n, JCBlock encBlock) {
        final MethodSymbol mSym = rs.getSymbol(mi, cut, n);
        if (!mi.args.isEmpty()) {
            for (JCExpression arg : mi.args) {
                final Type argType = rs.getType(arg, cut, n);
                JCExpression newArg = processCond(arg, cut, n, encBlock);
                if (!newArg.equals(arg)) {
                    final JCExpression castedNewArg;
                    castedNewArg = cast(newArg, argType);
                    mi.args = replace(arg, mi.args, castedNewArg);
                }
            }
        }
        Symbol accSym = rs.getInvokationTarget(mi, cut, n);
        final boolean accessible = isAccessible(mSym, accSym, cut, n);
        if (!accessible) {
            mi.type = mSym.getReturnType();
            reflect(mSym, cut, n, mi.args, encBlock);
            JCExpression accessor = rs.getInvokationExp(mi, cut, n);
            mi = getReflectedAccess(mSym, cut, accessor, mi.args, n);
        } else {
            mi.type = mSym.getReturnType();
        }
        return mi;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.