Search in sources :

Example 1 with Package

use of nl.ramsolutions.sw.magik.analysis.typing.types.Package in project magik-tools by StevenLooman.

the class JsonTypeKeeperReader method handlePackage.

private void handlePackage(final JSONObject instruction) {
    final String name = instruction.getString("name");
    if (!this.typeKeeper.hasPackage(name)) {
        final Package pakkage = new Package(name);
        this.typeKeeper.addPackage(pakkage);
    }
    final Package pakkage = this.typeKeeper.getPackage(name);
    instruction.getJSONArray("uses").forEach(useObj -> {
        final String use = (String) useObj;
        final Package usePackage = this.typeKeeper.getPackage(use);
        pakkage.addUse(usePackage);
    });
}
Also used : Package(nl.ramsolutions.sw.magik.analysis.typing.types.Package)

Example 2 with Package

use of nl.ramsolutions.sw.magik.analysis.typing.types.Package in project magik-tools by StevenLooman.

the class TypeKeeper method hasType.

@Override
public boolean hasType(final GlobalReference globalReference) {
    final String pakkageName = globalReference.getPakkage();
    final Package pakkage = this.getPackage(pakkageName);
    final String identifier = globalReference.getIdentifier();
    return pakkage != null && pakkage.containsKey(identifier);
}
Also used : Package(nl.ramsolutions.sw.magik.analysis.typing.types.Package)

Example 3 with Package

use of nl.ramsolutions.sw.magik.analysis.typing.types.Package in project magik-tools by StevenLooman.

the class TypeKeeper method addType.

@Override
public void addType(final AbstractType type) {
    final GlobalReference globalRef = GlobalReference.of(type.getFullName());
    final String pakkageName = globalRef.getPakkage();
    final Package pakkage = this.getPackage(pakkageName);
    final String identifier = globalRef.getIdentifier();
    pakkage.put(identifier, type);
}
Also used : GlobalReference(nl.ramsolutions.sw.magik.analysis.typing.types.GlobalReference) Package(nl.ramsolutions.sw.magik.analysis.typing.types.Package)

Example 4 with Package

use of nl.ramsolutions.sw.magik.analysis.typing.types.Package in project magik-tools by StevenLooman.

the class TypeKeeper method registerRequiredTypes.

private void registerRequiredTypes() {
    final Package swPakkage = this.getPackage("sw");
    swPakkage.put("object", new ObjectType(GlobalReference.of("sw:object")));
    swPakkage.put("unset", new IntrinsicType(GlobalReference.of("sw:unset")));
    swPakkage.put("false", new IntrinsicType(GlobalReference.of("sw:false")));
    swPakkage.put("maybe", new IntrinsicType(GlobalReference.of("sw:maybe")));
    swPakkage.put("integer", new IntrinsicType(GlobalReference.of("sw:integer")));
    swPakkage.put("bignum", new IntrinsicType(GlobalReference.of("sw:bignum")));
    swPakkage.put("float", new IntrinsicType(GlobalReference.of("sw:float")));
    swPakkage.put("symbol", new IndexedType(GlobalReference.of("sw:symbol")));
    swPakkage.put("character", new IntrinsicType(GlobalReference.of("sw:character")));
    swPakkage.put("sw_regexp", new IntrinsicType(GlobalReference.of("sw:sw_regexp")));
    swPakkage.put("char16_vector", new IndexedType(GlobalReference.of("sw:char16_vector")));
    swPakkage.put("simple_vector", new IndexedType(GlobalReference.of("sw:simple_vector")));
    swPakkage.put("heavy_thread", new IntrinsicType(GlobalReference.of("sw:heavy_thread")));
    swPakkage.put("light_thread", new IntrinsicType(GlobalReference.of("sw:light_thread")));
    swPakkage.put("condition", new SlottedType(GlobalReference.of("sw:condition")));
    swPakkage.put("enumeration_value", new SlottedType(GlobalReference.of("sw:enumeration_value")));
    swPakkage.put("indexed_format_mixin", new IntrinsicType(GlobalReference.of("sw:indexed_format_mixin")));
    swPakkage.put("slotted_format_mixin", new IntrinsicType(GlobalReference.of("sw:slotted_format_mixin")));
}
Also used : ObjectType(nl.ramsolutions.sw.magik.analysis.typing.types.ObjectType) IntrinsicType(nl.ramsolutions.sw.magik.analysis.typing.types.IntrinsicType) SlottedType(nl.ramsolutions.sw.magik.analysis.typing.types.SlottedType) Package(nl.ramsolutions.sw.magik.analysis.typing.types.Package) IndexedType(nl.ramsolutions.sw.magik.analysis.typing.types.IndexedType)

Example 5 with Package

use of nl.ramsolutions.sw.magik.analysis.typing.types.Package in project magik-tools by StevenLooman.

the class TypeKeeper method getType.

@Override
public AbstractType getType(final GlobalReference globalReference) {
    final String pakkageName = globalReference.getPakkage();
    final Package pakkage = this.getPackage(pakkageName);
    final String identifier = globalReference.getIdentifier();
    if (!pakkage.containsKey(identifier)) {
        return UndefinedType.INSTANCE;
    }
    return pakkage.get(identifier);
}
Also used : Package(nl.ramsolutions.sw.magik.analysis.typing.types.Package)

Aggregations

Package (nl.ramsolutions.sw.magik.analysis.typing.types.Package)10 AstNode (com.sonar.sslr.api.AstNode)2 URI (java.net.URI)2 Path (java.nio.file.Path)2 Location (nl.ramsolutions.sw.magik.analysis.Location)2 IndexedType (nl.ramsolutions.sw.magik.analysis.typing.types.IndexedType)2 IntrinsicType (nl.ramsolutions.sw.magik.analysis.typing.types.IntrinsicType)2 SlottedType (nl.ramsolutions.sw.magik.analysis.typing.types.SlottedType)2 Token (com.sonar.sslr.api.Token)1 IOException (java.io.IOException)1 Paths (java.nio.file.Paths)1 Collections (java.util.Collections)1 EnumSet (java.util.EnumSet)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1