• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Interpreter.ScriptThread类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Irony.Interpreter.ScriptThread的典型用法代码示例。如果您正苦于以下问题:C# ScriptThread类的具体用法?C# ScriptThread怎么用?C# ScriptThread使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ScriptThread类属于Irony.Interpreter命名空间,在下文中一共展示了ScriptThread类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: EvaluateSpecialForm

 // Evaluation for special forms
 private object EvaluateSpecialForm(ScriptThread thread)
 {
     thread.CurrentNode = this;  //standard prolog
       var result = _specialForm(thread, _specialFormArgs);
       thread.CurrentNode = Parent; //standard epilog
       return result;
 }
开发者ID:MarcusTheBold,项目名称:Irony,代码行数:8,代码来源:FunctionCallNode.cs


示例2: DoEvaluate

        protected override object DoEvaluate(ScriptThread thread)
        {
            thread.CurrentNode = this;  //standard prolog
            var pi = thread.GetPageInfo();

            var test = globalNode.AsString.ToLower();
            if (test.Contains(":")) {
                Console.WriteLine("");
            }
            if ( test == "pagenumber") {
                return pi.PageNumber;
            } else if (test == "pages") {
                return pi.TotalPages;
            } else if (test == "reportname") {
                return pi.ReportName;
            } else if (test == "reportfolder") {
                return pi.ReportFolder;
            } else if (test == "reportfilename") {
                return pi.ReportFileName;
            }

            else {
                return String.Format(CultureInfo.CurrentCulture,"Syntaxerror in Globals <{0}>",globalNode.AsString);
            }
        }
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:25,代码来源:GlobalsNode.cs


示例3: ExtractLibraryFunctions

		public static LibraryFunction[] ExtractLibraryFunctions(ScriptThread thread, object instance)
		{
			if (instance == null)
				return new LibraryFunction[0];

			var list = new List<LibraryFunction>();
			var languageCaseSensitive = thread.App.Language.Grammar.CaseSensitive;

			MethodInfo[] methods = instance.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
			foreach (MethodInfo method in methods)
			{
				var fun = method.CreateDelegate<LibraryDelegate>(instance, false);
				if (fun != null)
				{
					var fname = method.GetCustomAttribute<FunctionNamesAttribute>();
					var names = (fname == null) ? new string[] { method.Name } : fname.Names;
					foreach (var strName in names)
					{
						string name = languageCaseSensitive ? strName : strName.ToLowerInvariant();
						list.Add(new LibraryFunction(name, fun));
					}
				}
			}

			return list.ToArray();
		}
开发者ID:Rezura,项目名称:LiveSplit,代码行数:26,代码来源:LibraryFunction.cs


示例4: Sum

		public static object Sum(ScriptThread thread, AstNode[] childNodes) {
			double sum =  0;
			var fieldName = childNodes[0].Evaluate(thread).ToString();
			
			var dataSource = thread.GetDataSource();
			
			var grouped = ImportAggregateHelper.IsGrouped(dataSource);
			
			if (grouped != null) {
				
				foreach (var element in grouped) {
					var s = element.Sum(o => {
					                    	var v = ReadValueFromObject(fieldName, o);
					                    	return TypeNormalizer.EnsureType<double>(v);
					                    });
					sum = sum + s;
				}
			} else {
				if (ImportAggregateHelper.FieldExist(dataSource.FirstOrDefault(),fieldName)) {
					sum = dataSource.Sum(o => {
					                     	var v = ReadValueFromObject(fieldName, o);
					                     	return TypeNormalizer.EnsureType<double>(v);
					                     });
				}
			}
			return sum.ToString();
		}
开发者ID:fanyjie,项目名称:SharpDevelop,代码行数:27,代码来源:ImportAggregates.cs


