]> gerrit.simantics Code Review - simantics/platform.git/blob
cbac0c85ac213df1a0b7cdcaf1c61836a9dfc58b
[simantics/platform.git] /
1 package org.simantics.scl.compiler.runtime;
2
3 import gnu.trove.map.hash.THashMap;
4
5 import org.simantics.scl.compiler.environment.Environment;
6
7 public class RuntimeEnvironmentImpl implements RuntimeEnvironment {
8
9     private final Environment environment;
10     private final THashMap<String, RuntimeModule> runtimeModuleMap;
11     private final ClassLoader parentClassLoader;
12     private MutableClassLoader classLoader;
13     
14     public RuntimeEnvironmentImpl(Environment environment,
15             ClassLoader parentClassLoader,
16             THashMap<String, RuntimeModule> runtimeModuleMap) {
17         this.environment = environment;
18         this.parentClassLoader = parentClassLoader;
19         this.runtimeModuleMap = runtimeModuleMap;
20     }
21
22     @Override
23     public Environment getEnvironment() {
24         return environment;
25     }
26
27     @Override
28     public RuntimeModule getRuntimeModule(String name) {
29         return runtimeModuleMap.get(name);
30     }
31
32     @Override
33     public synchronized MutableClassLoader getMutableClassLoader() {
34         if(classLoader == null)
35             classLoader = new ExpressionClassLoader(
36                     parentClassLoader, runtimeModuleMap, "Expression");
37         return classLoader;
38     }
39
40 }