Search in sources :

Example 1 with ActionInfo

use of org.ballerinalang.util.codegen.ActionInfo 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);
}
Also used : ResourceInfo(org.ballerinalang.util.codegen.ResourceInfo) StructInfo(org.ballerinalang.util.codegen.StructInfo) PackageInfo(org.ballerinalang.util.codegen.PackageInfo) ActionInfo(org.ballerinalang.util.codegen.ActionInfo) LineNumberInfo(org.ballerinalang.util.codegen.LineNumberInfo) ProgramFile(org.ballerinalang.util.codegen.ProgramFile)

Example 2 with ActionInfo

use of org.ballerinalang.util.codegen.ActionInfo in project ballerina by ballerina-lang.

the class CPU method invokeAction.

private static WorkerExecutionContext invokeAction(WorkerExecutionContext ctx, String actionName, int[] argRegs, int[] retRegs, int flags) {
    BConnector connector = (BConnector) ctx.workerLocal.refRegs[argRegs[0]];
    if (connector == null) {
        ctx.setError(BLangVMErrors.createNullRefException(ctx));
        handleError(ctx);
        return null;
    }
    BConnectorType actualCon = (BConnectorType) connector.getConnectorType();
    ActionInfo actionInfo = ctx.programFile.getPackageInfo(actualCon.getPackagePath()).getConnectorInfo(actualCon.getName()).getActionInfo(actionName);
    return BLangFunctions.invokeCallable(actionInfo, ctx, argRegs, retRegs, false, flags);
}
Also used : BConnector(org.ballerinalang.model.values.BConnector) BConnectorType(org.ballerinalang.model.types.BConnectorType) ActionInfo(org.ballerinalang.util.codegen.ActionInfo)

Aggregations

ActionInfo (org.ballerinalang.util.codegen.ActionInfo)2 BConnectorType (org.ballerinalang.model.types.BConnectorType)1 BConnector (org.ballerinalang.model.values.BConnector)1 LineNumberInfo (org.ballerinalang.util.codegen.LineNumberInfo)1 PackageInfo (org.ballerinalang.util.codegen.PackageInfo)1 ProgramFile (org.ballerinalang.util.codegen.ProgramFile)1 ResourceInfo (org.ballerinalang.util.codegen.ResourceInfo)1 StructInfo (org.ballerinalang.util.codegen.StructInfo)1