示例5: DoEvaluate

		protected override object DoEvaluate(ScriptThread thread)
		{
			// standard prolog
			thread.CurrentNode = this;

			if (EntryPoint == null)
			{
				thread.ThrowScriptError("No entry point defined (entry point is a function named «Go»)");
				return null;
			}

			// define built-in runtime library functions
			var libraryFunctions = LibraryFunction.ExtractLibraryFunctions(thread, new RefalLibrary(thread));
			foreach (var libFun in libraryFunctions)
			{
				var binding = thread.Bind(libFun.Name, BindingRequestFlags.Write | BindingRequestFlags.ExistingOrNew);
				binding.SetValueRef(thread, libFun);
			}

			// define functions declared in the compiled program
			foreach (var fun in FunctionList)
			{
				fun.Evaluate(thread);
			}

			// call entry point with an empty expression
			EntryPoint.Call(thread, new object[] { PassiveExpression.Build() });

			// standard epilog
			thread.CurrentNode = Parent;
			return null;
		}
开发者ID:androdev4u,项目名称:XLParser,代码行数:32,代码来源:Program.cs


示例6: Iif

        public static object Iif(ScriptThread thread, AstNode[] childNodes)
        {
            var testValue = childNodes[0].Evaluate(thread);
            object result = thread.Runtime.IsTrue(testValue) ? childNodes[1].Evaluate(thread) : childNodes[2].Evaluate(thread);
            return result;

        }
开发者ID:HyperSharp,项目名称:Hyperspace.DotLua,代码行数:7,代码来源:SpecialFormsLibrary.cs


示例7: DoEvaluate

 protected override object DoEvaluate(ScriptThread thread)
 {
     thread.CurrentNode = this;  //standard prolog
       //assign implementation method
       switch (Op) {
     case ExpressionType.AndAlso:
       this.Evaluate = EvaluateAndAlso;
       break;
     case ExpressionType.OrElse:
       this.Evaluate = EvaluateOrElse;
       break;
     default:
       this.Evaluate = DefaultEvaluateImplementation;
       break;
       }
       // actually evaluate and get the result.
       var result = Evaluate(thread);
       // Check if result is constant - if yes, save the value and switch to method that directly returns the result.
       if (IsConstant()) {
     _constValue = result;
     AsString = Op + "(operator) Const=" + _constValue;
     this.Evaluate = EvaluateConst;
       }
       thread.CurrentNode = Parent; //standard epilog
       return result;
 }
开发者ID:MarcusTheBold,项目名称:Irony,代码行数:26,代码来源:BinaryOperationNode.cs


示例8: DoEvaluate

        protected override object DoEvaluate(ScriptThread thread)
        {
            thread.CurrentNode = this;
            try
            {
                var result = new MtResult();
                var targetThread = _target.NewScriptThread(thread);
                var rTarget = _target.Evaluate(targetThread) as MtResult;

                var sourceThread = _source.NewScriptThread(thread);
                var rSource = _source.Evaluate(sourceThread) as MtResult;

                rTarget.GetValue(target =>
                {
                    rSource.GetValue(source =>
                    {
                        MtStream.ReadFromWriteTo(
                            source.Value as MtStream, target.Value as MtStream, () => {
                                result.SetValue(MtObject.True);
                            });
                    });
                });

                return result;
            }
            catch (Exception e)
            {
                throw new Exception("Exception on MtFlowRightToLeft.DoEvaluate", e);
            }
            finally
            {
                //thread.CurrentNode = Parent;
            }
        }
开发者ID:fabriceleal,项目名称:Multitasks,代码行数:34,代码来源:MtFlowRightToLeft.cs


示例9: DoEvaluate

		protected override object DoEvaluate(ScriptThread thread)
		{
			// standard prolog
			thread.CurrentNode = this;
			object result = null;

			// is this variable a part of a pattern?
			if (UseType == NodeUseType.Name)
			{
				// don't evaluate it
				result = CreateVariable();
			}
			else
			{
				// get last recognized pattern
				var pattern = thread.GetLastPattern();
				if (pattern == null)
				{
					thread.ThrowScriptError("No pattern recognized!");
					return null;
				}

				// read variable from the last recognized pattern
				result = pattern.GetVariable(Index);
			}

			// standard epilog
			thread.CurrentNode = Parent;
			return result;
		}
