Search in sources :

Example 91 with Scope

use of org.eclipse.ceylon.model.typechecker.model.Scope in project ceylon by eclipse.

the class DeclarationVisitor method visit.

@Override
public void visit(Tree.TypeAliasDeclaration that) {
    TypeAlias a = new TypeAlias();
    that.setDeclarationModel(a);
    visitDeclaration(that, a);
    Scope o = enterScope(a);
    super.visit(that);
    exitScope(o);
}
Also used : Scope(org.eclipse.ceylon.model.typechecker.model.Scope) ConditionScope(org.eclipse.ceylon.model.typechecker.model.ConditionScope) ModelUtil.getRealScope(org.eclipse.ceylon.model.typechecker.model.ModelUtil.getRealScope) TypeAlias(org.eclipse.ceylon.model.typechecker.model.TypeAlias)

Example 92 with Scope

use of org.eclipse.ceylon.model.typechecker.model.Scope in project ceylon by eclipse.

the class DeclarationVisitor method visit.

@Override
public void visit(Tree.SwitchExpression that) {
    ControlBlock cb = new ControlBlock();
    cb.setId(id++);
    visitElement(that, cb);
    Scope o = enterScope(cb);
    super.visit(that);
    exitScope(o);
}
Also used : ControlBlock(org.eclipse.ceylon.model.typechecker.model.ControlBlock) Scope(org.eclipse.ceylon.model.typechecker.model.Scope) ConditionScope(org.eclipse.ceylon.model.typechecker.model.ConditionScope) ModelUtil.getRealScope(org.eclipse.ceylon.model.typechecker.model.ModelUtil.getRealScope)

Example 93 with Scope

use of org.eclipse.ceylon.model.typechecker.model.Scope in project ceylon by eclipse.

the class DeclarationVisitor method visit.

@Override
public void visit(Tree.ControlClause that) {
    ControlBlock cb = new ControlBlock();
    cb.setLet(that instanceof Tree.LetClause);
    cb.setId(id++);
    that.setControlBlock(cb);
    visitElement(that, cb);
    Scope o = enterScope(cb);
    super.visit(that);
    exitScope(o);
}
Also used : ControlBlock(org.eclipse.ceylon.model.typechecker.model.ControlBlock) Scope(org.eclipse.ceylon.model.typechecker.model.Scope) ConditionScope(org.eclipse.ceylon.model.typechecker.model.ConditionScope) ModelUtil.getRealScope(org.eclipse.ceylon.model.typechecker.model.ModelUtil.getRealScope) CustomTree(org.eclipse.ceylon.compiler.typechecker.tree.CustomTree) Tree(org.eclipse.ceylon.compiler.typechecker.tree.Tree)

Example 94 with Scope

use of org.eclipse.ceylon.model.typechecker.model.Scope in project ceylon by eclipse.

the class DeclarationVisitor method visit.

public void visit(Tree.TypeConstructor that) {
    TypeAlias ta = new TypeAlias();
    ta.setShared(true);
    ta.setName("Anonymous#" + fid++);
    ta.setAnonymous(true);
    visitElement(that, ta);
    ModelUtil.setVisibleScope(ta);
    Scope o = enterScope(ta);
    Declaration od = beginDeclaration(ta);
    super.visit(that);
    endDeclaration(od);
    exitScope(o);
    ta.setExtendedType(that.getType().getTypeModel());
    that.setDeclarationModel(ta);
    Type pt = ta.getType();
    pt.setTypeConstructor(true);
    that.setTypeModel(pt);
}
Also used : IntersectionType(org.eclipse.ceylon.model.typechecker.model.IntersectionType) LazyType(org.eclipse.ceylon.model.typechecker.model.LazyType) UnionType(org.eclipse.ceylon.model.typechecker.model.UnionType) Type(org.eclipse.ceylon.model.typechecker.model.Type) UnknownType(org.eclipse.ceylon.model.typechecker.model.UnknownType) TypeVisitor.getTupleType(org.eclipse.ceylon.compiler.typechecker.analyzer.TypeVisitor.getTupleType) Scope(org.eclipse.ceylon.model.typechecker.model.Scope) ConditionScope(org.eclipse.ceylon.model.typechecker.model.ConditionScope) ModelUtil.getRealScope(org.eclipse.ceylon.model.typechecker.model.ModelUtil.getRealScope) TypeAlias(org.eclipse.ceylon.model.typechecker.model.TypeAlias) TypedDeclaration(org.eclipse.ceylon.model.typechecker.model.TypedDeclaration) AnalyzerUtil.getPackageTypeDeclaration(org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getPackageTypeDeclaration) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration) AnalyzerUtil.getTypeDeclaration(org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getTypeDeclaration) Declaration(org.eclipse.ceylon.model.typechecker.model.Declaration)

Example 95 with Scope

use of org.eclipse.ceylon.model.typechecker.model.Scope in project ceylon by eclipse.

the class DeclarationVisitor method visit.

