public FunctionCallStatement(ScriptLoadingContext lcontext, FunctionCallExpression functionCallExpression)
			: base(lcontext)
		{
			m_FunctionCallExpression = functionCallExpression;
			lcontext.Source.Refs.Add(m_FunctionCallExpression.SourceRef);
		}
Пример #2
0
		/// <summary>
		/// Primaries the exp.
		/// </summary>
		/// <param name="lcontext">The lcontext.</param>
		/// <returns></returns>
		internal static Expression PrimaryExp(ScriptLoadingContext lcontext)
		{
			Expression e = PrefixExp(lcontext);

			while (true)
			{
				Token T = lcontext.Lexer.Current;
				Token thisCallName = null;

				switch (T.Type)
				{
					case TokenType.Dot:
						{
							lcontext.Lexer.Next();
							Token name = CheckTokenType(lcontext, TokenType.Name);
							e = new IndexExpression(e, name.Text, lcontext);
						}
						break;
					case TokenType.Brk_Open_Square:
						{
							Token openBrk = lcontext.Lexer.Current;
							lcontext.Lexer.Next(); // skip bracket
							Expression index = Expr(lcontext);

							// support moonsharp multiple indexers for userdata
							if (lcontext.Lexer.Current.Type == TokenType.Comma)
							{
								var explist = ExprListAfterFirstExpr(lcontext, index);
								index = new ExprListExpression(explist, lcontext);
							}

							CheckMatch(lcontext, openBrk, TokenType.Brk_Close_Square, "]");
							e = new IndexExpression(e, index, lcontext);
						}
						break;
					case TokenType.Colon:
						lcontext.Lexer.Next();
						thisCallName = CheckTokenType(lcontext, TokenType.Name);
						goto case TokenType.Brk_Open_Round;
					case TokenType.Brk_Open_Round:
					case TokenType.String:
					case TokenType.String_Long:
					case TokenType.Brk_Open_Curly:
						e = new FunctionCallExpression(lcontext, e, thisCallName);
						break;
					default:
						return e;
				}
			}
		}