Search in sources :

Example 16 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.FunctionArgument that) {
    Tree.Type type = that.getType();
    final Function f = new Function();
    f.setName("anonymous#" + fid++);
    f.setAnonymous(true);
    if (type.getToken() != null) {
        f.setDeclaredVoid(type instanceof Tree.VoidModifier);
    } else {
        Tree.Block block = that.getBlock();
        if (block != null) {
            f.setDeclaredVoid(true);
            new Visitor() {

                @Override
                public void visit(Tree.Declaration that) {
                }

                @Override
                public void visit(Tree.TypedArgument that) {
                }

                @Override
                public void visit(Tree.ObjectExpression that) {
                }

                @Override
                public void visit(Tree.FunctionArgument that) {
                }

                @Override
                public void visit(Tree.Return that) {
                    if (that.getExpression() != null) {
                        f.setDeclaredVoid(false);
                    }
                    super.visit(that);
                }
            }.visit(block);
        }
    }
    that.setDeclarationModel(f);
    visitArgument(that, f);
    Scope o = enterScope(f);
    Declaration d = beginDeclaration(f);
    super.visit(that);
    endDeclaration(d);
    exitScope(o);
    setParameterLists(f, that.getParameterLists(), that);
}
Also used : Visitor(org.eclipse.ceylon.compiler.typechecker.tree.Visitor) Function(org.eclipse.ceylon.model.typechecker.model.Function) 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) 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 17 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.ObjectExpression that) {
    Class c = new Class();
    c.setName("anonymous#" + fid++);
    c.setNamed(false);
    defaultExtendedToBasic(c);
    c.setAnonymous(true);
    that.setAnonymousClass(c);
    visitArgument(that, c);
    Scope o = enterScope(c);
    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) 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)

Example 18 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.AnyMethod that) {
    Function m = new Function();
    that.setDeclarationModel(m);
    visitDeclaration(that, m);
    Scope o = enterScope(m);
    super.visit(that);
    exitScope(o);
    setParameterLists(m, that.getParameterLists(), that);
    Tree.Type type = that.getType();
    m.setDeclaredVoid(type instanceof Tree.VoidModifier);
    if (type instanceof Tree.ValueModifier) {
        type.addError("functions may not be declared using the keyword value");
    }
    if (type instanceof Tree.DynamicModifier) {
        m.setDynamicallyTyped(true);
    }
}
Also used : Function(org.eclipse.ceylon.model.typechecker.model.Function) 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 19 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.ObjectArgument that) {
    Class c = new Class();
    defaultExtendedToBasic(c);
    c.setAnonymous(true);
    that.setAnonymousClass(c);
    visitArgument(that, c);
    Value v = new Value();
    that.setDeclarationModel(v);
    visitArgument(that, v);
    Type t = c.getType();
    that.getType().setTypeModel(t);
    v.setType(t);
    Scope o = enterScope(c);
    super.visit(that);
    exitScope(o);
}
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) Value(org.eclipse.ceylon.model.typechecker.model.Value) FunctionOrValue(org.eclipse.ceylon.model.typechecker.model.FunctionOrValue) 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)

Example 20 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.ImportModuleList that) {
    ModuleImportList il = new ModuleImportList();
    il.setContainer(scope);
    il.setUnit(unit);
    Scope o = enterScope(il);
    super.visit(that);
    exitScope(o);
}
Also used : ModuleImportList(org.eclipse.ceylon.model.typechecker.model.ModuleImportList) 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)

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