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


C# Execution.ScriptLoadingContext类代码示例

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


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

示例1: CreateSubTree

        /// <summary>
        ///     Creates a sub tree of binary expressions
        /// </summary>
        private static Expression CreateSubTree(LinkedList list, ScriptLoadingContext lcontext)
        {
            var opfound = list.OperatorMask;

            var nodes = list.Nodes;

            if ((opfound & POWER) != 0)
                nodes = PrioritizeRightAssociative(nodes, lcontext, POWER);

            if ((opfound & MUL_DIV_MOD) != 0)
                nodes = PrioritizeLeftAssociative(nodes, lcontext, MUL_DIV_MOD);

            if ((opfound & ADD_SUB) != 0)
                nodes = PrioritizeLeftAssociative(nodes, lcontext, ADD_SUB);

            if ((opfound & STRCAT) != 0)
                nodes = PrioritizeRightAssociative(nodes, lcontext, STRCAT);

            if ((opfound & COMPARES) != 0)
                nodes = PrioritizeLeftAssociative(nodes, lcontext, COMPARES);

            if ((opfound & LOGIC_AND) != 0)
                nodes = PrioritizeLeftAssociative(nodes, lcontext, LOGIC_AND);

            if ((opfound & LOGIC_OR) != 0)
                nodes = PrioritizeLeftAssociative(nodes, lcontext, LOGIC_OR);


            if (nodes.Next != null || nodes.Prev != null)
                throw new InternalErrorException("Expression reduction didn't work! - 1");
            if (nodes.Expr == null)
                throw new InternalErrorException("Expression reduction didn't work! - 2");

            return nodes.Expr;
        }
开发者ID:eddy5641,项目名称:moonsharp,代码行数:38,代码来源:BinaryOperatorExpression.cs

示例2: LiteralExpression

        public LiteralExpression(ScriptLoadingContext lcontext, Token t)
            : base(lcontext)
        {
            switch (t.Type)
            {
                case TokenType.Number:
                case TokenType.Number_Hex:
                case TokenType.Number_HexFloat:
                    Value = DynValue.NewNumber(t.GetNumberValue()).AsReadOnly();
                    break;
                case TokenType.String:
                case TokenType.String_Long:
                    Value = DynValue.NewString(t.Text).AsReadOnly();
                    break;
                case TokenType.True:
                    Value = DynValue.True;
                    break;
                case TokenType.False:
                    Value = DynValue.False;
                    break;
                case TokenType.Nil:
                    Value = DynValue.Nil;
                    break;
                default:
                    throw new InternalErrorException("type mismatch");
            }

            if (Value == null)
                throw new SyntaxErrorException(t, "unknown literal format near '{0}'", t.Text);

            lcontext.Lexer.Next();
        }
开发者ID:eddy5641,项目名称:moonsharp,代码行数:32,代码来源:LiteralExpression.cs

示例3: ReturnStatement

		public ReturnStatement(ScriptLoadingContext lcontext, Expression e, SourceRef sref)
			: base(lcontext)
		{
			m_Expression = e;
			m_Ref = sref;
			lcontext.Source.Refs.Add(sref);
		}
开发者ID:eddy5641,项目名称:LuaSharp,代码行数:7,代码来源:ReturnStatement.cs

示例4: ForLoopStatement

		public ForLoopStatement(ScriptLoadingContext lcontext, Token nameToken, Token forToken)
			: base(lcontext)
		{
			//	for Name ‘=’ exp ‘,’ exp [‘,’ exp] do block end | 

			// lexer already at the '=' ! [due to dispatching vs for-each]
			CheckTokenType(lcontext, TokenType.Op_Assignment);

			m_Start = Expression.Expr(lcontext);
			CheckTokenType(lcontext, TokenType.Comma);
			m_End = Expression.Expr(lcontext);

			if (lcontext.Lexer.Current.Type == TokenType.Comma)
			{
				lcontext.Lexer.Next();
				m_Step = Expression.Expr(lcontext);
			}
			else
			{
				m_Step = new LiteralExpression(lcontext, DynValue.NewNumber(1));
			}

			lcontext.Scope.PushBlock();
			m_VarName = lcontext.Scope.DefineLocal(nameToken.Text);
			m_RefFor = forToken.GetSourceRef(CheckTokenType(lcontext, TokenType.Do));
			m_InnerBlock = new CompositeStatement(lcontext);
			m_RefEnd = CheckTokenType(lcontext, TokenType.End).GetSourceRef();
			m_StackFrame = lcontext.Scope.PopBlock();

			lcontext.Source.Refs.Add(m_RefFor);
			lcontext.Source.Refs.Add(m_RefEnd);
		}		
