use of org.finos.legend.pure.m3.serialization.filesystem.PureCodeStorage in project legend-pure by finos.
the class M3CoreInstanceGenerator method main.
public static void main(String[] args) {
String outputDir = args[0];
String factoryNamePrefix = args[1];
String fileNameStr = args[2];
ListIterable<String> filePaths = StringIterate.tokensToList(fileNameStr, ",");
PureRuntime runtime = new PureRuntimeBuilder(new PureCodeStorage(Paths.get(""), new ClassLoaderCodeStorage(CodeRepository.newPlatformCodeRepository()))).setTransactionalByDefault(false).build();
ModelRepository repository = runtime.getModelRepository();
runtime.loadAndCompileCore();
M3ToJavaGenerator m3ToJavaGenerator = generator(outputDir, factoryNamePrefix, repository);
m3ToJavaGenerator.generate(repository, filePaths);
}
use of org.finos.legend.pure.m3.serialization.filesystem.PureCodeStorage in project legend-pure by finos.
the class JavaClassLoaderSourceCodeGenerator method gen.
public static void gen(long start, Path filePath, String name, MutableList<CompiledExtension> extensions) {
RichIterable<CodeRepository> repositoriesForCompilation = Lists.fixedSize.of(CodeRepository.newPlatformCodeRepository());
PureCodeStorage codeStorage = new PureCodeStorage(null, new ClassLoaderCodeStorage(repositoriesForCompilation));
ClassLoaderPureGraphCache graphCache = new ClassLoaderPureGraphCache();
PureRuntime runtime = new PureRuntimeBuilder(codeStorage).withCache(graphCache).setTransactionalByDefault(false).buildAndTryToInitializeFromCache();
if (!runtime.isInitialized()) {
CacheState cacheState = graphCache.getCacheState();
if (cacheState != null) {
String lastStackTrace = cacheState.getLastStackTrace();
if (lastStackTrace != null) {
System.out.println("Cache initialization failure: " + lastStackTrace);
}
}
System.out.println("Initialization from caches failed - compiling from scratch");
runtime.reset();
runtime.loadAndCompileCore();
runtime.loadAndCompileSystem();
}
System.out.format("Finished Pure initialization (%.6fs)%n", (System.nanoTime() - start) / 1_000_000_000.0);
JavaSourceCodeGenerator javaSourceCodeGenerator = new JavaSourceCodeGenerator(runtime.getProcessorSupport(), runtime.getCodeStorage(), true, filePath, false, extensions, name, JavaPackageAndImportBuilder.externalizablePackage());
javaSourceCodeGenerator.generateCode();
javaSourceCodeGenerator.generatePureCoreHelperClasses(new ProcessorContext(runtime.getProcessorSupport(), false));
}
use of org.finos.legend.pure.m3.serialization.filesystem.PureCodeStorage in project legend-pure by finos.
the class TestJavaStandaloneLibraryGenerator method setUp.
@BeforeClass
public static void setUp() {
MutableCodeStorage codeStorage = new PureCodeStorage(null, new ClassLoaderCodeStorage(CodeRepository.newPlatformCodeRepository()), new EmptyCodeStorage(new GenericCodeRepository("test", "test::.*", PlatformCodeRepository.NAME)));
setUpRuntime(codeStorage, codeStorage.getAllRepositories(), Tuples.pair("/test/standalone/tests.pure", "import test::standalone::*;\n" + "\n" + "Enum test::standalone::TestEnumeration\n" + "{\n" + " TYPE1, TYPE2, TYPE3\n" + "}\n" + "\n" + "Class test::standalone::TestClassA\n" + "{\n" + " name : String[1];\n" + "}\n" + "\n" + "Class test::standalone::TestClassB\n" + "{\n" + " id:Integer[1];\n" + " type:TestEnumeration[1];\n" + "}\n" + "\n" + "Association test::standalone::TestAssociation\n" + "{\n" + " toA:TestClassA[1];\n" + " toB:TestClassB[1];\n" + "}\n" + "\n" + "function <<access.externalizable>> test::standalone::joinWithCommas(strings:String[*]):String[1]\n" + "{\n" + " $strings->joinStrings(', ');\n" + "}\n" + "\n" + "function <<access.externalizable>> test::standalone::testWithReflection(prefix:String[1]):String[1]\n" + "{\n" + " let f = testWithReflection_String_1__String_1_;\n" + " let class = TestClassA;\n" + " let association = TestAssociation;\n" + " let b = ^TestClassB(id=43, type=TestEnumeration.TYPE3, toA=^TestClassA(name=$prefix));\n" + " if($class == $association, |'ERROR', |$b.toA.name + $f.functionName->toOne());\n" + "}\n"));
}
use of org.finos.legend.pure.m3.serialization.filesystem.PureCodeStorage in project legend-pure by finos.
the class TestCoreCompiledStateIntegrity method initialize.
@BeforeClass
public static void initialize() {
MutableCodeStorage codeStorage = new PureCodeStorage(null, new ClassLoaderCodeStorage(Lists.mutable.with(CodeRepository.newPlatformCodeRepository()).withAll(CodeRepositoryProviderHelper.findCodeRepositories())));
initialize(codeStorage);
}
use of org.finos.legend.pure.m3.serialization.filesystem.PureCodeStorage in project legend-pure by finos.
the class Test_PureTestSuite method getClassLoaderExecutionSupport.
public static CompiledExecutionSupport getClassLoaderExecutionSupport() {
MutableList<CodeRepository> codeRepos = Lists.mutable.of(CodeRepository.newPlatformCodeRepository()).withAll(CodeRepositoryProviderHelper.findCodeRepositories());
ClassLoader classLoader = Test_PureTestSuite.class.getClassLoader();
return new CompiledExecutionSupport(new JavaCompilerState(null, classLoader), new CompiledProcessorSupport(classLoader, MetadataLazy.fromClassLoader(classLoader), Sets.mutable.empty()), null, new PureCodeStorage(null, new ClassLoaderCodeStorage(classLoader, codeRepos)), null, null, new ConsoleCompiled(), new FunctionCache(), new ClassCache(classLoader), null, Sets.mutable.empty());
}
Aggregations