开发者ID:androdev4u,项目名称:XLParser,代码行数:30,代码来源:Variable.cs


示例10: ReallyDoEvaluate

        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            Context.CurrentAct = actnumber;
            thread.rs().Action.At(Span).Label(actnumber);

            return base.ReallyDoEvaluate(thread);
        }
开发者ID:jamescurran,项目名称:ShakespeareCompiler,代码行数:7,代码来源:PlayAST.cs


示例11: DoEvaluate

		protected override object DoEvaluate(ScriptThread thread)
		{
			// standard prolog
			thread.CurrentNode = this;

			var binding = thread.Bind(FunctionName, BindingRequestFlags.Read);
			var result = binding.GetValueRef(thread);
			if (result == null)
			{
				thread.ThrowScriptError("Unknown identifier: {0}", FunctionName);
				return null;
			}

			CallTarget = result as ICallTarget;
			if (CallTarget == null)
			{
				thread.ThrowScriptError("This identifier cannot be called: {0}", FunctionName);
				return null;
			}

			// set Evaluate pointer
			Evaluate = DoCall;

			// standard epilog is done by DoCall
			return DoCall(thread);
		}
开发者ID:Rezura,项目名称:LiveSplit,代码行数:26,代码来源:FunctionCall.cs


示例12: DoEvaluate

 protected override object DoEvaluate(ScriptThread thread)
 {
     thread.CurrentNode = this;  //standard prolog
       var arg = Argument.Evaluate(thread);
       var result = thread.Runtime.ExecuteUnaryOperator(base.ExpressionType, arg, ref _lastUsed);
       thread.CurrentNode = Parent; //standard epilog
       return result;
 }
开发者ID:MarcusTheBold,项目名称:Irony,代码行数:8,代码来源:UnaryOperationNode.cs


示例13: DoEvaluate

 protected override object DoEvaluate(ScriptThread thread)
 {
     thread.CurrentNode = this;  //standard prolog
       SetupEvaluateMethod(thread);
       var result = Evaluate(thread);
       thread.CurrentNode = Parent; //standard epilog
       return result;
 }
开发者ID:MarcusTheBold,项目名称:Irony,代码行数:8,代码来源:FunctionCallNode.cs


示例14: RefalLibrary

		public RefalLibrary(ScriptThread thread)
		{
			ScriptThread = thread;
			OpenFiles = new Dictionary<string, object>();
			BuriedKeys = new Dictionary<string, PassiveExpression>();
			BuriedValues = new Dictionary<string, PassiveExpression>();
			CommandLineArguments = null;
		}
开发者ID:PrototypeAlpha,项目名称:LiveSplit,代码行数:8,代码来源:RefalLibrary.cs


示例15: DoEvaluate

        protected override object DoEvaluate(ScriptThread thread)
        {
            thread.CurrentNode = this;
            try
            {
                var programResult = new MtResult();

                // do NOT use this for anything else other than counting the number of to-finish-threads
                var count = _chains.Count;
                var waitForAllToEnd = new ManualResetEvent(false);

                // TODO THIS NEEDS TO BE FIXED!
                // The rest of the program only cares about the result of the last expression
                // which doesn't depend of the result of the previous expressions;
                // however, the program shouldn't end.
                // SOLUTION: Keep a global counter of all awaiting MtResults?

                for (int i = 0; i < _chains.Count; ++i)
                {
                    // This is here because of issues with closures using the for variable
                    var safe_i = i + 0;
                    var ch = _chains[i];
                    var subthread = ch.NewScriptThread(thread);
                    var chResult = ch.Evaluate(subthread) as MtResult;

                    // Lookout:
                    // do not capture anything loop related inside here
                    chResult.GetValue(delegate(MtObject x)
                    {
                        if (Interlocked.Decrement(ref count) == 0)
                        {
                            waitForAllToEnd.Set();
                        }

                        // Wait for the last chain to end.
                        // Last refers in the order of the chain in the code,
                        // not the order of execution!!!
                        if (safe_i == _chains.Count - 1)
                        {
                            // Wait for the end of *all* the chains before returning ...
                            waitForAllToEnd.WaitOne();
                            programResult.SetValue(x);
                        }
                    });
                }

                // Return value does not matter. This is asynchronous, remember?
                return programResult;
            }
            catch (Exception e)
            {
                throw new Exception("Exception on MtProgram.", e);
            }
            finally
            {
                //thread.CurrentNode = Parent;
            }
        }