开发者ID:eddy5641,项目名称:LuaSharp,代码行数:32,代码来源:ForLoopStatement.cs

示例5: BinaryOperatorExpression

 private BinaryOperatorExpression(Expression exp1, Expression exp2, Operator op, ScriptLoadingContext lcontext)
     : base(lcontext)
 {
     m_Exp1 = exp1;
     m_Exp2 = exp2;
     m_Operator = op;
 }
开发者ID:eddy5641,项目名称:moonsharp,代码行数:7,代码来源:BinaryOperatorExpression.cs

示例6: CreateLambdaBody

		private Statement CreateLambdaBody(ScriptLoadingContext lcontext)
		{
			Token start = lcontext.Lexer.Current;
			Expression e = Expression.Expr(lcontext);
			Token end = lcontext.Lexer.Current;
			SourceRef sref = start.GetSourceRefUpTo(end);
			Statement s = new ReturnStatement(lcontext, e, sref);
			return s;
		}
开发者ID:eddy5641,项目名称:LuaSharp,代码行数:9,代码来源:FunctionDefinitionExpression.cs

示例7: CheckVar

		private IVariable CheckVar(ScriptLoadingContext lcontext, Expression firstExpression)
		{
			IVariable v = firstExpression as IVariable;

			if (v == null)
				throw new SyntaxErrorException(lcontext.Lexer.Current, "unexpected symbol near '{0}' - not a l-value", lcontext.Lexer.Current);

			return v;
		}
开发者ID:eddy5641,项目名称:LuaSharp,代码行数:9,代码来源:AssignmentStatement.cs

示例8: SymbolRefExpression

		public SymbolRefExpression(ScriptLoadingContext lcontext, SymbolRef refr)
			: base(lcontext)
		{
			m_Ref = refr;

			if (lcontext.IsDynamicExpression)
			{
				throw new DynamicExpressionException("Unsupported symbol reference expression detected.");
			}
		}
开发者ID:eddy5641,项目名称:LuaSharp,代码行数:10,代码来源:SymbolRefExpression.cs

示例9: CheckTokenType

        protected static Token CheckTokenType(ScriptLoadingContext lcontext, TokenType tokenType1, TokenType tokenType2)
        {
            var t = lcontext.Lexer.Current;
            if (t.Type != tokenType1 && t.Type != tokenType2)
                return UnexpectedTokenType(t);

            lcontext.Lexer.Next();

            return t;
        }
开发者ID:eddy5641,项目名称:moonsharp,代码行数:10,代码来源:NodeBase.cs

示例10: StructField

        private void StructField(ScriptLoadingContext lcontext)
        {
            Expression key = new LiteralExpression(lcontext, DynValue.NewString(lcontext.Lexer.Current.Text));
            lcontext.Lexer.Next();

            CheckTokenType(lcontext, TokenType.Op_Assignment);

            var value = Expr(lcontext);

            m_CtorArgs.Add(new KeyValuePair<Expression, Expression>(key, value));
        }
开发者ID:eddy5641,项目名称:moonsharp,代码行数:11,代码来源:TableConstructor.cs

示例11: LabelStatement

		public LabelStatement(ScriptLoadingContext lcontext)
			: base(lcontext)
		{
			CheckTokenType(lcontext, TokenType.DoubleColon);
			NameToken = CheckTokenType(lcontext, TokenType.Name);
			CheckTokenType(lcontext, TokenType.DoubleColon);

			SourceRef = NameToken.GetSourceRef();
			Label = NameToken.Text;

			lcontext.Scope.DefineLabel(this);
		}
开发者ID:eddy5641,项目名称:LuaSharp,代码行数:12,代码来源:LabelStatement.cs

示例12: GotoStatement

        public GotoStatement(ScriptLoadingContext lcontext)
            : base(lcontext)
        {
            GotoToken = CheckTokenType(lcontext, TokenType.Goto);
            var name = CheckTokenType(lcontext, TokenType.Name);

            SourceRef = GotoToken.GetSourceRef(name);

            Label = name.Text;

            lcontext.Scope.RegisterGoto(this);
        }
开发者ID:eddy5641,项目名称:moonsharp,代码行数:12,代码来源:GotoStatement.cs

