1 package org.simantics.scl.compiler.environment;
4 import java.util.function.Consumer;
6 import org.simantics.scl.compiler.constants.Constant;
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);
29 * Get an SCLValue for a given name. The same instance is returned on each call.
30 * @param name the name of a defined value
31 * @return The return value is an SCLValue provided by any source included in the namespace,
32 * or null if the name is not found.
33 * @exception AmbiguousNameException if the name matches with multiple imported modules.
35 SCLValue getValue(String name) throws AmbiguousNameException;
38 * Get an SCLRelation for a given name. The same instance is returned on each call.
39 * @param name the name of a defined relation
40 * @return The return value is an SCLRelation provided by any source included in the namespace,
41 * or null if the name is not found.
42 * @exception AmbiguousNameException if the name matches with multiple imported modules.
44 SCLRelation getRelation(String name) throws AmbiguousNameException;
47 * Get an SCLEntityType for a given name. The same instance is returned on each call.
48 * @param name the name of a defined entity type
49 * @return The return value is an SCLEntityType provided by any source included in the namespace,
50 * or null if the name is not found.
51 * @exception AmbiguousNameException if the name matches with multiple imported modules.
53 SCLEntityType getEntityType(String name) throws AmbiguousNameException;
56 * Get a TypeDescriptor for a given name. The same instance is returned on each call.
57 * @param name the name of a defined entity type
58 * @return The return value is a TypeDescriptor provided by any source included in the namespace,
59 * or null if the name is not found.
60 * @exception AmbiguousNameException if the name matches with multiple imported modules.
62 TypeDescriptor getTypeDescriptor(String name) throws AmbiguousNameException;
65 * Get an EffectConstructor for a given name. The same instance is returned on each call.
66 * @param name an effect name
67 * @return The return value is an EffectConstructor provided by any source included in the namespace,
68 * or null if the name is not found.
69 * @exception AmbiguousNameException if the name matches with multiple imported modules.
71 EffectConstructor getEffectConstructor(String name) throws AmbiguousNameException;
74 * Get a TypeClass for a given name. The same instance is returned on each call.
75 * @param name the name of a defined entity type
76 * @return The return value is a TypeClass provided by any source included in the namespace,
77 * or null if the name is not found.
78 * @exception AmbiguousNameException if the name matches with multiple imported modules.
80 TypeClass getTypeClass(String name) throws AmbiguousNameException;
82 TransformationRule getRule(String name) throws AmbiguousNameException;
83 MappingRelation getMappingRelation(String name) throws AmbiguousNameException;
86 * Find all values that share a common prefix and call a procedure for them.
87 * @param prefix A name prefix
88 * @param filter A filter that restricts the set of found values
89 * @param proc A procedure that is called for all found values
91 void findValuesForPrefix(String prefix, NamespaceFilter filter, TObjectProcedure<SCLValue> proc);
94 * Find all types that share a common prefix and call a consumer for them.
95 * @param prefix A name prefix
96 * @param filter A filter that restricts the set of found values
97 * @param consumer A procedure that is called for all found values
99 void findTypesForPrefix(String prefix, NamespaceFilter filter, Consumer<TCon> consumer);