use of org.ballerinalang.util.codegen.PackageInfo in project ballerina by ballerina-lang.
the class BLangVMErrors method getStackFrame.
public static BStruct getStackFrame(CallableUnitInfo callableUnitInfo, int ip) {
if (callableUnitInfo == null) {
return null;
}
ProgramFile progFile = callableUnitInfo.getPackageInfo().getProgramFile();
PackageInfo runtimePackage = progFile.getPackageInfo(PACKAGE_RUNTIME);
StructInfo callStackElement = runtimePackage.getStructInfo(STRUCT_CALL_STACK_ELEMENT);
int currentIP = ip - 1;
Object[] values;
values = new Object[4];
String parentScope = "";
if (callableUnitInfo instanceof ResourceInfo) {
parentScope = ((ResourceInfo) callableUnitInfo).getServiceInfo().getName() + ".";
} else if (callableUnitInfo instanceof ActionInfo) {
parentScope = ((ActionInfo) callableUnitInfo).getConnectorInfo().getName() + ".";
}
values[0] = parentScope + callableUnitInfo.getName();
values[1] = callableUnitInfo.getPkgPath();
if (callableUnitInfo.isNative()) {
values[2] = "<native>";
values[3] = 0;
} else {
LineNumberInfo lineNumberInfo = callableUnitInfo.getPackageInfo().getLineNumberInfo(currentIP);
if (lineNumberInfo != null) {
values[2] = lineNumberInfo.getFileName();
values[3] = lineNumberInfo.getLineNumber();
}
}
return BLangVMStructs.createBStruct(callStackElement, values);
}
use of org.ballerinalang.util.codegen.PackageInfo in project ballerina by ballerina-lang.
the class BLangVMErrors method createIllegalStateException.
public static BStruct createIllegalStateException(Context context, String msg) {
PackageInfo errorPackageInfo = context.getProgramFile().getPackageInfo(PACKAGE_RUNTIME);
StructInfo errorStructInfo = errorPackageInfo.getStructInfo(STRUCT_ILLEGAL_STATE_EXCEPTION);
return createError(context, true, errorStructInfo, msg);
}
use of org.ballerinalang.util.codegen.PackageInfo in project ballerina by ballerina-lang.
the class BLangVMErrors method createNullRefException.
public static BStruct createNullRefException(CallableUnitInfo callableUnitInfo) {
ProgramFile progFile = callableUnitInfo.getPackageInfo().getProgramFile();
PackageInfo errorPackageInfo = progFile.getPackageInfo(PACKAGE_RUNTIME);
StructInfo errorStructInfo = errorPackageInfo.getStructInfo(STRUCT_NULL_REF_EXCEPTION);
return generateError(callableUnitInfo, true, errorStructInfo);
}
use of org.ballerinalang.util.codegen.PackageInfo in project ballerina by ballerina-lang.
the class BLangVMErrors method createNullRefException.
public static BStruct createNullRefException(WorkerExecutionContext context) {
PackageInfo errorPackageInfo = context.programFile.getPackageInfo(PACKAGE_RUNTIME);
StructInfo errorStructInfo = errorPackageInfo.getStructInfo(STRUCT_NULL_REF_EXCEPTION);
return generateError(context, true, errorStructInfo);
}
use of org.ballerinalang.util.codegen.PackageInfo in project ballerina by ballerina-lang.
the class ConnectorSPIModelHelper method getAnnotationVariable.
public static BMap getAnnotationVariable(String pkgPath, ProgramFile programFile) {
PackageInfo packageInfo = programFile.getPackageInfo(pkgPath);
PackageVarInfo annotationData = packageInfo.getPackageVarInfo(ANNOTATION_DATA);
final LockableStructureType globalMemoryBlock = programFile.getGlobalMemoryBlock();
return (BMap) globalMemoryBlock.getRefField(annotationData.getGlobalMemIndex());
}
Aggregations