Search in sources :

Example 1 with PackageVarInfo

use of org.ballerinalang.util.codegen.PackageVarInfo 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());
}
Also used : BMap(org.ballerinalang.model.values.BMap) PackageInfo(org.ballerinalang.util.codegen.PackageInfo) PackageVarInfo(org.ballerinalang.util.codegen.PackageVarInfo) LockableStructureType(org.ballerinalang.model.values.LockableStructureType)

Example 2 with PackageVarInfo

use of org.ballerinalang.util.codegen.PackageVarInfo 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());
}
Also used : BStruct(org.ballerinalang.model.values.BStruct) PackageInfo(org.ballerinalang.util.codegen.PackageInfo) PackageVarInfo(org.ballerinalang.util.codegen.PackageVarInfo)

Aggregations

PackageInfo (org.ballerinalang.util.codegen.PackageInfo)2 PackageVarInfo (org.ballerinalang.util.codegen.PackageVarInfo)2 BMap (org.ballerinalang.model.values.BMap)1 BStruct (org.ballerinalang.model.values.BStruct)1 LockableStructureType (org.ballerinalang.model.values.LockableStructureType)1