]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/module/LazyModule.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / module / LazyModule.java
diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/module/LazyModule.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/module/LazyModule.java
new file mode 100644 (file)
index 0000000..54914dd
--- /dev/null
@@ -0,0 +1,142 @@
+package org.simantics.scl.compiler.module;
+
+import gnu.trove.map.hash.THashMap;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.simantics.scl.compiler.elaboration.modules.Documentation;
+import org.simantics.scl.compiler.elaboration.modules.SCLValue;
+import org.simantics.scl.compiler.elaboration.modules.TypeAlias;
+import org.simantics.scl.compiler.elaboration.modules.TypeClass;
+import org.simantics.scl.compiler.elaboration.modules.TypeClassInstance;
+import org.simantics.scl.compiler.elaboration.modules.TypeConstructor;
+import org.simantics.scl.compiler.elaboration.relations.SCLEntityType;
+import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
+import org.simantics.scl.compiler.elaboration.rules.MappingRelation;
+import org.simantics.scl.compiler.elaboration.rules.TransformationRule;
+import org.simantics.scl.compiler.internal.codegen.effects.EffectConstructor;
+import org.simantics.scl.compiler.top.ModuleInitializer;
+import org.simantics.scl.compiler.types.TCon;
+import org.simantics.scl.runtime.profiling.BranchPoint;
+
+public abstract class LazyModule implements Module {
+
+    String moduleName;
+    private THashMap<String, SCLValue> values = new THashMap<String, SCLValue>();
+    private THashMap<String, SCLRelation> relations = new THashMap<String, SCLRelation>();
+    private THashMap<String, SCLEntityType> entityTypes = new THashMap<String, SCLEntityType>();
+    
+    protected abstract SCLValue createValue(String name);
+    
+    protected SCLRelation createRelation(String name) {
+        return null;
+    }
+    
+    protected SCLEntityType createEntityType(String name) {
+        return null;
+    }
+    
+    @Override
+    public MappingRelation getMappingRelation(String name) {
+        return null;
+    }
+    
+    @Override
+    public TransformationRule getRule(String name) {
+        return null;
+    }
+    
+    public LazyModule(String moduleName) {
+        this.moduleName = moduleName;
+    }
+        
+    @Override
+    public String getName() {
+        return moduleName;
+    }
+    
+    public void findValuesForPrefix(final Collection<SCLValue> values, final String prefix) {          
+    }
+
+    @Override
+    public SCLValue getValue(String name) {
+        if(values.containsKey(name))
+            return values.get(name);
+        else {
+            SCLValue value = createValue(name);
+            values.put(name, value);
+            return value;
+        }
+    }
+    
+    public SCLRelation getRelation(String name) {
+        if(relations.containsKey(name))
+            return relations.get(name);
+        else {
+            SCLRelation relation = createRelation(name);
+            relations.put(name, relation);
+            return relation;
+        }
+    }
+    
+    public SCLEntityType getEntityType(String name) {
+        if(entityTypes.containsKey(name))
+            return entityTypes.get(name);
+        else {
+            SCLEntityType entityType = createEntityType(name);
+            entityTypes.put(name, entityType);
+            return entityType;
+        }
+    } 
+
+    @Override
+    public TypeClass getTypeClass(String name) {
+        return null;
+    }
+   
+    @Override
+    public Collection<TypeClassInstance> getInstances(TCon typeClass) {
+        return Collections.emptyList();
+    }
+
+    @Override
+    public TypeConstructor getTypeConstructor(String name) {
+        return null;
+    }
+
+    @Override
+    public Documentation getDocumentation() {
+        return null;
+    }
+    
+    @Override
+    public byte[] getClass(String name) {
+        return null;
+    }
+    
+    @Override
+    public ModuleInitializer getModuleInitializer() {
+        return null;
+    }
+    
+    @Override
+    public EffectConstructor getEffectConstructor(String name) {
+        return null;
+    }
+    
+    @Override
+    public TypeAlias getTypeAlias(String name) {
+        return null;
+    }
+    
+    @Override
+    public Collection<TransformationRule> getRules() {
+        return Collections.emptyList();
+    }
+    
+    @Override
+    public THashMap<String, BranchPoint[]> getBranchPoints() {
+        return null;
+    }
+}