Package com.redhat.ceylon.compiler.typechecker.model

Examples of com.redhat.ceylon.compiler.typechecker.model.Scope


     * @param declaration
     * @return
     */
    JCExpression makeTypeParameterDeclaration(Node node,
            TypeParameter declaration) {
        Scope container = declaration.getContainer();
        if(container instanceof Declaration){
            JCExpression containerExpr;
            Declaration containerDeclaration = (Declaration) container;
            if(containerDeclaration instanceof ClassOrInterface
                    || containerDeclaration instanceof TypeAlias){
View Full Code Here


        JCExpression expr;
        at(param);
       
        if (Strategy.hasDefaultParameterValueMethod(param.getParameterModel())) {
            Tree.SpecifierOrInitializerExpression spec = Decl.getDefaultArgument(param);
            Scope container = param.getParameterModel().getModel().getContainer();
            boolean classParameter = container instanceof ClassOrInterface;
            ClassOrInterface oldWithinDefaultParameterExpression = withinDefaultParameterExpression;
            if(classParameter)
                withinDefaultParameterExpression((ClassOrInterface) container);
            if (param instanceof Tree.FunctionalParameterDeclaration) {
View Full Code Here

                        && builder.getPrimaryDeclaration().getContainer() instanceof Interface) {
                    // If the subclass is inner to an interface then it will be
                    // generated inner to the companion and we need to qualify the
                    // super(), *unless* the subclass is nested within the same
                    // interface as it's superclass.
                    Scope outer = builder.getSub().getContainer();
                    while (!(outer instanceof Package)) {
                        if (outer == builder.getPrimaryDeclaration().getContainer()) {
                            expr = naming.makeSuper();
                            break;
                        }
                        outer = outer.getContainer();
                    }
                    if (expr == null) {                   
                        Interface iface = (Interface)builder.getPrimaryDeclaration().getContainer();
                        JCExpression superQual;
                        if (Decl.getClassOrInterfaceContainer(classBuilder.getForDefinition(), false) instanceof Interface) {
View Full Code Here

                && !Decl.isLocalToInitializer(decl)
                && !isWithinSuperInvocation()) {
            // First check whether the expression is captured from an enclosing scope
            TypeDeclaration outer = null;
            // get the ClassOrInterface container of the declaration
            Scope stop = Decl.getClassOrInterfaceContainer(decl, false);
            if (stop instanceof TypeDeclaration) {// reified scope
                Scope scope = expr.getScope();
                while (!(scope instanceof Package)) {
                    if (scope.equals(stop)) {
                        outer = (TypeDeclaration)stop;
                        break;
                    }
                    scope = scope.getContainer();
                }
            }
            // If not it might be inherited...
            if (outer == null) {
                outer = expr.getScope().getInheritingDeclaration(decl);
View Full Code Here

            Tree.StaticMemberOrTypeExpression expr, Declaration decl,
            JCExpression qualExpr) {
        if (expr instanceof Tree.BaseMemberExpression
                && qualExpr == null
                && typeFact().getObjectDeclaration().equals(Decl.getClassOrInterfaceContainer(decl))) {
            Scope scope = expr.getScope();
            while (Decl.isLocalNotInitializerScope(scope)) {
                scope = scope.getContainer();
            }
            if (scope instanceof Interface) {
                qualExpr = naming.makeQuotedThis();
            }
        }
View Full Code Here

            // A functional parameter that's not method wrapped will already be Callable-wrapped
            return false;
        }
        // Optimization: If we're in a scope where the Callable field is visible
        // we don't need to create a method ref       
        Scope scope = expr.getScope();
        while (true) {
            if (scope instanceof Package) {
                break;
            }
            if (scope.equals(functionalParameter.getContainer())) {
                return false;
            }
            scope = scope.getContainer();
        }
        // Otherwise we do require an AbstractCallable.
        return true;
    }
View Full Code Here

    // Array access

    private JCExpression addInterfaceImplAccessorIfRequired(JCExpression qualExpr, Tree.StaticMemberOrTypeExpression expr, Declaration decl) {
        // Partial fix for https://github.com/ceylon/ceylon-compiler/issues/1023
        // For interfaces we sometimes need to access either the interface instance or its $impl class
        Scope declContainer = Decl.container(decl);
        if(qualExpr != null
                // this is only for interface containers
                && declContainer instanceof Interface
                // we only ever need the $impl if the declaration is not shared
                && !decl.isShared()){
View Full Code Here

    private JCExpression makeQualifiedDollarThis(Tree.BaseMemberExpression expr) {
        Declaration decl = expr.getDeclaration();
        Interface interf = (Interface) Decl.getClassOrInterfaceContainer(decl);
        // find the target container interface that is or satisfies the given interface
        Scope scope = expr.getScope();
        boolean needsQualified = false;
        while(scope != null){
            if(scope instanceof Interface){
                if(Decl.equalScopeDecl(scope, interf) || ((Interface)scope).inherits(interf)){
                    break;
                }
                // we only need to qualify it if we're aiming for a $this of an outer interface than the interface we are caught in
                needsQualified = true;
            }
            scope = scope.getContainer();
        }
        if(!needsQualified)
            return naming.makeQuotedThis();
        interf = (Interface) scope;
        return makeQualifiedDollarThis(interf.getType());
View Full Code Here

            final Declaration decl = expr.getDeclaration();
            if(!Decl.withinInterface(decl))
                return false;
           
            // Find the method/getter/setter where the expr is being used
            Scope scope = expr.getScope();
            while (scope != null && scope instanceof Interface == false) {
                scope = scope.getContainer();
            }
            // Is it being used in an interface (=> impl)
            if (scope instanceof Interface) {
                return decl.isShared();
            }
View Full Code Here

    //
    // Helper functions
   
    private boolean isRecursiveReference(Tree.StaticMemberOrTypeExpression expr) {
        Declaration decl = expr.getDeclaration();
        Scope s = expr.getScope();
        // do we have decl as our container anywhere in the scope?
        while (s != null && !Decl.equalScopeDecl(s, decl)) {
            s = s.getContainer();
        }
        return Decl.equalScopeDecl(s, decl);
    }
View Full Code Here

TOP

Related Classes of com.redhat.ceylon.compiler.typechecker.model.Scope

Copyright © 2018 www.massapicom. 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.