Search in sources :

Example 91 with Symbol

use of com.sun.tools.javac.code.Symbol in project ceylon-compiler by ceylon.

the class Resolve method resolveOperator.

/** Resolve operator.
     *  @param pos       The position to use for error reporting.
     *  @param optag     The tag of the operation tree.
     *  @param env       The environment current at the operation.
     *  @param argtypes  The types of the operands.
     */
Symbol resolveOperator(DiagnosticPosition pos, int optag, Env<AttrContext> env, List<Type> argtypes) {
    Name name = treeinfo.operatorName(optag);
    Symbol sym = findMethod(env, syms.predefClass.type, name, argtypes, null, false, false, true);
    if (boxingEnabled && sym.kind >= WRONG_MTHS)
        sym = findMethod(env, syms.predefClass.type, name, argtypes, null, true, false, true);
    return access(sym, pos, env.enclClass.sym.type, name, false, argtypes, null);
}
Also used : Symbol(com.sun.tools.javac.code.Symbol)

Example 92 with Symbol

use of com.sun.tools.javac.code.Symbol in project ceylon-compiler by ceylon.

the class Resolve method resolveSelf.

/**
     * Resolve `c.name' where name == this or name == super.
     * @param pos           The position to use for error reporting.
     * @param env           The environment current at the expression.
     * @param c             The qualifier.
     * @param name          The identifier's name.
     */
Symbol resolveSelf(DiagnosticPosition pos, Env<AttrContext> env, TypeSymbol c, Name name) {
    Env<AttrContext> env1 = env;
    boolean staticOnly = false;
    while (env1.outer != null) {
        if (isStatic(env1))
            staticOnly = true;
        if (env1.enclClass.sym == c) {
            Symbol sym = env1.info.scope.lookup(name).sym;
            if (sym != null) {
                if (staticOnly)
                    sym = new StaticError(sym);
                return access(sym, pos, env.enclClass.sym.type, name, true);
            }
        }
        if ((env1.enclClass.sym.flags() & STATIC) != 0)
            staticOnly = true;
        env1 = env1.outer;
    }
    log.error(pos, "not.encl.class", c);
    return syms.errSymbol;
}
Also used : Symbol(com.sun.tools.javac.code.Symbol)

Example 93 with Symbol

use of com.sun.tools.javac.code.Symbol in project ceylon-compiler by ceylon.

the class Resolve method resolveMethod.

/** Resolve an unqualified method identifier.
     *  @param pos       The position to use for error reporting.
     *  @param env       The environment current at the method invocation.
     *  @param name      The identifier's name.
     *  @param argtypes  The types of the invocation's value arguments.
     *  @param typeargtypes  The types of the invocation's type arguments.
     */
Symbol resolveMethod(DiagnosticPosition pos, Env<AttrContext> env, Name name, List<Type> argtypes, List<Type> typeargtypes) {
    Symbol sym = startResolution();
    List<MethodResolutionPhase> steps = methodResolutionSteps;
    while (steps.nonEmpty() && steps.head.isApplicable(boxingEnabled, varargsEnabled) && sym.kind >= ERRONEOUS) {
        currentStep = steps.head;
        sym = findFun(env, name, argtypes, typeargtypes, steps.head.isBoxingRequired, env.info.varArgs = steps.head.isVarargsRequired);
        methodResolutionCache.put(steps.head, sym);
        steps = steps.tail;
    }
    if (sym.kind >= AMBIGUOUS) {
        //if nothing is found return the 'first' error
        MethodResolutionPhase errPhase = firstErroneousResolutionPhase();
        sym = access(methodResolutionCache.get(errPhase), pos, env.enclClass.sym.type, name, false, argtypes, typeargtypes);
        env.info.varArgs = errPhase.isVarargsRequired;
    }
    return sym;
}
Also used : MethodResolutionPhase(com.sun.tools.javac.comp.Resolve.MethodResolutionPhase) Symbol(com.sun.tools.javac.code.Symbol)

Example 94 with Symbol

use of com.sun.tools.javac.code.Symbol in project ceylon-compiler by ceylon.

the class Resolve method firstErroneousResolutionPhase.

private MethodResolutionPhase firstErroneousResolutionPhase() {
    MethodResolutionPhase bestSoFar = BASIC;
    Symbol sym = methodNotFound;
    List<MethodResolutionPhase> steps = methodResolutionSteps;
    while (steps.nonEmpty() && steps.head.isApplicable(boxingEnabled, varargsEnabled) && sym.kind >= WRONG_MTHS) {
        sym = methodResolutionCache.get(steps.head);
        bestSoFar = steps.head;
        steps = steps.tail;
    }
    return bestSoFar;
}
Also used : MethodResolutionPhase(com.sun.tools.javac.comp.Resolve.MethodResolutionPhase) Symbol(com.sun.tools.javac.code.Symbol)

Example 95 with Symbol

use of com.sun.tools.javac.code.Symbol in project ceylon-compiler by ceylon.

the class Resolve method resolveConstructor.

/** Resolve constructor.
     *  @param pos       The position to use for error reporting.
     *  @param env       The environment current at the constructor invocation.
     *  @param site      The type of class for which a constructor is searched.
     *  @param argtypes  The types of the constructor invocation's value
     *                   arguments.
     *  @param typeargtypes  The types of the constructor invocation's type
     *                   arguments.
     *  @param allowBoxing Allow boxing and varargs conversions.
     *  @param useVarargs Box trailing arguments into an array for varargs.
     */
Symbol resolveConstructor(DiagnosticPosition pos, Env<AttrContext> env, Type site, List<Type> argtypes, List<Type> typeargtypes, boolean allowBoxing, boolean useVarargs) {
    Symbol sym = findMethod(env, site, names.init, argtypes, typeargtypes, allowBoxing, useVarargs, false);
    chk.checkDeprecated(pos, env.info.scope.owner, sym);
    return sym;
}
Also used : Symbol(com.sun.tools.javac.code.Symbol)

Aggregations

Symbol (com.sun.tools.javac.code.Symbol)195 MethodSymbol (com.sun.tools.javac.code.Symbol.MethodSymbol)56 Type (com.sun.tools.javac.code.Type)54 ClassSymbol (com.sun.tools.javac.code.Symbol.ClassSymbol)53 VarSymbol (com.sun.tools.javac.code.Symbol.VarSymbol)45 TypeSymbol (com.sun.tools.javac.code.Symbol.TypeSymbol)36 PackageSymbol (com.sun.tools.javac.code.Symbol.PackageSymbol)29 JCTree (com.sun.tools.javac.tree.JCTree)28 ClassType (com.sun.tools.javac.code.Type.ClassType)18 Tree (com.sun.source.tree.Tree)17 ExpressionTree (com.sun.source.tree.ExpressionTree)15 DynamicMethodSymbol (com.sun.tools.javac.code.Symbol.DynamicMethodSymbol)15 OperatorSymbol (com.sun.tools.javac.code.Symbol.OperatorSymbol)15 ClassTree (com.sun.source.tree.ClassTree)14 MethodTree (com.sun.source.tree.MethodTree)14 Name (com.sun.tools.javac.util.Name)14 IdentifierTree (com.sun.source.tree.IdentifierTree)13 ArrayType (com.sun.tools.javac.code.Type.ArrayType)12 MethodType (com.sun.tools.javac.code.Type.MethodType)12 UnionClassType (com.sun.tools.javac.code.Type.UnionClassType)12