private static Strand invokeVirtualFunction(Strand ctx, StackFrame sf, int receiver, FunctionInfo virtualFuncInfo, int[] argRegs, int retReg, int flags) { BMap<String, BValue> structVal = (BMap<String, BValue>) sf.refRegs[receiver]; // TODO use ObjectTypeInfo once record init function is removed StructureTypeInfo structInfo = (StructureTypeInfo) ((BStructureType) structVal.getType()).getTypeInfo(); FunctionInfo attachedFuncInfo = structInfo.funcInfoEntries.get(virtualFuncInfo.getName()); return invokeCallable(ctx, attachedFuncInfo, argRegs, retReg, flags); }
private void updateAttachFunctionInfo(PackageInfo packageInfo, BType attachedType, String funcName, FunctionInfo functionInfo) throws IOException { // Append the receiver type to the parameter types. This is done because in the VM, // first parameter will always be the attached type. These param types will be used // to allocate worker local data. // This is the only place where we append the receiver to the params. BType[] paramTypes = Stream.concat(Stream.of(functionInfo.attachedToType), Stream.of(functionInfo.getParamTypes())) .toArray(BType[]::new); functionInfo.setParamTypes(paramTypes); if (attachedType.getTag() != TypeTags.OBJECT_TYPE_TAG && attachedType.getTag() != TypeTags.RECORD_TYPE_TAG) { return; } //Update the attachedFunctionInfo String objectInit; BStructureType structType = (BStructureType) attachedType; if (attachedType.getTag() == TypeTags.OBJECT_TYPE_TAG) { objectInit = CONSTRUCTOR_FUNCTION_SUFFIX; } else { objectInit = structType.getName() + INIT_FUNCTION_SUFFIX; } StructureTypeInfo typeInfo = (StructureTypeInfo) structType.getTypeInfo(); typeInfo.funcInfoEntries.put(funcName, functionInfo); // Setting the object initializer if (objectInit.equals(funcName)) { typeInfo.initializer = functionInfo; } }
StructureTypeInfo structInfo = (StructureTypeInfo) structType.getTypeInfo(); for (StructFieldInfo fieldInfo : structInfo.getFieldInfoEntries()) { BType fieldType = fieldInfo.getFieldType();
private static BMap<String, BValue> convertMapToStruct(Strand ctx, BMap<String, BValue> bMap, BStructureType structType) { BMap<String, BValue> bStruct = new BMap<>(structType); StructureTypeInfo structInfo = (StructureTypeInfo) structType.getTypeInfo();
structVal.getType()).getTypeInfo(); FunctionInfo attachedFuncInfo = structInfo.funcInfoEntries .get(funcRefCPEntry.getFunctionInfo().getName());