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.TypeClass;
7 import org.simantics.scl.compiler.elaboration.modules.TypeDescriptor;
8 import org.simantics.scl.compiler.elaboration.relations.SCLEntityType;
9 import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
10 import org.simantics.scl.compiler.elaboration.rules.MappingRelation;
11 import org.simantics.scl.compiler.elaboration.rules.TransformationRule;
12 import org.simantics.scl.compiler.environment.filter.NamespaceFilter;
13 import org.simantics.scl.compiler.internal.codegen.effects.EffectConstructor;
14 import org.simantics.scl.compiler.types.TCon;
16 import gnu.trove.procedure.TObjectProcedure;
18 public interface Namespace {
20 * Find a sub-namespace with a given name
21 * @param name name of the namespace
22 * @return a Namespace instance, or null if not found
24 Namespace getNamespace(String name);
27 * Get an SCLValue for a given name. The same instance is returned on each call.
28 * @param name the name of a defined value
29 * @return The return value is an SCLValue provided by any source included in the namespace,
30 * or null if the name is not found.
31 * @exception AmbiguousNameException if the name matches with multiple imported modules.
33 SCLValue getValue(String name) throws AmbiguousNameException;
36 * Get an SCLRelation for a given name. The same instance is returned on each call.
37 * @param name the name of a defined relation
38 * @return The return value is an SCLRelation provided by any source included in the namespace,
39 * or null if the name is not found.
40 * @exception AmbiguousNameException if the name matches with multiple imported modules.
42 SCLRelation getRelation(String name) throws AmbiguousNameException;
45 * Get an SCLEntityType for a given name. The same instance is returned on each call.
46 * @param name the name of a defined entity type
47 * @return The return value is an SCLEntityType provided by any source included in the namespace,
48 * or null if the name is not found.
49 * @exception AmbiguousNameException if the name matches with multiple imported modules.
51 SCLEntityType getEntityType(String name) throws AmbiguousNameException;
54 * Get a TypeDescriptor for a given name. The same instance is returned on each call.
55 * @param name the name of a defined entity type
56 * @return The return value is a TypeDescriptor provided by any source included in the namespace,
57 * or null if the name is not found.
58 * @exception AmbiguousNameException if the name matches with multiple imported modules.
60 TypeDescriptor getTypeDescriptor(String name) throws AmbiguousNameException;
63 * Get an EffectConstructor for a given name. The same instance is returned on each call.
64 * @param name an effect name
65 * @return The return value is an EffectConstructor provided by any source included in the namespace,
66 * or null if the name is not found.
67 * @exception AmbiguousNameException if the name matches with multiple imported modules.
69 EffectConstructor getEffectConstructor(String name) throws AmbiguousNameException;
72 * Get a TypeClass for a given name. The same instance is returned on each call.
73 * @param name the name of a defined entity type
74 * @return The return value is a TypeClass provided by any source included in the namespace,
75 * or null if the name is not found.
76 * @exception AmbiguousNameException if the name matches with multiple imported modules.
78 TypeClass getTypeClass(String name) throws AmbiguousNameException;
80 TransformationRule getRule(String name) throws AmbiguousNameException;
81 MappingRelation getMappingRelation(String name) throws AmbiguousNameException;
84 * Find all values that share a common prefix and call a procedure for them.
85 * @param prefix A name prefix
86 * @param filter A filter that restricts the set of found values
87 * @param proc A procedure that is called for all found values
89 void findValuesForPrefix(String prefix, NamespaceFilter filter, TObjectProcedure<SCLValue> proc);
92 * Find all types that share a common prefix and call a consumer for them.
93 * @param prefix A name prefix
94 * @param filter A filter that restricts the set of found values
95 * @param consumer A procedure that is called for all found values
97 void findTypesForPrefix(String prefix, NamespaceFilter filter, Consumer<TCon> consumer);