X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fscl%2FSCL%2FModuleRepository.scl;fp=bundles%2Forg.simantics.scl.compiler%2Fscl%2FSCL%2FModuleRepository.scl;h=eceb418be1a70c5a439737888c491681c040c5b9;hb=7444d4b3a2f3c25fac462d8a168898656dafd52e;hp=0000000000000000000000000000000000000000;hpb=da4210cb095e4acd25ddba55a86aa6fe0b18301d;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/scl/SCL/ModuleRepository.scl b/bundles/org.simantics.scl.compiler/scl/SCL/ModuleRepository.scl new file mode 100644 index 000000000..eceb418be --- /dev/null +++ b/bundles/org.simantics.scl.compiler/scl/SCL/ModuleRepository.scl @@ -0,0 +1,45 @@ +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 -> a + + @JavaName getSourceRepository + moduleSourceRepositoryOf :: ModuleRepository -> ModuleSourceRepository + + @JavaName getModule + moduleByName_ :: ModuleRepository -> String -> 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 -> a +unsafeSclValueByName = unsafeSclValueByName_ MODULE_REPOSITORY + +possibleUnsafeSclValueByName :: String -> Maybe a +possibleUnsafeSclValueByName name = Just (unsafeSclValueByName name) `catch` \(_ :: Exception) -> Nothing + +sclModuleNames :: [String] +sclModuleNames = sclModuleNames_ (moduleSourceRepositoryOf MODULE_REPOSITORY) + +moduleByName :: String -> Maybe Module +moduleByName name = getResult failable + where + failable = moduleByName_ MODULE_REPOSITORY name \ No newline at end of file