1 package org.simantics.scl.compiler.environment;
3 import java.util.function.Consumer;
5 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
6 import org.simantics.scl.compiler.elaboration.modules.TypeAlias;
7 import org.simantics.scl.compiler.elaboration.modules.TypeClass;
8 import org.simantics.scl.compiler.elaboration.modules.TypeConstructor;
9 import org.simantics.scl.compiler.elaboration.relations.SCLEntityType;
10 import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
11 import org.simantics.scl.compiler.elaboration.rules.MappingRelation;
12 import org.simantics.scl.compiler.elaboration.rules.TransformationRule;
13 import org.simantics.scl.compiler.environment.filter.NamespaceFilter;
14 import org.simantics.scl.compiler.internal.codegen.effects.EffectConstructor;
15 import org.simantics.scl.compiler.types.TCon;
17 import gnu.trove.procedure.TObjectProcedure;
19 public interface Namespace {
21 * Find a sub-namespace with a given name
22 * @param name name of the namespace
23 * @return a Namespace instance, or null if not found
25 Namespace getNamespace(String name);
28 * Get an SCLValue for a given name. The same instance is returned on each call.
29 * @param name the name of a defined value
30 * @return The return value is an SCLValue provided by any source included in the namespace,
31 * or null if the name is not found.
32 * @exception AmbiguousNameException if the name matches with multiple imported modules.
34 SCLValue getValue(String name) throws AmbiguousNameException;
37 * Get an SCLRelation for a given name. The same instance is returned on each call.
38 * @param name the name of a defined relation
39 * @return The return value is an SCLRelation provided by any source included in the namespace,
40 * or null if the name is not found.
41 * @exception AmbiguousNameException if the name matches with multiple imported modules.
43 SCLRelation getRelation(String name) throws AmbiguousNameException;
46 * Get an SCLEntityType for a given name. The same instance is returned on each call.
47 * @param name the name of a defined entity type
48 * @return The return value is an SCLEntityType provided by any source included in the namespace,
49 * or null if the name is not found.
50 * @exception AmbiguousNameException if the name matches with multiple imported modules.
52 SCLEntityType getEntityType(String name) throws AmbiguousNameException;
55 * Get a TypeConstructor for a given name. The same instance is returned on each call.
56 * @param name the name of a defined entity type
57 * @return The return value is a TypeConstructor provided by any source included in the namespace,
58 * or null if the name is not found.
59 * @exception AmbiguousNameException if the name matches with multiple imported modules.
61 TypeConstructor getTypeConstructor(String name) throws AmbiguousNameException;
64 * Get an EffectConstructor for a given name. The same instance is returned on each call.
65 * @param name an effect name
66 * @return The return value is an EffectConstructor provided by any source included in the namespace,
67 * or null if the name is not found.
68 * @exception AmbiguousNameException if the name matches with multiple imported modules.
70 EffectConstructor getEffectConstructor(String name) throws AmbiguousNameException;
73 * Get a TypeClass for a given name. The same instance is returned on each call.
74 * @param name the name of a defined entity type
75 * @return The return value is a TypeClass provided by any source included in the namespace,
76 * or null if the name is not found.
77 * @exception AmbiguousNameException if the name matches with multiple imported modules.
79 TypeClass getTypeClass(String name) throws AmbiguousNameException;
82 * Get a TypeAlias for a given name. The same instance is returned on each call.
83 * @param name the name of a defined entity type
84 * @return The return value is a TypeAlias provided by any source included in the namespace,
85 * or null if the name is not found.
86 * @exception AmbiguousNameException if the name matches with multiple imported modules.
88 TypeAlias getTypeAlias(String name) throws AmbiguousNameException;
90 TransformationRule getRule(String name) throws AmbiguousNameException;
91 MappingRelation getMappingRelation(String name) throws AmbiguousNameException;
94 * Find all values that share a common prefix and call a procedure for them.
95 * @param prefix A name prefix
96 * @param filter A filter that restricts the set of found values
97 * @param proc A procedure that is called for all found values
99 void findValuesForPrefix(String prefix, NamespaceFilter filter, TObjectProcedure<SCLValue> proc);
102 * Find all types that share a common prefix and call a consumer for them.
103 * @param prefix A name prefix
104 * @param filter A filter that restricts the set of found values
105 * @param consumer A procedure that is called for all found values
107 void findTypesForPrefix(String prefix, NamespaceFilter filter, Consumer<TCon> consumer);