本文整理汇总了C#中BinaryPhoenix.Fusion.Runtime.Scripting.ScriptThread.PassParameter方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptThread.PassParameter方法的具体用法?C# ScriptThread.PassParameter怎么用?C# ScriptThread.PassParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryPhoenix.Fusion.Runtime.Scripting.ScriptThread
的用法示例。
在下文中一共展示了ScriptThread.PassParameter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InvokeExportFunction
/// <summary>
/// Invokes a export function from a given script.
/// </summary>
/// <param name="symbol">Symbol of function to call.</param>
/// <param name="toThread">Thread to call function.</param>
/// <param name="fromThread">Thread to call function from.</param>
/// <returns>Memory index of new array.</returns>
public void InvokeExportFunction(FunctionSymbol symbol, ScriptThread toThread, ScriptThread fromThread)
{
// Can't invoke functions if debugging :S.
if (_debugger != null && _debugger.AllowInvokedFunctions == false && toThread == this)
return;
// Find the functions parameter types.
DataTypeValue[] parameterTypes = new DataTypeValue[symbol.ParameterCount];
for (int i = 0; i < symbol.ParameterCount; i++)
parameterTypes[i] = ((VariableSymbol)symbol.Symbols[i]).DataType;
// Push any parameters we have been given.
for (int i = 0; i < parameterTypes.Length; i++)
{
RuntimeValue parameter = fromThread._runtimeStack[(fromThread._runtimeStack.TopIndex - parameterTypes.Length) + i];
parameter.DataType = parameterTypes[i];
if (parameterTypes[i].IsArray == true)
toThread.PassParameterArray(CopyValueArrayFromThread(parameter, toThread, fromThread));
else
toThread.PassParameter(CopyValueFromThread(parameter, toThread, fromThread));
}
// Call the function.
toThread.InvokeFunction(symbol.Identifier, true, true);
// Copy the return register.
fromThread._registers[(int)Register.Return].DataType = symbol.ReturnType;
if (symbol.ReturnType.IsArray == true)
SetMemoryIndexValue(fromThread._registers[(int)Register.Return], CopyValueArrayFromThread(toThread._registers[(int)Register.Return], fromThread, toThread));
else
fromThread._registers[(int)Register.Return] = CopyValueFromThread(toThread._registers[(int)Register.Return], fromThread, toThread);
}