当前位置: 首页>>代码示例>>C#>>正文


C# ScriptExecutionContext.GetCallingCoroutine方法代码示例

本文整理汇总了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));
		}
开发者ID:RainsSoft,项目名称:moonsharp,代码行数:5,代码来源:CoroutineModule.cs

示例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);
        }
开发者ID:eddy5641,项目名称:moonsharp,代码行数:53,代码来源:DebugModule.cs

示例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);
			}
	
		}
开发者ID:RainsSoft,项目名称:moonsharp,代码行数:23,代码来源:CoroutineModule.cs


注:本文中的ScriptExecutionContext.GetCallingCoroutine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。