1 package org.simantics.scl.compiler.environment;
3 import java.util.function.Consumer;
5 import org.simantics.scl.compiler.elaboration.chr.CHRRuleset;
6 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
7 import org.simantics.scl.compiler.elaboration.modules.TypeClass;
8 import org.simantics.scl.compiler.elaboration.modules.TypeDescriptor;
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 TypeDescriptor 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 TypeDescriptor 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 TypeDescriptor getTypeDescriptor(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;
72 CHRRuleset getRuleset(String name) throws AmbiguousNameException;
75 * Get a TypeClass for a given name. The same instance is returned on each call.
76 * @param name the name of a defined entity type
77 * @return The return value is a TypeClass provided by any source included in the namespace,
78 * or null if the name is not found.
79 * @exception AmbiguousNameException if the name matches with multiple imported modules.
81 TypeClass getTypeClass(String name) throws AmbiguousNameException;
83 TransformationRule getRule(String name) throws AmbiguousNameException;
84 MappingRelation getMappingRelation(String name) throws AmbiguousNameException;
87 * Find all values that share a common prefix and call a procedure for them.
88 * @param prefix A name prefix
89 * @param filter A filter that restricts the set of found values
90 * @param proc A procedure that is called for all found values
92 void findValuesForPrefix(String prefix, NamespaceFilter filter, TObjectProcedure<SCLValue> proc);
95 * Find all types that share a common prefix and call a consumer for them.
96 * @param prefix A name prefix
97 * @param filter A filter that restricts the set of found values
98 * @param consumer A procedure that is called for all found values
100 void findTypesForPrefix(String prefix, NamespaceFilter filter, Consumer<TCon> consumer);