Search in sources :

Example 6 with Package

use of dyvilx.tools.compiler.ast.structure.Package in project Dyvil by Dyvil.

the class HeaderContext method resolvePackage.

@Override
public Package resolvePackage(Name name) {
    Package result;
    final ImportDeclaration[] importDeclarations = this.header.importDeclarations;
    for (int i = 0, count = this.header.importCount; i < count; i++) {
        result = importDeclarations[i].getContext().resolvePackage(name);
        if (result != null) {
            return result;
        }
    }
    return this.header.resolvePackage(name);
}
Also used : ImportDeclaration(dyvilx.tools.compiler.ast.imports.ImportDeclaration) Package(dyvilx.tools.compiler.ast.structure.Package)

Example 7 with Package

use of dyvilx.tools.compiler.ast.structure.Package in project Dyvil by Dyvil.

the class SingleImport method resolveTypes.

@Override
public void resolveTypes(MarkerList markers, IContext context, IImportContext parentContext, int mask) {
    if (this.parent != null) {
        this.parent.resolveTypes(markers, context, parentContext, KindedImport.PARENT);
        parentContext = this.parent.asParentContext();
    }
    boolean resolved = false;
    this.resolver = parentContext;
    this.mask = mask;
    if ((mask & KindedImport.CLASS) != 0) {
        final IClass theClass = parentContext.resolveClass(this.name);
        if (theClass != null) {
            this.asParentContext = theClass;
            resolved = true;
        }
    }
    if ((mask & KindedImport.HEADER) != 0) {
        final IHeaderUnit header = parentContext.resolveHeader(this.name);
        if (header != null) {
            if ((mask & KindedImport.INLINE) != 0 && this.checkInline(markers, context, header)) {
                this.asContext = new CombiningContext(this, header.getContext());
            }
            this.asParentContext = !resolved ? header : new CombiningContext(header, this.asParentContext);
            resolved = true;
        }
    }
    if ((mask & KindedImport.PACKAGE) != 0) {
        final Package thePackage = parentContext.resolvePackage(this.name);
        if (thePackage != null) {
            this.asParentContext = !resolved ? thePackage : new CombiningContext(thePackage, this.asParentContext);
            resolved = true;
        }
    }
    if (!resolved) {
        this.asParentContext = IDefaultContext.DEFAULT;
        if (mask == KindedImport.PARENT) {
            // when resolving as a parent import, the resolve method is never called,
            // so we need the error reporting to happen here.
            this.reportResolve(markers);
        }
    }
// otherwise error later
}
Also used : CombiningContext(dyvilx.tools.compiler.ast.context.CombiningContext) IClass(dyvilx.tools.compiler.ast.classes.IClass) Package(dyvilx.tools.compiler.ast.structure.Package) IHeaderUnit(dyvilx.tools.compiler.ast.header.IHeaderUnit)

Aggregations

Package (dyvilx.tools.compiler.ast.structure.Package)7 IClass (dyvilx.tools.compiler.ast.classes.IClass)5 IType (dyvilx.tools.compiler.ast.type.IType)3 ITypeParameter (dyvilx.tools.compiler.ast.generic.ITypeParameter)2 ITypeAlias (dyvilx.tools.compiler.ast.type.alias.ITypeAlias)2 PackageType (dyvilx.tools.compiler.ast.type.raw.PackageType)2 ResolvedTypeVarType (dyvilx.tools.compiler.ast.type.typevar.ResolvedTypeVarType)2 CombiningContext (dyvilx.tools.compiler.ast.context.CombiningContext)1 IHeaderUnit (dyvilx.tools.compiler.ast.header.IHeaderUnit)1 ImportDeclaration (dyvilx.tools.compiler.ast.imports.ImportDeclaration)1