]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/scl/SCL/ModuleRepository.scl
Compilation of SCL expressions from SCL
[simantics/platform.git] / bundles / org.simantics.scl.compiler / scl / SCL / ModuleRepository.scl
1 module {
2     export = [possibleUnsafeSclValueByName, unsafeSclValueByName, sclModuleNames, moduleByName]
3 }
4
5 include "./CurrentModuleRepository"
6 include "./Module"
7
8 importJava "org.simantics.scl.compiler.module.repository.ModuleRepository" where
9     // data ModuleRepository
10     // defined in CurrentModuleRepository
11
12     @JavaName getValue
13     unsafeSclValueByName_ :: ModuleRepository -> String -> <Proc> a
14     
15     @JavaName getSourceRepository
16     moduleSourceRepositoryOf :: ModuleRepository -> ModuleSourceRepository
17     
18     @JavaName getModule
19     moduleByName_ :: ModuleRepository -> String -> <Proc> Failable Module 
20     
21 importJava "org.simantics.scl.compiler.source.repository.ModuleSourceRepository" where
22     data ModuleSourceRepository
23     
24     @JavaName getModuleNames
25     sclModuleNames_ :: ModuleSourceRepository -> [String]
26
27 importJava "org.simantics.scl.compiler.errors.Failable" where
28     data Failable a
29     
30     didSucceed :: Failable a -> Boolean
31     getResult :: Failable a -> Maybe a 
32
33 unsafeSclValueByName :: String -> <Proc> a
34 unsafeSclValueByName = unsafeSclValueByName_ MODULE_REPOSITORY
35
36 possibleUnsafeSclValueByName :: String -> <Proc> Maybe a
37 possibleUnsafeSclValueByName name = Just (unsafeSclValueByName name) `catch` \(_ :: Exception) -> Nothing
38
39 sclModuleNames :: <Proc> [String]
40 sclModuleNames = sclModuleNames_ (moduleSourceRepositoryOf MODULE_REPOSITORY)
41
42 moduleByName :: String -> <Proc> Maybe Module
43 moduleByName name = getResult failable
44   where
45     failable = moduleByName_ MODULE_REPOSITORY name