def prepare(self): if self.model_ast.output_size > 1: print_code = PRINT_VECTOR else: print_code = PRINT_SCALAR executor_code = EXECUTOR_CODE_TPL.format( model_code=self.interpreter.interpret(self.model_ast), print_code=print_code) self.script_path = self._resource_tmp_dir / f"{self.model_name}.rb" utils.write_content_to_file(executor_code, self.script_path)
def prepare(self): # Create files generated by exporter in the temp dir. code = export_to_java(self.model, class_name=self.class_name) code_file_name = self._resource_tmp_dir / f"{self.class_name}.java" utils.write_content_to_file(code, code_file_name) # Move Executor.java to the same temp dir. module_path = Path(__file__).absolute().parent executor_path = self._resource_tmp_dir / "Executor.java" copyfile(module_path / "Executor.java", executor_path) # Compile all files together. subprocess.call( [str(self._javac_bin), str(code_file_name), str(executor_path)])
def prepare(self): if self.model_ast.output_size > 1: print_code = EXECUTE_AND_PRINT_VECTOR else: print_code = EXECUTE_AND_PRINT_SCALAR executor_code = EXECUTOR_CODE_TPL.format(print_code=print_code) model_code = self.interpreter.interpret(self.model_ast) model_file_name = self._global_tmp_dir / "Model.vb" executor_file_name = self._global_tmp_dir / "Program.vb" utils.write_content_to_file(model_code, model_file_name) utils.write_content_to_file(executor_code, executor_file_name) subprocess.call([ "dotnet", "build", str(self._global_tmp_dir / f"{self.project_name}.vbproj"), "--output", str(self.target_exec_dir) ])
def prepare(self): if self.model_ast.output_size > 1: execute_code = EXECUTE_VECTOR else: execute_code = EXECUTE_SCALAR executor_code = EXECUTOR_CODE_TPL.format( model_code=self.interpreter.interpret(self.model_ast), execute_code=execute_code) executor_file_name = self._resource_tmp_dir / f"{self.model_name}.rs" utils.write_content_to_file(executor_code, executor_file_name) self.exec_path = self._resource_tmp_dir / self.model_name subprocess.call([ "rustc", str(executor_file_name), "-o", str(self.exec_path) ])
def prepare(self): if self.model_ast.output_size > 1: print_code = EXECUTE_AND_PRINT_VECTOR_TPL.format( size=self.model_ast.output_size) else: print_code = EXECUTE_AND_PRINT_SCALAR executor_code = EXECUTOR_CODE_TPL.format( model_code=self.interpreter.interpret(self.model_ast), print_code=print_code) file_name = self._resource_tmp_dir / f"{self.model_name}.c" utils.write_content_to_file(executor_code, file_name) self.exec_path = self._resource_tmp_dir / self.model_name flags = ["-std=c99", "-lm"] subprocess.call( ["gcc", str(file_name), "-o", str(self.exec_path), *flags])
def prepare(self): if self.model_ast.output_size > 1: print_code = EXECUTE_AND_PRINT_VECTOR else: print_code = EXECUTE_AND_PRINT_SCALAR executor_code = EXECUTOR_CODE_TPL.format( model_code=self.interpreter.interpret(self.model_ast), print_code=print_code) file_name = self._resource_tmp_dir / f"{self.model_name}.go" utils.write_content_to_file(executor_code, file_name) self.exec_path = self._resource_tmp_dir / self.model_name subprocess.call([ "go", "build", "-o", str(self.exec_path), str(file_name) ])
def prepare(self): if self.model_ast.output_size > 1: print_code = PRINT_VECTOR else: print_code = PRINT_SCALAR executor_code = EXECUTOR_CODE_TPL.format( executor_name=self.executor_name, model_name=self.model_name, print_code=print_code) model_code = self.interpreter.interpret(self.model_ast) executor_file_name = self._resource_tmp_dir / f"{self.executor_name}.hs" model_file_name = self._resource_tmp_dir / f"{self.model_name}.hs" utils.write_content_to_file(executor_code, executor_file_name) utils.write_content_to_file(model_code, model_file_name) self.exec_path = self._resource_tmp_dir / self.executor_name subprocess.call([ "ghc", str(executor_file_name), f"-i{self._resource_tmp_dir}", "-o", str(self.exec_path) ])
def prepare(self): executor_code = EXECUTOR_CODE_TPL.format( model_code=self.interpreter.interpret(self.model_ast)) self.script_path = self._resource_tmp_dir / f"{self.model_name}.ps1" utils.write_content_to_file(executor_code, self.script_path)
def prepare(self): code = export_to_javascript(self.model) self.script_path = self._resource_tmp_dir / "model.js" utils.write_content_to_file(code, self.script_path)
def prepare(self): code = export_to_python(self.model) file_name = self._resource_tmp_dir / "model.py" write_content_to_file(code, file_name)