export = [whoCalls, unusedDefinitions]
}
-import "SCL/Reflection"
+import "SCL/ModuleRepository"
@JavaType "org.simantics.scl.compiler.module.debug.SymbolReference"
data SymbolReference =
--- /dev/null
+module {
+ export = [moduleOfName, nameOfName, createName]
+}
+
+// Names
+
+importJava "org.simantics.scl.compiler.common.names.Name" where
+ data Name
+
+ @JavaName module
+ moduleOfName_ :: Name -> String
+ @JavaName name
+ nameOfName_ :: Name -> String
+
+ @JavaName create
+ createName_ :: String -> String -> Name
+
+instance Show Name where
+ sb <+ n = sb << moduleOfName n << "/" << nameOfName n
+
+moduleOfName = moduleOfName_
+nameOfName = nameOfName_
+createName = createName_
+
+// Locations
+
+type Location = Long
\ No newline at end of file
--- /dev/null
+include "./ModuleRepository"
+
+importJava "org.simantics.scl.compiler.environment.Environment" where
+ data Environment
+
+importJava "org.simantics.scl.compiler.runtime.RuntimeEnvironment" where
+ data RuntimeEnvironment
+
+importJava "org.simantics.scl.compiler.environment.specification.EnvironmentSpecification" where
+ data EnvironmentSpecification
+
+ fromList :: [(String,String)] -> EnvironmentSpecification
+
+importJava "org.simantics.scl.compiler.module.repository.ModuleRepository" where
+ @JavaName createRuntimeEnvironment
+ createRuntimeEnvironment_ :: ModuleRepository -> EnvironmentSpecification -> <Proc> RuntimeEnvironment
+
+createRuntimeEnvironment :: [(String,String)] -> <Proc> RuntimeEnvironment
+createRuntimeEnvironment = createRuntimeEnvironment_ MODULE_REPOSITORY . fromList
\ No newline at end of file
--- /dev/null
+include "./Environment"
+
+importJava "org.simantics.scl.compiler.top.ExpressionEvaluator" where
+ data ExpressionEvaluator
+
+ @JavaName "<init>"
+ createExpressionEvaluator :: RuntimeEnvironment -> String -> <Proc> ExpressionEvaluator
+
+ eval :: ExpressionEvaluator -> <Proc> a
+
+ expectedType :: ExpressionEvaluator -> Type -> <Proc> ExpressionEvaluator
+
+importJava "org.simantics.scl.compiler.top.SCLExpressionCompilationException" where
+ data SCLExpressionCompilationException
+
+data EvaluationModifier
+
+applyModifier evaluator _ = ()
+
+evaluateExpression :: Typeable a => RuntimeEnvironment -> [EvaluationModifier] -> String -> <Proc> a
+evaluateExpression runtimeEnvironment modifiers expression = do
+ evaluator = createExpressionEvaluator runtimeEnvironment expression
+ expectedType evaluator (typeOfProxy (TypeProxy :: TypeProxy a))
+ iter (applyModifier evaluator) modifiers
+ eval evaluator
+
+untypedEvaluateExpression :: RuntimeEnvironment -> [EvaluationModifier] -> String -> <Proc> a
+untypedEvaluateExpression runtimeEnvironment modifiers expression = do
+ evaluator = createExpressionEvaluator runtimeEnvironment expression
+ iter (applyModifier evaluator) modifiers
+ eval evaluator
\ No newline at end of file
--- /dev/null
+include "./Common"
+
+importJava "org.simantics.scl.compiler.module.Module" where
+ data Module
+
+ @JavaName getValueNames
+ valueNamesOf_ :: Module -> [String]
+
+valueNamesOf = valueNamesOf_
\ No newline at end of file
--- /dev/null
+module {
+ export = [possibleUnsafeSclValueByName, unsafeSclValueByName, sclModuleNames, moduleByName]
+}
+
+include "./CurrentModuleRepository"
+include "./Module"
+
+importJava "org.simantics.scl.compiler.module.repository.ModuleRepository" where
+ // data ModuleRepository
+ // defined in CurrentModuleRepository
+
+ @JavaName getValue
+ unsafeSclValueByName_ :: ModuleRepository -> String -> <Proc> a
+
+ @JavaName getSourceRepository
+ moduleSourceRepositoryOf :: ModuleRepository -> ModuleSourceRepository
+
+ @JavaName getModule
+ moduleByName_ :: ModuleRepository -> String -> <Proc> Failable Module
+
+importJava "org.simantics.scl.compiler.source.repository.ModuleSourceRepository" where
+ data ModuleSourceRepository
+
+ @JavaName getModuleNames
+ sclModuleNames_ :: ModuleSourceRepository -> [String]
+
+importJava "org.simantics.scl.compiler.errors.Failable" where
+ data Failable a
+
+ didSucceed :: Failable a -> Boolean
+ getResult :: Failable a -> Maybe a
+
+unsafeSclValueByName :: String -> <Proc> a
+unsafeSclValueByName = unsafeSclValueByName_ MODULE_REPOSITORY
+
+possibleUnsafeSclValueByName :: String -> <Proc> Maybe a
+possibleUnsafeSclValueByName name = Just (unsafeSclValueByName name) `catch` \(_ :: Exception) -> Nothing
+
+sclModuleNames :: <Proc> [String]
+sclModuleNames = sclModuleNames_ (moduleSourceRepositoryOf MODULE_REPOSITORY)
+
+moduleByName :: String -> <Proc> Maybe Module
+moduleByName name = getResult failable
+ where
+ failable = moduleByName_ MODULE_REPOSITORY name
\ No newline at end of file
module {
- export = [possibleUnsafeSclValueByName, unsafeSclValueByName, sclModuleNames, moduleByName,
- moduleOfName, nameOfName, createName, valueNamesOf]
+ deprecated = "Use more specialized modules like ModuleRepository"
}
-include "SCL/ReflectionJava"
-
-importJava "org.simantics.scl.compiler.module.repository.ModuleRepository" where
- @JavaName getValue
- unsafeSclValueByName_ :: ModuleRepository -> String -> <Proc> a
-
- @JavaName getSourceRepository
- moduleSourceRepositoryOf :: ModuleRepository -> ModuleSourceRepository
-
- @JavaName getModule
- moduleByName_ :: ModuleRepository -> String -> <Proc> Failable Module
-
-importJava "org.simantics.scl.compiler.source.repository.ModuleSourceRepository" where
- data ModuleSourceRepository
-
- @JavaName getModuleNames
- sclModuleNames_ :: ModuleSourceRepository -> [String]
-
-importJava "org.simantics.scl.compiler.errors.Failable" where
- data Failable a
-
- didSucceed :: Failable a -> Boolean
- getResult :: Failable a -> Maybe a
-
-importJava "org.simantics.scl.compiler.module.Module" where
- data Module
-
- @JavaName getValueNames
- valueNamesOf_ :: Module -> [String]
-
-importJava "org.simantics.scl.compiler.common.names.Name" where
- data Name
-
- @JavaName module
- moduleOfName_ :: Name -> String
- @JavaName name
- nameOfName_ :: Name -> String
-
- @JavaName create
- createName_ :: String -> String -> Name
-
-instance Show Name where
- sb <+ n = sb << moduleOfName n << "/" << nameOfName n
-
-moduleOfName = moduleOfName_
-nameOfName = nameOfName_
-createName = createName_
-valueNamesOf = valueNamesOf_
-
-type Location = Long
-
-unsafeSclValueByName :: String -> <Proc> a
-unsafeSclValueByName = unsafeSclValueByName_ MODULE_REPOSITORY
-
-possibleUnsafeSclValueByName :: String -> <Proc> Maybe a
-possibleUnsafeSclValueByName name = Just (unsafeSclValueByName name) `catch` \(_ :: Exception) -> Nothing
-
-sclModuleNames :: <Proc> [String]
-sclModuleNames = sclModuleNames_ (moduleSourceRepositoryOf MODULE_REPOSITORY)
-
-moduleByName :: String -> <Proc> Maybe Module
-moduleByName name = getResult failable
- where
- failable = moduleByName_ MODULE_REPOSITORY name
\ No newline at end of file
+include "./ModuleRepository"
\ No newline at end of file
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.compiler.types.kinds.Kinds;
-public class ReflectionJavaModule extends ConcreteModule {
+public class CurrentModuleRepositoryModule extends ConcreteModule {
- public static ReflectionJavaModule INSTANCE = new ReflectionJavaModule();
+ public static CurrentModuleRepositoryModule INSTANCE = new CurrentModuleRepositoryModule();
- public ReflectionJavaModule() {
- super("SCL/ReflectionJava");
+ public CurrentModuleRepositoryModule() {
+ super("SCL/CurrentModuleRepository");
// ModuleRepository type
TCon ModuleRepository = Types.con(getName(), "ModuleRepository");
package org.simantics.scl.compiler.environment.specification;
import java.util.ArrayList;
+import java.util.List;
import org.simantics.scl.compiler.module.ImportDeclaration;
+import org.simantics.scl.runtime.tuple.Tuple2;
public class EnvironmentSpecification {
public final ArrayList<ImportDeclaration> imports = new ArrayList<ImportDeclaration>();
spec.importModule(strings[i], strings[i+1]);
return spec;
}
+
+ public static EnvironmentSpecification fromList(List<Tuple2> imports) {
+ EnvironmentSpecification spec = new EnvironmentSpecification();
+ for(Tuple2 tuple : imports)
+ spec.importModule((String)tuple.c0, (String)tuple.c1);
+ return spec;
+ }
@Override
public int hashCode() {
return createRuntimeEnvironment(environmentSpecification, parentClassLoader, null);
}
+ public RuntimeEnvironment createRuntimeEnvironment(EnvironmentSpecification environmentSpecification) throws ImportFailureException {
+ return createRuntimeEnvironment(environmentSpecification, getClass().getClassLoader());
+ }
+
public RuntimeEnvironment createRuntimeEnvironment(
EnvironmentSpecification environmentSpecification,
ClassLoader parentClassLoader,
import org.simantics.scl.compiler.elaboration.java.JavaModule;
import org.simantics.scl.compiler.elaboration.java.LoggingModule;
import org.simantics.scl.compiler.elaboration.java.MinigraphModule;
-import org.simantics.scl.compiler.elaboration.java.ReflectionJavaModule;
+import org.simantics.scl.compiler.elaboration.java.CurrentModuleRepositoryModule;
public class BuiltinModuleSourceRepository extends MapModuleSourceRepository implements ModuleSourceRepository {
public BuiltinModuleSourceRepository() {
super(Builtins.INSTANCE,
JavaModule.INSTANCE,
- ReflectionJavaModule.INSTANCE,
+ CurrentModuleRepositoryModule.INSTANCE,
MinigraphModule.INSTANCE,
new LoggingModule());
}