]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/module/LazyModule.java
Merge "List the unsatisfied dependencies in CanvasContext"
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / module / LazyModule.java
1 package org.simantics.scl.compiler.module;
2
3 import java.util.Collection;
4 import java.util.Collections;
5
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.TypeDescriptor;
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;
20
21 import gnu.trove.map.hash.THashMap;
22
23 public abstract class LazyModule implements Module {
24
25     String moduleName;
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>();
29     
30     protected abstract SCLValue createValue(String name);
31     
32     protected SCLRelation createRelation(String name) {
33         return null;
34     }
35     
36     protected SCLEntityType createEntityType(String name) {
37         return null;
38     }
39     
40     @Override
41     public MappingRelation getMappingRelation(String name) {
42         return null;
43     }
44     
45     @Override
46     public TransformationRule getRule(String name) {
47         return null;
48     }
49     
50     public LazyModule(String moduleName) {
51         this.moduleName = moduleName;
52     }
53         
54     @Override
55     public String getName() {
56         return moduleName;
57     }
58     
59     public void findValuesForPrefix(final Collection<SCLValue> values, final String prefix) {           
60     }
61
62     @Override
63     public SCLValue getValue(String name) {
64         if(values.containsKey(name))
65             return values.get(name);
66         else {
67             SCLValue value = createValue(name);
68             values.put(name, value);
69             return value;
70         }
71     }
72     
73     public SCLRelation getRelation(String name) {
74         if(relations.containsKey(name))
75             return relations.get(name);
76         else {
77             SCLRelation relation = createRelation(name);
78             relations.put(name, relation);
79             return relation;
80         }
81     }
82     
83     public SCLEntityType getEntityType(String name) {
84         if(entityTypes.containsKey(name))
85             return entityTypes.get(name);
86         else {
87             SCLEntityType entityType = createEntityType(name);
88             entityTypes.put(name, entityType);
89             return entityType;
90         }
91     } 
92
93     @Override
94     public TypeClass getTypeClass(String name) {
95         return null;
96     }
97    
98     @Override
99     public Collection<TypeClassInstance> getInstances(TCon typeClass) {
100         return Collections.emptyList();
101     }
102
103     @Override
104     public TypeDescriptor getTypeDescriptor(String name) {
105         return null;
106     }
107
108     @Override
109     public Documentation getDocumentation() {
110         return null;
111     }
112     
113     @Override
114     public byte[] getClass(String name) {
115         return null;
116     }
117     
118     @Override
119     public ModuleInitializer getModuleInitializer() {
120         return null;
121     }
122     
123     @Override
124     public EffectConstructor getEffectConstructor(String name) {
125         return null;
126     }
127     
128     @Override
129     public Collection<TransformationRule> getRules() {
130         return Collections.emptyList();
131     }
132     
133     @Override
134     public THashMap<String, BranchPoint[]> getBranchPoints() {
135         return null;
136     }
137 }