开发者ID:fabriceleal,项目名称:Multitasks,代码行数:58,代码来源:MtFork.cs


示例16: EvaluateAfter

 private object EvaluateAfter(ScriptThread thread)
 {
     thread.CurrentNode = this;  //standard prolog
       var closure = new Closure(thread.CurrentScope, this);
       if (NameNode != null)
     NameNode.SetValue(thread, closure);
       thread.CurrentNode = Parent; //standard epilog
       return closure;
 }
开发者ID:MarcusTheBold,项目名称:Irony,代码行数:9,代码来源:FunctionDefNode.cs


示例17: DefaultEvaluateImplementation

 protected object DefaultEvaluateImplementation(ScriptThread thread)
 {
     thread.CurrentNode = this;  //standard prolog
       var arg1 = Left.Evaluate(thread);
       var arg2 = Right.Evaluate(thread);
       var result = thread.Runtime.ExecuteBinaryOperator(this.Op, arg1, arg2, ref _lastUsed);
       thread.CurrentNode = Parent; //standard epilog
       return result;
 }
开发者ID:MarcusTheBold,项目名称:Irony,代码行数:9,代码来源:BinaryOperationNode.cs


示例18: DoEvaluate

 //Executed only once, on the first call
 protected override object DoEvaluate(ScriptThread thread)
 {
     thread.CurrentNode = this;  //standard prolog
       _accessor = thread.Bind(Symbol, BindingRequestFlags.Read);
       this.Evaluate = _accessor.GetValueRef; // Optimization - directly set method ref to accessor's method. EvaluateReader;
       var result = this.Evaluate(thread);
       thread.CurrentNode = Parent; //standard epilog
       return result;
 }
开发者ID:MarcusTheBold,项目名称:Irony,代码行数:10,代码来源:IdentifierNode.cs


示例19: BindingRequest

 public BindingRequest(ScriptThread thread, AstNode fromNode, string symbol, BindingRequestFlags flags) {
   Thread = thread;
   FromNode = fromNode;
   FromModule = thread.App.DataMap.GetModule(fromNode.ModuleNode);
   Symbol = symbol;
   Flags = flags;
   FromScopeInfo = thread.CurrentScope.Info;
   IgnoreCase = !thread.Runtime.Language.Grammar.CaseSensitive;
 }
开发者ID:androdev4u,项目名称:XLParser,代码行数:9,代码来源:BindingRequest.cs


示例20: DoSetValue

 public override void DoSetValue(ScriptThread thread, object value)
 {
     thread.CurrentNode = this;  //standard prolog
       if (_accessor == null) {
     _accessor = thread.Bind(Symbol, BindingRequestFlags.Write | BindingRequestFlags.ExistingOrNew);
       }
       _accessor.SetValueRef(thread, value);
       thread.CurrentNode = Parent;  //standard epilog
 }
开发者ID:MarcusTheBold,项目名称:Irony,代码行数:9,代码来源:IdentifierNode.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Parsing.LanguageData类代码示例发布时间:2022-05-26
下一篇:
C# Ast.AstContext类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap