use of org.ballerinalang.util.codegen.StructInfo in project ballerina by ballerina-lang.
the class ClientSocketTest method testOpenWithProperties.
@Test(dependsOnMethods = "testClosure", description = "Test connection open with properties")
public void testOpenWithProperties() {
int port = ThreadLocalRandom.current().nextInt(33000, 46000);
PackageInfo ioPackageInfo = socketClient.getProgFile().getPackageInfo("ballerina.io");
StructInfo socketProperties = ioPackageInfo.getStructInfo("SocketProperties");
BStruct propertyStruct = BLangVMStructs.createBStruct(socketProperties, port);
BValue[] args = { new BString("localhost"), new BInteger(MockSocketServer.SERVER_PORT), propertyStruct };
final BValue[] returns = BRunUtil.invoke(socketClient, "openSocketConnectionWithProps", args);
final BStruct socket = (BStruct) returns[0];
Assert.assertEquals(socket.getIntField(1), port, "Client port didn't bind to assign port.");
args = new BValue[] { socket };
BRunUtil.invoke(socketClient, "close", args);
}
use of org.ballerinalang.util.codegen.StructInfo in project ballerina by ballerina-lang.
the class CPU method createNewStruct.
private static void createNewStruct(WorkerExecutionContext ctx, int[] operands, WorkerData sf) {
int cpIndex = operands[0];
int i = operands[1];
StructureRefCPEntry structureRefCPEntry = (StructureRefCPEntry) ctx.constPool[cpIndex];
StructInfo structInfo = (StructInfo) structureRefCPEntry.getStructureTypeInfo();
sf.refRegs[i] = new BStruct(structInfo.getType());
}
use of org.ballerinalang.util.codegen.StructInfo in project ballerina by ballerina-lang.
the class BLangVMErrors method createNullRefException.
/* Type Specific Errors */
public static BStruct createNullRefException(Context context) {
PackageInfo errorPackageInfo = context.getProgramFile().getPackageInfo(PACKAGE_RUNTIME);
StructInfo errorStructInfo = errorPackageInfo.getStructInfo(STRUCT_NULL_REF_EXCEPTION);
return generateError(context.getCallableUnitInfo(), true, errorStructInfo, "");
}
use of org.ballerinalang.util.codegen.StructInfo 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.StructInfo 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);
}
Aggregations