Search in sources :

Example 1 with TypeSynDecl

use of abs.frontend.ast.TypeSynDecl in project abstools by abstools.

the class PureExpressionBuilder method resolveTypeSynonym.

/**
 * Resolve the type synonyms to its raw type (interface or data type)
 * @param d
 * @return
 */
Decl resolveTypeSynonym(TypeSynDecl d) {
    TypeUse use = d.getValue();
    Decl decl = getDecl(model, Decl.class, namePred(use.getName()));
    if (decl instanceof TypeSynDecl) {
        return resolveTypeSynonym((TypeSynDecl) decl);
    }
    return decl;
}
Also used : TypeUse(abs.frontend.ast.TypeUse) DataTypeUse(abs.frontend.ast.DataTypeUse) AbsASTBuilderUtil.getDecl(abs.backend.tests.AbsASTBuilderUtil.getDecl) DataTypeDecl(abs.frontend.ast.DataTypeDecl) InterfaceDecl(abs.frontend.ast.InterfaceDecl) Decl(abs.frontend.ast.Decl) TypeParameterDecl(abs.frontend.ast.TypeParameterDecl) TypeSynDecl(abs.frontend.ast.TypeSynDecl) ParametricDataTypeDecl(abs.frontend.ast.ParametricDataTypeDecl) TypeSynDecl(abs.frontend.ast.TypeSynDecl)

Example 2 with TypeSynDecl

use of abs.frontend.ast.TypeSynDecl in project abstools by abstools.

the class PureExpressionBuilder method importType.

void importType(Decl decl) {
    importModules.add(decl.getModuleDecl().getName());
    if (decl instanceof TypeSynDecl) {
        decl = resolveTypeSynonym((TypeSynDecl) decl);
        importModules.add(decl.getModuleDecl().getName());
    }
    // import type parameters
    if (decl instanceof ParametricDataTypeDecl) {
        for (TypeParameterDecl t : ((ParametricDataTypeDecl) decl).getTypeParameters()) {
            Decl type = getDecl(model, Decl.class, namePred(t.getName()));
            if (type == null) {
                // most likely a generic type
                continue;
            }
            importType(type);
        }
    }
}
Also used : TypeParameterDecl(abs.frontend.ast.TypeParameterDecl) AbsASTBuilderUtil.getDecl(abs.backend.tests.AbsASTBuilderUtil.getDecl) DataTypeDecl(abs.frontend.ast.DataTypeDecl) InterfaceDecl(abs.frontend.ast.InterfaceDecl) Decl(abs.frontend.ast.Decl) TypeParameterDecl(abs.frontend.ast.TypeParameterDecl) TypeSynDecl(abs.frontend.ast.TypeSynDecl) ParametricDataTypeDecl(abs.frontend.ast.ParametricDataTypeDecl) ParametricDataTypeDecl(abs.frontend.ast.ParametricDataTypeDecl) TypeSynDecl(abs.frontend.ast.TypeSynDecl)

Example 3 with TypeSynDecl

use of abs.frontend.ast.TypeSynDecl in project abstools by abstools.

the class TypeHierarchyContentProvider method getChildren.

@Override
public Object[] getChildren(Object node) {
    if (node instanceof InterfaceDecl) {
        InterfaceDecl interfaceDecl = (InterfaceDecl) node;
        Collection<HasTypeHierarchy> subTypes = interfaceDecl.getDirectSubTypes();
        return subTypes.toArray();
    } else if (node instanceof DataTypeDecl) {
        DataTypeDecl dataTypeDecl = (DataTypeDecl) node;
        Object[] result = new Object[dataTypeDecl.getNumDataConstructor()];
        int i = 0;
        for (DataConstructor d : dataTypeDecl.getDataConstructors()) {
            result[i] = d;
            i++;
        }
        return result;
    } else if (node instanceof TypeSynDecl) {
        TypeSynDecl typeSynDecl = (TypeSynDecl) node;
        return new Object[] { typeSynDecl.getType().getDecl() };
    }
    return nothing;
}
Also used : InterfaceDecl(abs.frontend.ast.InterfaceDecl) HasTypeHierarchy(abs.frontend.ast.HasTypeHierarchy) DataConstructor(abs.frontend.ast.DataConstructor) DataTypeDecl(abs.frontend.ast.DataTypeDecl) TypeSynDecl(abs.frontend.ast.TypeSynDecl)

Aggregations

DataTypeDecl (abs.frontend.ast.DataTypeDecl)3 InterfaceDecl (abs.frontend.ast.InterfaceDecl)3 TypeSynDecl (abs.frontend.ast.TypeSynDecl)3 AbsASTBuilderUtil.getDecl (abs.backend.tests.AbsASTBuilderUtil.getDecl)2 Decl (abs.frontend.ast.Decl)2 ParametricDataTypeDecl (abs.frontend.ast.ParametricDataTypeDecl)2 TypeParameterDecl (abs.frontend.ast.TypeParameterDecl)2 DataConstructor (abs.frontend.ast.DataConstructor)1 DataTypeUse (abs.frontend.ast.DataTypeUse)1 HasTypeHierarchy (abs.frontend.ast.HasTypeHierarchy)1 TypeUse (abs.frontend.ast.TypeUse)1