1 package org.simantics.scl.compiler.module;
3 import java.util.Collection;
4 import java.util.Collections;
6 import org.simantics.scl.compiler.elaboration.modules.Documentation;
7 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
8 import org.simantics.scl.compiler.elaboration.modules.TypeAlias;
9 import org.simantics.scl.compiler.elaboration.modules.TypeClass;
10 import org.simantics.scl.compiler.elaboration.modules.TypeClassInstance;
11 import org.simantics.scl.compiler.elaboration.modules.TypeConstructor;
12 import org.simantics.scl.compiler.elaboration.relations.SCLEntityType;
13 import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
14 import org.simantics.scl.compiler.elaboration.rules.MappingRelation;
15 import org.simantics.scl.compiler.elaboration.rules.TransformationRule;
16 import org.simantics.scl.compiler.internal.codegen.effects.EffectConstructor;
17 import org.simantics.scl.compiler.top.ModuleInitializer;
18 import org.simantics.scl.compiler.types.TCon;
19 import org.simantics.scl.runtime.profiling.BranchPoint;
21 import gnu.trove.map.hash.THashMap;
23 public abstract class LazyModule implements Module {
26 private THashMap<String, SCLValue> values = new THashMap<String, SCLValue>();
27 private THashMap<String, SCLRelation> relations = new THashMap<String, SCLRelation>();
28 private THashMap<String, SCLEntityType> entityTypes = new THashMap<String, SCLEntityType>();
30 protected abstract SCLValue createValue(String name);
32 protected SCLRelation createRelation(String name) {
36 protected SCLEntityType createEntityType(String name) {
41 public MappingRelation getMappingRelation(String name) {
46 public TransformationRule getRule(String name) {
50 public LazyModule(String moduleName) {
51 this.moduleName = moduleName;
55 public String getName() {
59 public void findValuesForPrefix(final Collection<SCLValue> values, final String prefix) {
63 public SCLValue getValue(String name) {
64 if(values.containsKey(name))
65 return values.get(name);
67 SCLValue value = createValue(name);
68 values.put(name, value);
73 public SCLRelation getRelation(String name) {
74 if(relations.containsKey(name))
75 return relations.get(name);
77 SCLRelation relation = createRelation(name);
78 relations.put(name, relation);
83 public SCLEntityType getEntityType(String name) {
84 if(entityTypes.containsKey(name))
85 return entityTypes.get(name);
87 SCLEntityType entityType = createEntityType(name);
88 entityTypes.put(name, entityType);
94 public TypeClass getTypeClass(String name) {
99 public Collection<TypeClassInstance> getInstances(TCon typeClass) {
100 return Collections.emptyList();
104 public TypeConstructor getTypeConstructor(String name) {
109 public Documentation getDocumentation() {
114 public byte[] getClass(String name) {
119 public ModuleInitializer getModuleInitializer() {
124 public EffectConstructor getEffectConstructor(String name) {
129 public TypeAlias getTypeAlias(String name) {
134 public Collection<TransformationRule> getRules() {
135 return Collections.emptyList();
139 public THashMap<String, BranchPoint[]> getBranchPoints() {