X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Fenvironment%2FNamespace.java;fp=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Fenvironment%2FNamespace.java;h=dc388a72c2ebfe2392cd58d8172113f7c9137baa;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/environment/Namespace.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/environment/Namespace.java new file mode 100644 index 000000000..dc388a72c --- /dev/null +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/environment/Namespace.java @@ -0,0 +1,108 @@ +package org.simantics.scl.compiler.environment; + +import gnu.trove.procedure.TObjectProcedure; + +import java.util.function.Consumer; + +import org.simantics.scl.compiler.elaboration.modules.SCLValue; +import org.simantics.scl.compiler.elaboration.modules.TypeAlias; +import org.simantics.scl.compiler.elaboration.modules.TypeClass; +import org.simantics.scl.compiler.elaboration.modules.TypeConstructor; +import org.simantics.scl.compiler.elaboration.relations.SCLEntityType; +import org.simantics.scl.compiler.elaboration.relations.SCLRelation; +import org.simantics.scl.compiler.elaboration.rules.MappingRelation; +import org.simantics.scl.compiler.elaboration.rules.TransformationRule; +import org.simantics.scl.compiler.environment.filter.NamespaceFilter; +import org.simantics.scl.compiler.internal.codegen.effects.EffectConstructor; +import org.simantics.scl.compiler.types.TCon; + +public interface Namespace { + /** + * Find a sub-namespace with a given name + * @param name name of the namespace + * @return a Namespace instance, or null if not found + */ + Namespace getNamespace(String name); + + /** + * Get an SCLValue for a given name. The same instance is returned on each call. + * @param name the name of a defined value + * @return The return value is an SCLValue provided by any source included in the namespace, + * or null if the name is not found. + * @exception AmbiguousNameException if the name matches with multiple imported modules. + */ + SCLValue getValue(String name) throws AmbiguousNameException; + + /** + * Get an SCLRelation for a given name. The same instance is returned on each call. + * @param name the name of a defined relation + * @return The return value is an SCLRelation provided by any source included in the namespace, + * or null if the name is not found. + * @exception AmbiguousNameException if the name matches with multiple imported modules. + */ + SCLRelation getRelation(String name) throws AmbiguousNameException; + + /** + * Get an SCLEntityType for a given name. The same instance is returned on each call. + * @param name the name of a defined entity type + * @return The return value is an SCLEntityType provided by any source included in the namespace, + * or null if the name is not found. + * @exception AmbiguousNameException if the name matches with multiple imported modules. + */ + SCLEntityType getEntityType(String name) throws AmbiguousNameException; + + /** + * Get a TypeConstructor for a given name. The same instance is returned on each call. + * @param name the name of a defined entity type + * @return The return value is a TypeConstructor provided by any source included in the namespace, + * or null if the name is not found. + * @exception AmbiguousNameException if the name matches with multiple imported modules. + */ + TypeConstructor getTypeConstructor(String name) throws AmbiguousNameException; + + /** + * Get an EffectConstructor for a given name. The same instance is returned on each call. + * @param name an effect name + * @return The return value is an EffectConstructor provided by any source included in the namespace, + * or null if the name is not found. + * @exception AmbiguousNameException if the name matches with multiple imported modules. + */ + EffectConstructor getEffectConstructor(String name) throws AmbiguousNameException; + + /** + * Get a TypeClass for a given name. The same instance is returned on each call. + * @param name the name of a defined entity type + * @return The return value is a TypeClass provided by any source included in the namespace, + * or null if the name is not found. + * @exception AmbiguousNameException if the name matches with multiple imported modules. + */ + TypeClass getTypeClass(String name) throws AmbiguousNameException; + + /** + * Get a TypeAlias for a given name. The same instance is returned on each call. + * @param name the name of a defined entity type + * @return The return value is a TypeAlias provided by any source included in the namespace, + * or null if the name is not found. + * @exception AmbiguousNameException if the name matches with multiple imported modules. + */ + TypeAlias getTypeAlias(String name) throws AmbiguousNameException; + + TransformationRule getRule(String name) throws AmbiguousNameException; + MappingRelation getMappingRelation(String name) throws AmbiguousNameException; + + /** + * Find all values that share a common prefix and call a procedure for them. + * @param prefix A name prefix + * @param filter A filter that restricts the set of found values + * @param proc A procedure that is called for all found values + */ + void findValuesForPrefix(String prefix, NamespaceFilter filter, TObjectProcedure proc); + + /** + * Find all types that share a common prefix and call a consumer for them. + * @param prefix A name prefix + * @param filter A filter that restricts the set of found values + * @param consumer A procedure that is called for all found values + */ + void findTypesForPrefix(String prefix, NamespaceFilter filter, Consumer consumer); +}