use of org.ballerinalang.util.codegen.PackageInfo in project ballerina by ballerina-lang.
the class BLangVMErrors method createCallCancelledException.
public static BStruct createCallCancelledException(CallableUnitInfo callableUnitInfo) {
PackageInfo errorPackageInfo = callableUnitInfo.getPackageInfo().getProgramFile().getPackageInfo(PACKAGE_RUNTIME);
StructInfo errorStructInfo = errorPackageInfo.getStructInfo(STRUCT_CALL_FAILED_EXCEPTION);
return generateError(callableUnitInfo, true, errorStructInfo, MSG_CALL_CANCELLED);
}
use of org.ballerinalang.util.codegen.PackageInfo in project ballerina by ballerina-lang.
the class BLangVMErrors method generateError.
private static BStruct generateError(WorkerExecutionContext context, boolean attachCallStack, Object... values) {
PackageInfo errorPackageInfo = context.programFile.getPackageInfo(PACKAGE_BUILTIN);
StructInfo errorStructInfo = errorPackageInfo.getStructInfo(STRUCT_GENERIC_ERROR);
return generateError(context, attachCallStack, errorStructInfo, values);
}
use of org.ballerinalang.util.codegen.PackageInfo in project ballerina by ballerina-lang.
the class ConnectorUtils method createAndGetStruct.
/**
* This method is used to create a struct given the context and required struct details.
*
* @param context to get program file.
* @param packagePath of the struct.
* @param structName of the struct.
* @return created struct.
* @throws BallerinaConnectorException if an error occurs
*/
public static BStruct createAndGetStruct(Context context, String packagePath, String structName) throws BallerinaConnectorException {
PackageInfo packageInfo = context.getProgramFile().getPackageInfo(packagePath);
if (packageInfo == null) {
throw new BallerinaConnectorException("package - " + packagePath + " does not exist");
}
StructInfo structInfo = packageInfo.getStructInfo(structName);
if (structInfo == null) {
throw new BallerinaConnectorException("struct - " + structName + " does not exist");
}
BStructType structType = structInfo.getType();
BStruct bStruct = new BStruct(structType);
return bStruct;
}
use of org.ballerinalang.util.codegen.PackageInfo in project ballerina by ballerina-lang.
the class FileUtils method createAccessDeniedError.
public static BStruct createAccessDeniedError(Context context, String msg) {
PackageInfo filePkg = context.getProgramFile().getPackageInfo(FILE_PACKAGE);
StructInfo accessErrInfo = filePkg.getStructInfo(ACCESS_DENIED_ERROR);
return BLangVMStructs.createBStruct(accessErrInfo, msg);
}
use of org.ballerinalang.util.codegen.PackageInfo in project ballerina by ballerina-lang.
the class AbstractAnnotationReader method createAnnotationStructArray.
private BRefValueArray createAnnotationStructArray(Context context, BValue map) {
if (map == null || map.getType().getTag() != BTypes.typeMap.getTag()) {
return null;
}
final PackageInfo packageInfo = context.getProgramFile().getPackageInfo(PKG_INTERNAL);
final StructInfo structInfo = packageInfo.getStructInfo(STRUCT_ANNOTATION);
BRefValueArray annotationArray = new BRefValueArray(structInfo.getType());
BMap<String, BValue> annotationMap = (BMap<String, BValue>) map;
long index = 0;
for (String key : annotationMap.keySet()) {
final String annotaionQName = key.split("\\$")[0];
final String[] qNameParts = annotaionQName.split(":");
final BStruct annotation = BLangVMStructs.createBStruct(structInfo, qNameParts[1], qNameParts[0], annotationMap.get(key));
annotationArray.add(index++, annotation);
}
return annotationArray;
}
Aggregations