virtual bool Process()override { FNiagaraCompiler_VectorVM* VMCompiler = (FNiagaraCompiler_VectorVM*)Compiler; check(ResultLocation == ENiagaraExpressionResultLocation::Temporaries); ResultIndex = VMCompiler->AquireTemporary(); if (ResultIndex == INDEX_NONE) { return false; } FNiagaraExpression* ValidExpr = GetSourceExpression(0).Get(); check(SourceExpressions.Num() == 1); uint8 ValidIndex = VMCompiler->GetResultVMIndex(ValidExpr); int32 SharedDataSetIndex; VMCompiler->GetSharedDataIndex(DataSet, false, SharedDataSetIndex); check(SharedDataSetIndex <= 255) //TODO - Make this better, either ensure this is in a register by now or allow the VM to handle from constants? //Though, why you'd have the conditional come from a constant, IDK. if (!(ValidExpr->ResultLocation == ENiagaraExpressionResultLocation::Temporaries || ValidExpr->ResultLocation == ENiagaraExpressionResultLocation::InputData)) { VMCompiler->Error(LOCTEXT("CompileFaliure_CannotUseConstantForSharedDataValidMask", "Use of constants for the shared data valid mask is not supported currently."), NULL, NULL); return false; } VMCompiler->WriteCode(bWrap ? (uint8)EVectorVMOp::aquireshareddataindexwrap : (uint8)EVectorVMOp::aquireshareddataindex); VMCompiler->WriteCode(ResultIndex); VMCompiler->WriteCode(ValidIndex); VMCompiler->WriteCode((uint8)SharedDataSetIndex); return true; }
virtual bool Process()override { FNiagaraCompiler_VectorVM* VMCompiler = (FNiagaraCompiler_VectorVM*)Compiler; check(ResultLocation == ENiagaraExpressionResultLocation::SharedData); FNiagaraDataSetProperties* DataSetProps = VMCompiler->GetSharedDataIndex(Event, false, ResultIndex); int32 VarIndex = VMCompiler->GetSharedDataVariableIndex(DataSetProps, Result); FNiagaraExpression* IndexExpr = GetSourceExpression(0).Get(); FNiagaraExpression* DataExpr = GetSourceExpression(1).Get(); check(SourceExpressions.Num() == 2); uint8 IndexIndex = VMCompiler->GetResultVMIndex(IndexExpr); uint8 DataIndex = VMCompiler->GetResultVMIndex(DataExpr); //TODO - Make this better, either ensure this is in a register by now or allow the VM to handle from constants? //Though, why you'd have the conditional come from a constant, IDK. if (!(DataExpr->ResultLocation == ENiagaraExpressionResultLocation::Temporaries || DataExpr->ResultLocation == ENiagaraExpressionResultLocation::InputData)) { VMCompiler->Error(LOCTEXT("CompileFaliure_CannotWriteConstantToSharedData", "Writing of constants to shared data is not currently supported"), NULL, NULL); return false; } check(IndexExpr->ResultLocation == ENiagaraExpressionResultLocation::Temporaries); VMCompiler->WriteCode((uint8)EVectorVMOp::shareddatawrite); VMCompiler->WriteCode(ResultIndex);//Set idx VMCompiler->WriteCode(VarIndex);//Index of variable buffer in the set. VMCompiler->WriteCode(IndexIndex);//Index of the temporary buffer that contains the data index. VMCompiler->WriteCode(DataIndex);//Temp buffer index for the data to write. return true; }