本文整理汇总了C#中ScriptExecutionContext.GetCallingCoroutine方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptExecutionContext.GetCallingCoroutine方法的具体用法?C# ScriptExecutionContext.GetCallingCoroutine怎么用?C# ScriptExecutionContext.GetCallingCoroutine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScriptExecutionContext
的用法示例。
在下文中一共展示了ScriptExecutionContext.GetCallingCoroutine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: running
public static DynValue running(ScriptExecutionContext executionContext, CallbackArguments args)
{
Coroutine C = executionContext.GetCallingCoroutine();
return DynValue.NewTuple(DynValue.NewCoroutine(C), DynValue.NewBoolean(C.State == CoroutineState.Main));
}
示例2: traceback
public static DynValue traceback(ScriptExecutionContext executionContext, CallbackArguments args)
{
var sb = new StringBuilder();
var vmessage = args[0];
var vlevel = args[1];
var defaultSkip = 1.0;
var cor = executionContext.GetCallingCoroutine();
if (vmessage.Type == DataType.Thread)
{
cor = vmessage.Coroutine;
vmessage = args[1];
vlevel = args[2];
defaultSkip = 0.0;
}
if (vmessage.IsNotNil() && vmessage.Type != DataType.String && vmessage.Type != DataType.Number)
{
return vmessage;
}
var message = vmessage.CastToString();
var skip = (int) ((vlevel.CastToNumber()) ?? defaultSkip);
var stacktrace = cor.GetStackTrace(Math.Max(0, skip));
if (message != null)
sb.AppendLine(message);
sb.AppendLine("stack traceback:");
foreach (var wi in stacktrace)
{
string name;
if (wi.Name == null)
if (wi.RetAddress < 0)
name = "main chunk";
else
name = "?";
else
name = "function '" + wi.Name + "'";
var loc = wi.Location != null ? wi.Location.FormatLocation(executionContext.GetScript()) : "[clr]";
sb.AppendFormat("\t{0}: in {1}\n", loc, name);
}
return DynValue.NewString(sb);
}
示例3: status
public static DynValue status(ScriptExecutionContext executionContext, CallbackArguments args)
{
DynValue handle = args.AsType(0, "status", DataType.Thread);
Coroutine running = executionContext.GetCallingCoroutine();
CoroutineState cs = handle.Coroutine.State;
switch (cs)
{
case CoroutineState.Main:
case CoroutineState.Running:
return (handle.Coroutine == running) ?
DynValue.NewString("running") :
DynValue.NewString("normal");
case CoroutineState.NotStarted:
case CoroutineState.Suspended:
return DynValue.NewString("suspended");
case CoroutineState.Dead:
return DynValue.NewString("dead");
default:
throw new InternalErrorException("Unexpected coroutine state {0}", cs);
}
}