use of org.ballerinalang.util.codegen.PackageInfo in project ballerina by ballerina-lang.
the class BLangProgramRunner method runMain.
public static void runMain(ProgramFile programFile, String[] args) {
if (!programFile.isMainEPAvailable()) {
throw new BallerinaException("main function not found in '" + programFile.getProgramFilePath() + "'");
}
PackageInfo mainPkgInfo = programFile.getEntryPackage();
if (mainPkgInfo == null) {
throw new BallerinaException("main function not found in '" + programFile.getProgramFilePath() + "'");
}
Debugger debugger = new Debugger(programFile);
initDebugger(programFile, debugger);
boolean distributedTxEnabled = CompilerUtils.isDistributedTransactionsEnabled();
programFile.setDistributedTransactionEnabled(distributedTxEnabled);
FunctionInfo mainFuncInfo = getMainFunction(mainPkgInfo);
try {
BLangFunctions.invokeEntrypointCallable(programFile, mainPkgInfo, mainFuncInfo, extractMainArgs(args));
} finally {
if (debugger.isDebugEnabled()) {
debugger.notifyExit();
}
BLangFunctions.invokeVMUtilFunction(mainPkgInfo.getStopFunctionInfo());
}
}
use of org.ballerinalang.util.codegen.PackageInfo in project ballerina by ballerina-lang.
the class BLangProgramRunner method runService.
public static void runService(ProgramFile programFile) {
if (!programFile.isServiceEPAvailable()) {
throw new BallerinaException("no services found in '" + programFile.getProgramFilePath() + "'");
}
// Get the service package
PackageInfo servicesPackage = programFile.getEntryPackage();
if (servicesPackage == null) {
throw new BallerinaException("no services found in '" + programFile.getProgramFilePath() + "'");
}
Debugger debugger = new Debugger(programFile);
initDebugger(programFile, debugger);
boolean distributedTxEnabled = CompilerUtils.isDistributedTransactionsEnabled();
programFile.setDistributedTransactionEnabled(distributedTxEnabled);
// Invoke package init function
BLangFunctions.invokePackageInitFunction(servicesPackage.getInitFunctionInfo());
BLangFunctions.invokeVMUtilFunction(servicesPackage.getStartFunctionInfo());
}
use of org.ballerinalang.util.codegen.PackageInfo in project ballerina by ballerina-lang.
the class BLangConnectorSPIUtil method getPackageEndpoint.
public static BStruct getPackageEndpoint(ProgramFile programFile, String pkgName, String endpointName) {
final PackageInfo packageInfo = programFile.getPackageInfo(pkgName);
if (packageInfo == null) {
throw new BallerinaConnectorException("Incorrect package name");
}
final PackageVarInfo packageVarInfo = packageInfo.getPackageVarInfo(endpointName);
if (packageVarInfo == null) {
throw new BallerinaConnectorException("Can't locate " + endpointName + " endpoint variable");
}
return (BStruct) programFile.getGlobalMemoryBlock().getRefField(packageVarInfo.getGlobalMemIndex());
}
use of org.ballerinalang.util.codegen.PackageInfo in project ballerina by ballerina-lang.
the class BLangConnectorSPIUtil method createBStruct.
public static BStruct createBStruct(ProgramFile programFile, String pkgPath, String structName, Object... values) {
PackageInfo packageInfo = programFile.getPackageInfo(pkgPath);
if (packageInfo == null) {
throw new BallerinaConnectorException("package - " + pkgPath + " does not exist");
}
StructInfo structInfo = packageInfo.getStructInfo(structName);
if (structInfo == null) {
throw new BallerinaConnectorException("struct - " + structName + " does not exist");
}
return BLangVMStructs.createBStruct(structInfo, values);
}
use of org.ballerinalang.util.codegen.PackageInfo in project ballerina by ballerina-lang.
the class BCompileUtil method createAndGetStruct.
public static BStruct createAndGetStruct(ProgramFile programFile, String packagePath, String structName) {
PackageInfo structPackageInfo = programFile.getPackageInfo(packagePath);
StructInfo structInfo = structPackageInfo.getStructInfo(structName);
BStructType structType = structInfo.getType();
return new BStruct(structType);
}
Aggregations