1 package org.simantics.scl.compiler.environment;
3 import java.util.Collection;
4 import java.util.function.Consumer;
6 import org.simantics.scl.compiler.elaboration.chr.CHRRuleset;
7 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
8 import org.simantics.scl.compiler.elaboration.modules.TypeClass;
9 import org.simantics.scl.compiler.elaboration.modules.TypeDescriptor;
10 import org.simantics.scl.compiler.elaboration.relations.SCLEntityType;
11 import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
12 import org.simantics.scl.compiler.elaboration.rules.MappingRelation;
13 import org.simantics.scl.compiler.elaboration.rules.TransformationRule;
14 import org.simantics.scl.compiler.environment.filter.NamespaceFilter;
15 import org.simantics.scl.compiler.internal.codegen.effects.EffectConstructor;
16 import org.simantics.scl.compiler.types.TCon;
18 import gnu.trove.procedure.TObjectProcedure;
20 public interface Namespace {
22 * Find a sub-namespace with a given name
23 * @param name name of the namespace
24 * @return a Namespace instance, or null if not found
26 Namespace getNamespace(String name);
28 Collection<String> getNamespaces();
31 * Get an SCLValue for a given name. The same instance is returned on each call.
32 * @param name the name of a defined value
33 * @return The return value is an SCLValue provided by any source included in the namespace,
34 * or null if the name is not found.
35 * @exception AmbiguousNameException if the name matches with multiple imported modules.
37 SCLValue getValue(String name) throws AmbiguousNameException;
40 * Get an SCLRelation for a given name. The same instance is returned on each call.
41 * @param name the name of a defined relation
42 * @return The return value is an SCLRelation provided by any source included in the namespace,
43 * or null if the name is not found.
44 * @exception AmbiguousNameException if the name matches with multiple imported modules.
46 SCLRelation getRelation(String name) throws AmbiguousNameException;
49 * Get an SCLEntityType for a given name. The same instance is returned on each call.
50 * @param name the name of a defined entity type
51 * @return The return value is an SCLEntityType provided by any source included in the namespace,
52 * or null if the name is not found.
53 * @exception AmbiguousNameException if the name matches with multiple imported modules.
55 SCLEntityType getEntityType(String name) throws AmbiguousNameException;
58 * Get a TypeDescriptor for a given name. The same instance is returned on each call.
59 * @param name the name of a defined entity type
60 * @return The return value is a TypeDescriptor provided by any source included in the namespace,
61 * or null if the name is not found.
62 * @exception AmbiguousNameException if the name matches with multiple imported modules.
64 TypeDescriptor getTypeDescriptor(String name) throws AmbiguousNameException;
67 * Get an EffectConstructor for a given name. The same instance is returned on each call.
68 * @param name an effect name
69 * @return The return value is an EffectConstructor provided by any source included in the namespace,
70 * or null if the name is not found.
71 * @exception AmbiguousNameException if the name matches with multiple imported modules.
73 EffectConstructor getEffectConstructor(String name) throws AmbiguousNameException;
75 CHRRuleset getRuleset(String name) throws AmbiguousNameException;
78 * Get a TypeClass for a given name. The same instance is returned on each call.
79 * @param name the name of a defined entity type
80 * @return The return value is a TypeClass provided by any source included in the namespace,
81 * or null if the name is not found.
82 * @exception AmbiguousNameException if the name matches with multiple imported modules.
84 TypeClass getTypeClass(String name) throws AmbiguousNameException;
86 TransformationRule getRule(String name) throws AmbiguousNameException;
87 MappingRelation getMappingRelation(String name) throws AmbiguousNameException;
90 * Find all values that share a common prefix and call a procedure for them.
91 * @param prefix A name prefix
92 * @param filter A filter that restricts the set of found values
93 * @param proc A procedure that is called for all found values
95 void findValuesForPrefix(String prefix, NamespaceFilter filter, TObjectProcedure<SCLValue> proc);
98 * Find all types that share a common prefix and call a consumer for them.
99 * @param prefix A name prefix
100 * @param filter A filter that restricts the set of found values
101 * @param consumer A procedure that is called for all found values
103 void findTypesForPrefix(String prefix, NamespaceFilter filter, Consumer<TCon> consumer);