示例13: CreateStatement

		protected static Statement CreateStatement(ScriptLoadingContext lcontext, out bool forceLast)
		{
			Token tkn = lcontext.Lexer.Current;

			forceLast = false;

			switch (tkn.Type)
			{
				case TokenType.DoubleColon:
					return new LabelStatement(lcontext);
				case TokenType.Goto:
					return new GotoStatement(lcontext);
				case TokenType.SemiColon:
					lcontext.Lexer.Next();
					return new EmptyStatement(lcontext);
				case TokenType.If:
					return new IfStatement(lcontext);
				case TokenType.While:
					return new WhileStatement(lcontext);
				case TokenType.Do:
					return new ScopeBlockStatement(lcontext);
				case TokenType.For:
					return DispatchForLoopStatement(lcontext);
				case TokenType.Repeat:
					return new RepeatStatement(lcontext);
				case TokenType.Function:
					return new FunctionDefinitionStatement(lcontext, false, null);
				case TokenType.Local:
					Token localToken = lcontext.Lexer.Current;
					lcontext.Lexer.Next();
					if (lcontext.Lexer.Current.Type == TokenType.Function)
						return new FunctionDefinitionStatement(lcontext, true, localToken);
					else
						return new AssignmentStatement(lcontext, localToken);
				case TokenType.Return:
					forceLast = true;
					return new ReturnStatement(lcontext);
				case TokenType.Break:
					return new BreakStatement(lcontext);
				default:
					{
						Token l = lcontext.Lexer.Current;
						Expression exp = Expression.PrimaryExp(lcontext);
						FunctionCallExpression fnexp = exp as FunctionCallExpression;

						if (fnexp != null)
							return new FunctionCallStatement(lcontext, fnexp);
						else
							return new AssignmentStatement(lcontext, exp, l);
					}
			}
		}
开发者ID:eddy5641,项目名称:LuaSharp,代码行数:52,代码来源:Statement.cs

示例14: CreateElseBlock

		IfBlock CreateElseBlock(ScriptLoadingContext lcontext)
		{
			Token type = CheckTokenType(lcontext, TokenType.Else);

			lcontext.Scope.PushBlock();

			var ifblock = new IfBlock();
			ifblock.Block = new CompositeStatement(lcontext);
			ifblock.StackFrame = lcontext.Scope.PopBlock();
			ifblock.Source = type.GetSourceRef();
			lcontext.Source.Refs.Add(ifblock.Source);
			return ifblock;
		}
开发者ID:cyecp,项目名称:moonsharp,代码行数:13,代码来源:IfStatement.cs

示例15: FunctionCallExpression

		public FunctionCallExpression(ScriptLoadingContext lcontext, Expression function, Token thisCallName)
			: base(lcontext)
		{
			Token callToken = thisCallName ?? lcontext.Lexer.Current;

			m_Name = thisCallName != null ? thisCallName.Text : null;
			m_DebugErr = function.GetFriendlyDebugName();
			m_Function = function;

			switch (lcontext.Lexer.Current.Type)
			{
				case TokenType.Brk_Open_Round:
					Token openBrk = lcontext.Lexer.Current;
					lcontext.Lexer.Next();
					Token t = lcontext.Lexer.Current;
					if (t.Type == TokenType.Brk_Close_Round)
					{
						m_Arguments = new List<Expression>();
						SourceRef = callToken.GetSourceRef(t);
						lcontext.Lexer.Next();
					}
					else
					{
						m_Arguments = ExprList(lcontext);
						SourceRef = callToken.GetSourceRef(CheckMatch(lcontext, openBrk, TokenType.Brk_Close_Round, ")"));
					}
					break;
				case TokenType.String:
				case TokenType.String_Long:
					{
						m_Arguments = new List<Expression>();
						Expression le = new LiteralExpression(lcontext, lcontext.Lexer.Current);
						m_Arguments.Add(le);
						SourceRef = callToken.GetSourceRef(lcontext.Lexer.Current);
					}
					break;
				case TokenType.Brk_Open_Curly:
				case TokenType.Brk_Open_Curly_Shared:
					{
						m_Arguments = new List<Expression>();
						m_Arguments.Add(new TableConstructor(lcontext, lcontext.Lexer.Current.Type == TokenType.Brk_Open_Curly_Shared));
						SourceRef = callToken.GetSourceRefUpTo(lcontext.Lexer.Current);
					}
					break;
				default:
					throw new SyntaxErrorException(lcontext.Lexer.Current, "function arguments expected")
					{
						IsPrematureStreamTermination = (lcontext.Lexer.Current.Type == TokenType.Eof)
					};
			}
		}
开发者ID:eddy5641,项目名称:LuaSharp,代码行数:51,代码来源:FunctionCallExpression.cs


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