@Override
public void visit(Tree.Constructor that) {
    Constructor c = new Constructor();
    that.setConstructor(c);
    if (scope instanceof Class) {
        Class clazz = (Class) scope;
        if (that.getIdentifier() == null && clazz.getDefaultConstructor() != null) {
            // found an overloaded default constructor
            // we'll set up the class overloads later
            // when exiting visit(Tree.ClassDefinition)
            clazz.setOverloaded(true);
            clazz.setAbstraction(true);
        }
    }
    visitDeclaration(that, c, false);
    Type at;
    Scope realScope = getRealScope(scope);
    if (realScope instanceof Class) {
        Class clazz = (Class) realScope;
        Type ot = clazz.getType();
        c.setExtendedType(ot);
        at = c.appliedType(ot, NO_TYPE_ARGS);
        clazz.setConstructors(true);
        if (clazz.isAnonymous()) {
            that.addError("anonymous class may not have constructor: '" + clazz.getName() + "' is an anonymous class");
        }
    } else {
        at = null;
        that.addError("constructor declaration must occur directly in the body of a class");
    }
    Function f = new Function();
    f.setType(at);
    that.setDeclarationModel(f);
    visitDeclaration(that, f);
    Scope o = enterScope(c);
    super.visit(that);
    exitScope(o);
    f.setImplemented(that.getBlock() != null);
    if (that.getParameterList() == null) {
        that.addError("missing parameter list in constructor declaration: '" + name(that.getIdentifier()) + "' must have a parameter list", 1000);
    } else {
        ParameterList model = that.getParameterList().getModel();
        model.setFirst(true);
        if (model != null) {
            c.addParameterList(model);
            // TODO: fix this
            f.addParameterList(model);
        }
    }
    if (c.isAbstract()) {
        if (that.getIdentifier() == null) {
            that.addError("default constructor may not be annotated 'abstract'", 1601);
        } else if (c.isShared()) {
            that.addError("abstract constructor may not be annotated 'shared'", 1610);
        }
    }
}
Also used : Function(org.eclipse.ceylon.model.typechecker.model.Function) IntersectionType(org.eclipse.ceylon.model.typechecker.model.IntersectionType) LazyType(org.eclipse.ceylon.model.typechecker.model.LazyType) UnionType(org.eclipse.ceylon.model.typechecker.model.UnionType) Type(org.eclipse.ceylon.model.typechecker.model.Type) UnknownType(org.eclipse.ceylon.model.typechecker.model.UnknownType) TypeVisitor.getTupleType(org.eclipse.ceylon.compiler.typechecker.analyzer.TypeVisitor.getTupleType) Scope(org.eclipse.ceylon.model.typechecker.model.Scope) ConditionScope(org.eclipse.ceylon.model.typechecker.model.ConditionScope) ModelUtil.getRealScope(org.eclipse.ceylon.model.typechecker.model.ModelUtil.getRealScope) ModelUtil.isDefaultConstructor(org.eclipse.ceylon.model.typechecker.model.ModelUtil.isDefaultConstructor) ModelUtil.isConstructor(org.eclipse.ceylon.model.typechecker.model.ModelUtil.isConstructor) Constructor(org.eclipse.ceylon.model.typechecker.model.Constructor) ParameterList(org.eclipse.ceylon.model.typechecker.model.ParameterList) Class(org.eclipse.ceylon.model.typechecker.model.Class) AnalyzerUtil.isVeryAbstractClass(org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.isVeryAbstractClass) ModelUtil.isAnonymousClass(org.eclipse.ceylon.model.typechecker.model.ModelUtil.isAnonymousClass)

Aggregations

Scope (org.eclipse.ceylon.model.typechecker.model.Scope)142 TypeDeclaration (org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)71 TypedDeclaration (org.eclipse.ceylon.model.typechecker.model.TypedDeclaration)57 Declaration (org.eclipse.ceylon.model.typechecker.model.Declaration)50 Tree (org.eclipse.ceylon.compiler.typechecker.tree.Tree)44 Type (org.eclipse.ceylon.model.typechecker.model.Type)44 ConditionScope (org.eclipse.ceylon.model.typechecker.model.ConditionScope)35 ClassOrInterface (org.eclipse.ceylon.model.typechecker.model.ClassOrInterface)34 Class (org.eclipse.ceylon.model.typechecker.model.Class)33 ModelUtil.getRealScope (org.eclipse.ceylon.model.typechecker.model.ModelUtil.getRealScope)31 TypeParameter (org.eclipse.ceylon.model.typechecker.model.TypeParameter)30 UnknownType (org.eclipse.ceylon.model.typechecker.model.UnknownType)26 Value (org.eclipse.ceylon.model.typechecker.model.Value)26 Constructor (org.eclipse.ceylon.model.typechecker.model.Constructor)25 FunctionOrValue (org.eclipse.ceylon.model.typechecker.model.FunctionOrValue)24 Function (org.eclipse.ceylon.model.typechecker.model.Function)23 Package (org.eclipse.ceylon.model.typechecker.model.Package)22 ArrayList (java.util.ArrayList)21 CustomTree (org.eclipse.ceylon.compiler.typechecker.tree.CustomTree)20 NativeUtil.declarationScope (org.eclipse.ceylon.compiler.typechecker.util.NativeUtil.declarationScope)15