package org.simantics.scl.compiler.runtime; import gnu.trove.map.hash.THashMap; import org.simantics.scl.compiler.environment.Environment; public class RuntimeEnvironmentImpl implements RuntimeEnvironment { private final Environment environment; private final THashMap runtimeModuleMap; private final ClassLoader parentClassLoader; private MutableClassLoader classLoader; public RuntimeEnvironmentImpl(Environment environment, ClassLoader parentClassLoader, THashMap runtimeModuleMap) { this.environment = environment; this.parentClassLoader = parentClassLoader; this.runtimeModuleMap = runtimeModuleMap; } @Override public Environment getEnvironment() { return environment; } @Override public RuntimeModule getRuntimeModule(String name) { return runtimeModuleMap.get(name); } @Override public synchronized MutableClassLoader getMutableClassLoader() { if(classLoader == null) classLoader = new ExpressionClassLoader( parentClassLoader, runtimeModuleMap, "Expression"); return classLoader; } }