1 package org.simantics.scl.compiler.module;
3 import java.util.Collection;
4 import java.util.Collections;
7 import org.simantics.scl.compiler.constants.Constant;
8 import org.simantics.scl.compiler.elaboration.chr.CHRRuleset;
9 import org.simantics.scl.compiler.elaboration.modules.Documentation;
10 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
11 import org.simantics.scl.compiler.elaboration.modules.TypeClass;
12 import org.simantics.scl.compiler.elaboration.modules.TypeClassInstance;
13 import org.simantics.scl.compiler.elaboration.modules.TypeDescriptor;
14 import org.simantics.scl.compiler.elaboration.relations.SCLEntityType;
15 import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
16 import org.simantics.scl.compiler.elaboration.rules.MappingRelation;
17 import org.simantics.scl.compiler.elaboration.rules.TransformationRule;
18 import org.simantics.scl.compiler.errors.CompilationError;
19 import org.simantics.scl.compiler.internal.codegen.effects.EffectConstructor;
20 import org.simantics.scl.compiler.top.ModuleInitializer;
21 import org.simantics.scl.compiler.types.TCon;
22 import org.simantics.scl.runtime.profiling.BranchPoint;
24 import gnu.trove.map.hash.THashMap;
26 public abstract class LazyModule implements Module {
29 private THashMap<String, SCLValue> values = new THashMap<String, SCLValue>();
30 private THashMap<String, SCLRelation> relations = new THashMap<String, SCLRelation>();
31 private THashMap<String, SCLEntityType> entityTypes = new THashMap<String, SCLEntityType>();
33 protected abstract SCLValue createValue(String name);
35 protected SCLRelation createRelation(String name) {
39 protected SCLEntityType createEntityType(String name) {
44 public MappingRelation getMappingRelation(String name) {
49 public TransformationRule getRule(String name) {
53 public LazyModule(String moduleName) {
54 this.moduleName = moduleName;
58 public String getName() {
62 public void findValuesForPrefix(final Collection<SCLValue> values, final String prefix) {
66 public SCLValue getValue(String name) {
67 if(values.containsKey(name))
68 return values.get(name);
70 SCLValue value = createValue(name);
71 values.put(name, value);
77 public List<Constant> getFieldAccessors(String name) {
81 public SCLRelation getRelation(String name) {
82 if(relations.containsKey(name))
83 return relations.get(name);
85 SCLRelation relation = createRelation(name);
86 relations.put(name, relation);
91 public SCLEntityType getEntityType(String name) {
92 if(entityTypes.containsKey(name))
93 return entityTypes.get(name);
95 SCLEntityType entityType = createEntityType(name);
96 entityTypes.put(name, entityType);
102 public TypeClass getTypeClass(String name) {
107 public Collection<TypeClassInstance> getInstances(TCon typeClass) {
108 return Collections.emptyList();
112 public TypeDescriptor getTypeDescriptor(String name) {
117 public Documentation getDocumentation() {
122 public byte[] getClass(String name) {
127 public ModuleInitializer getModuleInitializer() {
132 public EffectConstructor getEffectConstructor(String name) {
137 public Collection<TransformationRule> getRules() {
138 return Collections.emptyList();
142 public THashMap<String, BranchPoint[]> getBranchPoints() {
147 public CompilationError[] getWarnings() {
148 return CompilationError.EMPTY_ARRAY;
152 public CHRRuleset getRuleset(String name) {
157 public String getDeprecation() {