]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/module/LazyModule.java
a53a90b916e8bb8ca7bb6e210f91e13077e54a9d
[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 import java.util.List;
6
7 import org.simantics.scl.compiler.constants.Constant;
8 import org.simantics.scl.compiler.elaboration.modules.Documentation;
9 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
10 import org.simantics.scl.compiler.elaboration.modules.TypeClass;
11 import org.simantics.scl.compiler.elaboration.modules.TypeClassInstance;
12 import org.simantics.scl.compiler.elaboration.modules.TypeDescriptor;
13 import org.simantics.scl.compiler.elaboration.relations.SCLEntityType;
14 import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
15 import org.simantics.scl.compiler.elaboration.rules.MappingRelation;
16 import org.simantics.scl.compiler.elaboration.rules.TransformationRule;
17 import org.simantics.scl.compiler.errors.CompilationError;
18 import org.simantics.scl.compiler.internal.codegen.effects.EffectConstructor;
19 import org.simantics.scl.compiler.top.ModuleInitializer;
20 import org.simantics.scl.compiler.types.TCon;
21 import org.simantics.scl.runtime.profiling.BranchPoint;
22
23 import gnu.trove.map.hash.THashMap;
24
25 public abstract class LazyModule implements Module {
26
27     String moduleName;
28     private THashMap<String, SCLValue> values = new THashMap<String, SCLValue>();
29     private THashMap<String, SCLRelation> relations = new THashMap<String, SCLRelation>();
30     private THashMap<String, SCLEntityType> entityTypes = new THashMap<String, SCLEntityType>();
31     
32     protected abstract SCLValue createValue(String name);
33     
34     protected SCLRelation createRelation(String name) {
35         return null;
36     }
37     
38     protected SCLEntityType createEntityType(String name) {
39         return null;
40     }
41     
42     @Override
43     public MappingRelation getMappingRelation(String name) {
44         return null;
45     }
46     
47     @Override
48     public TransformationRule getRule(String name) {
49         return null;
50     }
51     
52     public LazyModule(String moduleName) {
53         this.moduleName = moduleName;
54     }
55         
56     @Override
57     public String getName() {
58         return moduleName;
59     }
60     
61     public void findValuesForPrefix(final Collection<SCLValue> values, final String prefix) {           
62     }
63
64     @Override
65     public SCLValue getValue(String name) {
66         if(values.containsKey(name))
67             return values.get(name);
68         else {
69             SCLValue value = createValue(name);
70             values.put(name, value);
71             return value;
72         }
73     }
74     
75     @Override
76     public List<Constant> getFieldAccessors(String name) {
77         return null;
78     }
79     
80     public SCLRelation getRelation(String name) {
81         if(relations.containsKey(name))
82             return relations.get(name);
83         else {
84             SCLRelation relation = createRelation(name);
85             relations.put(name, relation);
86             return relation;
87         }
88     }
89     
90     public SCLEntityType getEntityType(String name) {
91         if(entityTypes.containsKey(name))
92             return entityTypes.get(name);
93         else {
94             SCLEntityType entityType = createEntityType(name);
95             entityTypes.put(name, entityType);
96             return entityType;
97         }
98     } 
99
100     @Override
101     public TypeClass getTypeClass(String name) {
102         return null;
103     }
104    
105     @Override
106     public Collection<TypeClassInstance> getInstances(TCon typeClass) {
107         return Collections.emptyList();
108     }
109
110     @Override
111     public TypeDescriptor getTypeDescriptor(String name) {
112         return null;
113     }
114
115     @Override
116     public Documentation getDocumentation() {
117         return null;
118     }
119     
120     @Override
121     public byte[] getClass(String name) {
122         return null;
123     }
124     
125     @Override
126     public ModuleInitializer getModuleInitializer() {
127         return null;
128     }
129     
130     @Override
131     public EffectConstructor getEffectConstructor(String name) {
132         return null;
133     }
134     
135     @Override
136     public Collection<TransformationRule> getRules() {
137         return Collections.emptyList();
138     }
139     
140     @Override
141     public THashMap<String, BranchPoint[]> getBranchPoints() {
142         return null;
143     }
144     
145     @Override
146     public CompilationError[] getWarnings() {
147         return CompilationError.EMPTY_ARRAY;
148     }
149 }