예제 #1
0
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="context" /> or <paramref name="code" /> or
        ///     <paramref name="conditionExpression" /> is <c>null</c>.
        /// </exception>
        internal LSLIfStatementNode(LSLParser.ControlStructureContext context, LSLCodeScopeNode code,
                                    ILSLExprNode conditionExpression)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (code == null)
            {
                throw new ArgumentNullException("code");
            }

            if (conditionExpression == null)
            {
                throw new ArgumentNullException("conditionExpression");
            }

            Code               = code;
            Code.Parent        = this;
            Code.CodeScopeType = LSLCodeScopeType.If;

            ConditionExpression        = conditionExpression;
            ConditionExpression.Parent = this;

            SourceRangeIfKeyword    = new LSLSourceCodeRange(context.if_keyword);
            SourceRangeOpenParenth  = new LSLSourceCodeRange(context.open_parenth);
            SourceRangeCloseParenth = new LSLSourceCodeRange(context.close_parenth);

            SourceRange = new LSLSourceCodeRange(SourceRangeIfKeyword, code.SourceRange);

            SourceRangesAvailable = true;
        }
예제 #2
0
        /// <summary>
        ///     Construct an <see cref="LSLForLoopNode" /> with all possible children.
        /// </summary>
        /// <param name="initExpressions">The init expression list.</param>
        /// <param name="condition">The for loop condition expression, may be <c>null</c>.</param>
        /// <param name="afterthoughtExpressions">The afterthought expression list.</param>
        /// <param name="code">The code body of the for loop.</param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="initExpressions" /> or
        ///     <paramref name="afterthoughtExpressions" /> or <paramref name="code" /> is <c>null</c>.
        /// </exception>
        public LSLForLoopNode(LSLExpressionListNode initExpressions, ILSLExprNode condition,
                              LSLExpressionListNode afterthoughtExpressions, LSLCodeScopeNode code)
        {
            if (initExpressions == null)
            {
                throw new ArgumentNullException("initExpressions");
            }
            if (afterthoughtExpressions == null)
            {
                throw new ArgumentNullException("afterthoughtExpressions");
            }
            if (code == null)
            {
                throw new ArgumentNullException("code");
            }

            InitExpressionList        = initExpressions;
            InitExpressionList.Parent = this;

            ConditionExpression = condition;

            if (ConditionExpression != null)
            {
                ConditionExpression.Parent = this;
            }

            AfterthoughtExpressionList        = afterthoughtExpressions;
            AfterthoughtExpressionList.Parent = this;

            Code               = code;
            Code.Parent        = this;
            Code.CodeScopeType = LSLCodeScopeType.ForLoop;
        }
예제 #3
0
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="code" /> or <paramref name="conditionExpression" /> is
        ///     <c>null</c>.
        /// </exception>
        internal LSLDoLoopNode(LSLParser.DoLoopContext context, LSLCodeScopeNode code, ILSLExprNode conditionExpression)
        {
            if (code == null)
            {
                throw new ArgumentNullException("code");
            }

            if (conditionExpression == null)
            {
                throw new ArgumentNullException("conditionExpression");
            }


            Code               = code;
            Code.Parent        = this;
            Code.CodeScopeType = LSLCodeScopeType.DoLoop;

            ConditionExpression        = conditionExpression;
            ConditionExpression.Parent = this;

            SourceRange             = new LSLSourceCodeRange(context);
            SourceRangeDoKeyword    = new LSLSourceCodeRange(context.loop_keyword);
            SourceRangeWhileKeyword = new LSLSourceCodeRange(context.while_keyword);
            SourceRangeOpenParenth  = new LSLSourceCodeRange(context.open_parenth);
            SourceRangeCloseParenth = new LSLSourceCodeRange(context.close_parenth);
            SourceRangeSemicolon    = new LSLSourceCodeRange(context.semi_colon);

            SourceRangesAvailable = true;
        }
예제 #4
0
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="context" /> or <paramref name="castedExpression" /> is
        ///     <c>null</c>.
        /// </exception>
        internal LSLTypecastExprNode(LSLParser.Expr_TypeCastContext context, LSLType result,
                                     ILSLExprNode castedExpression)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (castedExpression == null)
            {
                throw new ArgumentNullException("castedExpression");
            }

            CastToTypeName = context.cast_type.Text;
            CastToType     = LSLTypeTools.FromLSLTypeName(CastToTypeName);

            CastedExpression        = castedExpression;
            CastedExpression.Parent = this;

            Type = result;

            SourceRange             = new LSLSourceCodeRange(context);
            SourceRangeCloseParenth = new LSLSourceCodeRange(context.close_parenth);
            SourceRangeOpenParenth  = new LSLSourceCodeRange(context.open_parenth);
            SourceRangeCastToType   = new LSLSourceCodeRange(context.cast_type);

            SourceRangesAvailable = true;
        }
        /// <summary>
        ///     Create a <see cref="LSLBinaryExpressionNode" /> from two <see cref="ILSLExprNode" />'s and an operator description.
        /// </summary>
        /// <param name="resultType">
        ///     The resulting type of the binary operation between <paramref name="leftExpression" /> and
        ///     <paramref name="rightExpression" />.
        /// </param>
        /// <param name="leftExpression">The left expression.</param>
        /// <param name="operation">The operator.</param>
        /// <param name="rightExpression">The right expression.</param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="leftExpression" /> or <paramref name="rightExpression" /> is
        ///     <c>null</c>.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     Thrown if <paramref name="resultType" /> is equal to <see cref="LSLType.Void" /> or
        ///     <paramref name="operation" /> is equal to <see cref="LSLBinaryOperationType.Error" />
        /// </exception>
        public LSLBinaryExpressionNode(LSLType resultType, ILSLExprNode leftExpression, LSLBinaryOperationType operation,
                                       ILSLExprNode rightExpression)
        {
            if (leftExpression == null)
            {
                throw new ArgumentNullException("leftExpression");
            }
            if (rightExpression == null)
            {
                throw new ArgumentNullException("rightExpression");
            }
            if (resultType == LSLType.Void)
            {
                throw new ArgumentException("Binary operation resultType cannot be LSLType.Void.", "resultType");
            }


            Type = resultType;

            LeftExpression        = leftExpression;
            LeftExpression.Parent = this;

            Operation       = operation;
            OperationString = operation.ToOperatorString();

            RightExpression        = rightExpression;
            RightExpression.Parent = this;
        }
예제 #6
0
        /// <summary>
        ///     Creates a global variable declaration node with the given <see cref="LSLType" />, name, and declaration expression.
        /// </summary>
        /// <param name="type">The type of the global variable.</param>
        /// <param name="variableName">The name of the global variable.</param>
        /// <param name="declarationExpression">The declaration expression used in the global variables definition.</param>
        /// <returns>The created variable declaration node.</returns>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="variableName" /> or <paramref name="declarationExpression" />
        ///     is <c>null</c>.
        /// </exception>
        /// <exception cref="LSLInvalidSymbolNameException">
        ///     <paramref name="variableName" /> contained characters not allowed in an LSL ID token.
        /// </exception>
        public static LSLVariableDeclarationNode CreateGlobalVar(LSLType type, string variableName,
                                                                 ILSLExprNode declarationExpression)
        {
            if (variableName == null)
            {
                throw new ArgumentNullException("variableName");
            }
            if (declarationExpression == null)
            {
                throw new ArgumentNullException("declarationExpression");
            }

            if (!LSLTokenTools.IDRegexAnchored.IsMatch(variableName))
            {
                throw new LSLInvalidSymbolNameException(
                          "variableName provided contained characters not allowed in an LSL ID token.");
            }

            var n = new LSLVariableDeclarationNode();

            n.VariableNode        = LSLVariableNode.CreateGlobalVarReference(type, variableName, n);
            n.VariableNode.Parent = n;

            n.DeclarationExpression = declarationExpression;

            return(n);
        }
예제 #7
0
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="context" /> or <paramref name="declarationExpression" /> is
        ///     <c>null</c>.
        /// </exception>
        internal static LSLVariableDeclarationNode CreateVar(LSLParser.LocalVariableDeclarationContext context,
                                                             ILSLExprNode declarationExpression)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (declarationExpression == null)
            {
                throw new ArgumentNullException("declarationExpression");
            }


            var n = new LSLVariableDeclarationNode();

            n.VariableNode          = LSLVariableNode.CreateVarReference(context, n);
            n.SourceRange           = new LSLSourceCodeRange(context);
            n.VariableNode.Parent   = n;
            n.DeclarationExpression = declarationExpression;

            n.SourceRangeType = new LSLSourceCodeRange(context.variable_type);
            n.SourceRangeName = new LSLSourceCodeRange(context.variable_name);

            n.SourceRangesAvailable = true;

            declarationExpression.Parent = n;

            if (context.operation != null)
            {
                n.SourceRangeOperator = new LSLSourceCodeRange(context.operation);
            }

            return(n);
        }
        /// <exception cref="ArgumentException">
        ///     <para>
        ///         If <paramref name="accessedExpression" />.Type is not <see cref="LSLType.Vector" /> or
        ///         <see cref="LSLType.Rotation" />.
        ///     </para>
        ///     <para>
        ///         Or <paramref name="context" />.member.Text is not one of: "x", "y", "z" or "s".
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="context" /> or <paramref name="accessedExpression" /> is
        ///     <c>null</c>.
        /// </exception>
        internal LSLTupleAccessorNode(LSLParser.DotAccessorExprContext context, ILSLExprNode accessedExpression)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (accessedExpression == null)
            {
                throw new ArgumentNullException("context");
            }

            if (accessedExpression.Type != LSLType.Vector && accessedExpression.Type != LSLType.Rotation)
            {
                throw new ArgumentException("accessedExpression.Type can only be LSLType.Vector or LSLType.Rotation");
            }

            if (!Utility.EqualsOneOf(context.member.Text, "x", "y", "z", "s"))
            {
                throw new ArgumentException("context.member.Text is not x, y, z or s.", "context");
            }

            AccessedComponent = context.member.Text;

            SourceRangeAccessedComponent = new LSLSourceCodeRange(context.member);

            AccessedExpression        = accessedExpression;
            AccessedExpression.Parent = this;

            SourceRange = new LSLSourceCodeRange(context);

            SourceRangesAvailable = true;
        }
예제 #9
0
        /// <summary>
        ///     Construct an <see cref="LSLVectorLiteralNode" /> with the given component expressions.
        /// </summary>
        /// <param name="x">The 'x' vector component expression.</param>
        /// <param name="y">The 'y' vector component expression.</param>
        /// <param name="z">The 'z' vector component expression.</param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="x" /> or
        ///     <paramref name="y" /> or
        ///     <paramref name="z" /> is <c>null</c>.
        /// </exception>
        public LSLVectorLiteralNode(ILSLExprNode x, ILSLExprNode y,
                                    ILSLExprNode z)
        {
            if (x == null)
            {
                throw new ArgumentNullException("x");
            }

            if (y == null)
            {
                throw new ArgumentNullException("y");
            }

            if (z == null)
            {
                throw new ArgumentNullException("z");
            }

            XExpression = x;
            YExpression = y;
            ZExpression = z;

            XExpression.Parent = this;
            YExpression.Parent = this;
            ZExpression.Parent = this;
        }
예제 #10
0
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="context" /> or <paramref name="leftExpression" /> is
        ///     <c>null</c>.
        /// </exception>
        internal LSLPostfixOperationNode(LSLParser.Expr_PostfixOperationContext context, LSLType resultType,
                                         ILSLExprNode leftExpression)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (leftExpression == null)
            {
                throw new ArgumentNullException("leftExpression");
            }

            Type                  = resultType;
            LeftExpression        = leftExpression;
            LeftExpression.Parent = this;

            ParseAndSetOperation(context.operation.Text);

            SourceRange = new LSLSourceCodeRange(context);

            SourceRangeOperation = new LSLSourceCodeRange(context.operation);

            SourceRangesAvailable = true;
        }
예제 #11
0
        /// <summary>
        ///     Construct an <see cref="LSLTupleAccessorNode" /> from the accessed expression and component accessed.
        /// </summary>
        /// <param name="accessedExpression">The expression the '.' tuple access operator was used on.</param>
        /// <param name="accessedComponent">The tuple component accessed: "x", "y", "z" or "s".</param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="accessedExpression" /> or <paramref name="accessedComponent" />
        ///     is <c>null</c>.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     <para>
        ///         <paramref name="accessedExpression" />.Type is not <see cref="LSLType.Vector" /> or
        ///         <see cref="LSLType.Rotation" />.
        ///     </para>
        ///     <para>
        ///         Or <paramref name="accessedComponent" /> is not one of: "x", "y", "z" or "s".
        ///     </para>
        /// </exception>
        public LSLTupleAccessorNode(ILSLExprNode accessedExpression, string accessedComponent)
        {
            if (accessedExpression == null)
            {
                throw new ArgumentNullException("accessedExpression");
            }

            if (accessedComponent == null)
            {
                throw new ArgumentNullException("accessedComponent");
            }


            if (accessedExpression.Type != LSLType.Vector && accessedExpression.Type != LSLType.Rotation)
            {
                throw new ArgumentException("accessedExpression.Type can only be LSLType.Vector or LSLType.Rotation");
            }


            if (!Utility.EqualsOneOf(accessedComponent, "x", "y", "z", "s"))
            {
                throw new ArgumentException("accessedComponent is not x, y, z or s.", "accessedComponent");
            }

            AccessedComponent  = accessedComponent;
            AccessedExpression = accessedExpression;

            AccessedExpression.Parent = this;
        }
예제 #12
0
        /// <summary>
        ///     Construct an <see cref="LSLRotationLiteralNode" /> with the given component expressions.
        /// </summary>
        /// <param name="x">The 'x' rotation component expression.</param>
        /// <param name="y">The 'y' rotation component expression.</param>
        /// <param name="z">The 'z' rotation component expression.</param>
        /// <param name="s">The 's' rotation component expression.</param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="x" /> or
        ///     <paramref name="y" /> or
        ///     <paramref name="z" /> or
        ///     <paramref name="s" /> is <c>null</c>.
        /// </exception>
        public LSLRotationLiteralNode(ILSLExprNode x, ILSLExprNode y,
                                      ILSLExprNode z, ILSLExprNode s)
        {
            if (x == null)
            {
                throw new ArgumentNullException("x");
            }
            if (y == null)
            {
                throw new ArgumentNullException("y");
            }

            if (z == null)
            {
                throw new ArgumentNullException("z");
            }
            if (s == null)
            {
                throw new ArgumentNullException("z");
            }

            XExpression = x;
            YExpression = y;
            ZExpression = z;
            SExpression = s;

            XExpression.Parent = this;
            YExpression.Parent = this;
            ZExpression.Parent = this;
            SExpression.Parent = this;
        }
 public AssignmentExpressionContext(ILSLExprNode exprLvalue, IToken operationToken,
                                    LSLParser.ExpressionContext exprRvalue, LSLParser.ExpressionContext originalContext)
 {
     LeftExpr        = exprLvalue;
     OperationToken  = operationToken;
     RightContext    = exprRvalue;
     OriginalContext = originalContext;
 }
        /// <summary>
        ///     Create a <see cref="LSLParenthesizedExpressionNode" /> around a given <see cref="ILSLExprNode" />.
        /// </summary>
        /// <param name="innerExpression"></param>
        /// <exception cref="ArgumentNullException"><paramref name="innerExpression" /> is <c>null</c>.</exception>
        public LSLParenthesizedExpressionNode(ILSLExprNode innerExpression)
        {
            if (innerExpression == null)
            {
                throw new ArgumentNullException("innerExpression");
            }

            InnerExpression        = innerExpression;
            InnerExpression.Parent = this;
        }
        /// <summary>
        ///     Construct an <see cref="LSLExpressionStatementNode" /> with the given expression and a <see cref="ParentScopeId" /> of
        ///     zero.
        /// </summary>
        /// <param name="expression">The expression to appear as a statement.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expression" /> is <c>null</c>.</exception>
        public LSLExpressionStatementNode(ILSLExprNode expression)
        {
            if (expression == null)
            {
                throw new ArgumentNullException("expression");
            }

            Expression        = expression;
            Expression.Parent = this;
        }
        /// <summary>
        ///     Construct an <see cref="LSLReturnStatementNode" /> with a given return expression and <see cref="ParentScopeId" /> of
        ///     zero.
        /// </summary>
        /// <param name="returnExpression">The <see cref="ReturnExpression" />.</param>
        /// <exception cref="ArgumentNullException"><paramref name="returnExpression" /> is <c>null</c>.</exception>
        public LSLReturnStatementNode(ILSLExprNode returnExpression)
        {
            if (returnExpression == null)
            {
                throw new ArgumentNullException("returnExpression");
            }

            ReturnExpression        = returnExpression;
            ReturnExpression.Parent = this;
        }
예제 #17
0
        /// <summary>
        ///     Adds a new expression to the expression list node.
        /// </summary>
        /// <param name="node">The expression node to add to the expression list.</param>
        /// <exception cref="ArgumentNullException">Thrown if the 'node' parameter is <c>null</c>.</exception>
        public void Add(ILSLExprNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            node.Parent = this;

            _expressions.Add(node);
        }
예제 #18
0
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="context" /> or
        ///     <paramref name="x" /> or
        ///     <paramref name="y" /> or
        ///     <paramref name="z" /> is <c>null</c>.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     <paramref name="x" /> or
        ///     <paramref name="y" /> or
        ///     <paramref name="z" /> already has a Parent node.
        /// </exception>
        internal LSLVectorLiteralNode(LSLParser.VectorLiteralContext context, ILSLExprNode x, ILSLExprNode y,
                                      ILSLExprNode z) : this(x, y, z)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            SourceRange = new LSLSourceCodeRange(context);

            SourceRangeOpenBracket  = new LSLSourceCodeRange(context.open_bracket);
            SourceRangeCommaOne     = new LSLSourceCodeRange(context.comma_one);
            SourceRangeCommaTwo     = new LSLSourceCodeRange(context.comma_two);
            SourceRangeCloseBracket = new LSLSourceCodeRange(context.close_bracket);

            SourceRangesAvailable = true;
        }
예제 #19
0
        /// <summary>
        ///     Construct an <see cref="LSLIfStatementNode" /> with the given condition expression and code.
        /// </summary>
        /// <param name="condition">The branch condition.</param>
        /// <param name="code">The code.</param>
        /// <exception cref="ArgumentNullException"><paramref name="condition" /> or <paramref name="code" /> is <c>null</c>.</exception>
        public LSLIfStatementNode(ILSLExprNode condition, LSLCodeScopeNode code)
        {
            if (condition == null)
            {
                throw new ArgumentNullException("condition");
            }
            if (code == null)
            {
                throw new ArgumentNullException("code");
            }

            ConditionExpression        = condition;
            ConditionExpression.Parent = this;

            Code               = code;
            Code.Parent        = this;
            Code.CodeScopeType = LSLCodeScopeType.If;
        }
예제 #20
0
        /// <summary>
        ///     Construct an <see cref="LSLDoLoopNode" /> with a <see cref="ParentScopeId" /> of zero, condition and code body.
        /// </summary>
        /// <param name="condition">The <see cref="ConditionExpression" />.</param>
        /// <param name="code">The <see cref="Code" />.</param>
        /// <exception cref="ArgumentNullException"><paramref name="code" /> or <paramref name="condition" /> is <c>null</c>.</exception>
        public LSLDoLoopNode(LSLCodeScopeNode code, ILSLExprNode condition)
        {
            if (condition == null)
            {
                throw new ArgumentNullException("condition");
            }
            if (code == null)
            {
                throw new ArgumentNullException("code");
            }


            ConditionExpression        = condition;
            ConditionExpression.Parent = this;

            Code               = code;
            Code.Parent        = this;
            Code.CodeScopeType = LSLCodeScopeType.DoLoop;
        }
예제 #21
0
        /// <summary>
        ///     Construct an <see cref="LSLTypecastExprNode" /> with the given 'cast-to' type and casted expression node.
        /// </summary>
        /// <param name="castToType">The <see cref="LSLType" /> to cast to.</param>
        /// <param name="castedExpression">The expression the cast operator acts on.</param>
        /// <exception cref="ArgumentNullException"><paramref name="castedExpression" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException"><paramref name="castToType" /> is <see cref="LSLType.Void" />.</exception>
        public LSLTypecastExprNode(LSLType castToType, ILSLExprNode castedExpression)
        {
            if (castedExpression == null)
            {
                throw new ArgumentNullException("castedExpression");
            }

            if (castToType == LSLType.Void)
            {
                throw new ArgumentException("castToType cannot be LSLType.Void.");
            }

            CastToTypeName = castToType.ToLSLTypeName();
            CastToType     = castToType;

            CastedExpression        = castedExpression;
            CastedExpression.Parent = this;

            Type = castToType;
        }
예제 #22
0
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="context" /> or <paramref name="initExpression" /> or
        ///     <paramref name="afterthoughtExpressionsList" /> or <paramref name="code" /> is <c>null</c>.
        /// </exception>
        internal LSLForLoopNode(LSLParser.ForLoopContext context, LSLExpressionListNode initExpression,
                                ILSLExprNode conditionExpression,
                                LSLExpressionListNode afterthoughtExpressionsList, LSLCodeScopeNode code)
            : this(initExpression, conditionExpression, afterthoughtExpressionsList, code)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            SourceRange = new LSLSourceCodeRange(context);
            SourceRangeFirstSemicolon  = new LSLSourceCodeRange(context.first_semi_colon);
            SourceRangeSecondSemicolon = new LSLSourceCodeRange(context.second_semi_colon);
            SourceRangeOpenParenth     = new LSLSourceCodeRange(context.open_parenth);
            SourceRangeCloseParenth    = new LSLSourceCodeRange(context.close_parenth);
            SourceRangeForKeyword      = new LSLSourceCodeRange(context.loop_keyword);


            SourceRangesAvailable = true;
        }
예제 #23
0
        /// <summary>
        ///     Construct an <see cref="LSLPostfixOperationNode" /> from a given <see cref="ILSLExprNode" /> and
        ///     <see cref="LSLPostfixOperationType" />.
        /// </summary>
        /// <param name="resultType">The return type of the postfix operation on the given expression.</param>
        /// <param name="leftExpression">The expression the postfix operation occurs on.</param>
        /// <param name="operationType">The postfix operation type.</param>
        /// <exception cref="ArgumentNullException"><paramref name="leftExpression" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException"><paramref name="operationType" /> is <see cref="LSLPostfixOperationType.Error" />.</exception>
        public LSLPostfixOperationNode(LSLType resultType, ILSLExprNode leftExpression,
                                       LSLPostfixOperationType operationType)
        {
            if (leftExpression == null)
            {
                throw new ArgumentNullException("leftExpression");
            }

            if (operationType == LSLPostfixOperationType.Error)
            {
                throw new ArgumentException("operationType cannot be LSLPostfixOperationType.Error.");
            }

            Type                  = resultType;
            LeftExpression        = leftExpression;
            LeftExpression.Parent = this;

            Operation       = operationType;
            OperationString = Operation.ToOperatorString();
        }
예제 #24
0
        /// <summary>
        ///     Construct an <see cref="LSLPostfixOperationNode" /> from a given <see cref="ILSLExprNode" /> and
        ///     <see cref="LSLPostfixOperationType" />.
        /// </summary>
        /// <param name="resultType">The return type of the postfix operation on the given expression.</param>
        /// <param name="rightExpression">The expression the postfix operation occurs on.</param>
        /// <param name="operationType">The postfix operation type.</param>
        /// <exception cref="ArgumentNullException"><paramref name="rightExpression" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException"><paramref name="operationType" /> is <see cref="LSLPrefixOperationType.Error" />.</exception>
        public LSLPrefixOperationNode(LSLType resultType, LSLPrefixOperationType operationType,
                                      ILSLExprNode rightExpression)
        {
            if (rightExpression == null)
            {
                throw new ArgumentNullException("rightExpression");
            }

            if (operationType == LSLPrefixOperationType.Error)
            {
                throw new ArgumentException("operationType cannot be LSLPrefixOperationType.Error.");
            }

            Type                   = resultType;
            RightExpression        = rightExpression;
            RightExpression.Parent = this;

            Operation       = operationType;
            OperationString = Operation.ToOperatorString();
        }
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="context" /> or <paramref name="innerExpression" /> is
        ///     <c>null</c>.
        /// </exception>
        internal LSLParenthesizedExpressionNode(LSLParser.ParenthesizedExpressionContext context,
                                                ILSLExprNode innerExpression)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (innerExpression == null)
            {
                throw new ArgumentNullException("innerExpression");
            }

            InnerExpression         = innerExpression;
            InnerExpression.Parent  = this;
            SourceRange             = new LSLSourceCodeRange(context);
            SourceRangeOpenParenth  = new LSLSourceCodeRange(context.open_parenth);
            SourceRangeCloseParenth = new LSLSourceCodeRange(context.close_parenth);

            SourceRangesAvailable = true;
        }
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="context" /> or <paramref name="returnExpression" /> is
        ///     <c>null</c>.
        /// </exception>
        internal LSLReturnStatementNode(LSLParser.ReturnStatementContext context, ILSLExprNode returnExpression)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (returnExpression == null)
            {
                throw new ArgumentNullException("returnExpression");
            }

            ReturnExpression        = returnExpression;
            ReturnExpression.Parent = this;

            SourceRange = new LSLSourceCodeRange(context);
            SourceRangeReturnKeyword = new LSLSourceCodeRange(context.return_keyword);
            SourceRangeSemicolon     = new LSLSourceCodeRange(context.semi_colon);

            SourceRangesAvailable = true;
        }
        /// <exception cref="ArgumentNullException"><paramref name="context" /> or <paramref name="expression" /> is <c>null</c>.</exception>
        internal LSLExpressionStatementNode(LSLParser.ExpressionStatementContext context, ILSLExprNode expression)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (expression == null)
            {
                throw new ArgumentNullException("expression");
            }

            Expression = expression;

            Expression.Parent = this;

            SourceRange = new LSLSourceCodeRange(context);

            SourceRangeSemicolon = new LSLSourceCodeRange(context.semi_colon);

            SourceRangesAvailable = true;
        }
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="context" /> or
        ///     <paramref name="leftExpression" /> or
        ///     <paramref name="rightExpression" /> is <c>null</c>.
        /// </exception>
        internal LSLBinaryExpressionNode(
            LSLParser.ExpressionContext context,
            IToken operationToken,
            ILSLExprNode leftExpression,
            ILSLExprNode rightExpression,
            LSLType returns,
            string operationString)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (leftExpression == null)
            {
                throw new ArgumentNullException("leftExpression");
            }

            if (rightExpression == null)
            {
                throw new ArgumentNullException("rightExpression");
            }


            Type            = returns;
            LeftExpression  = leftExpression;
            RightExpression = rightExpression;

            leftExpression.Parent  = this;
            rightExpression.Parent = this;

            ParseAndSetOperation(operationString);

            SourceRange = new LSLSourceCodeRange(context);

            SourceRangeOperation = new LSLSourceCodeRange(operationToken);

            SourceRangesAvailable = true;
        }
예제 #29
0
 /// <summary>
 ///     Construct an <see cref="LSLForLoopNode" /> without init expressions.
 /// </summary>
 /// <param name="condition">The for loop condition expression, may be <c>null</c>.</param>
 /// <param name="afterthoughtExpressions">The afterthought expression list.</param>
 /// <param name="code">The code body of the for loop.</param>
 /// <exception cref="ArgumentNullException"><paramref name="afterthoughtExpressions" /> is <c>null</c>.</exception>
 public LSLForLoopNode(ILSLExprNode condition,
                       LSLExpressionListNode afterthoughtExpressions, LSLCodeScopeNode code)
     : this(new LSLExpressionListNode(), condition, afterthoughtExpressions, code)
 {
 }
예제 #30
0
 /// <summary>
 ///     Construct an <see cref="LSLForLoopNode" /> without init expressions or afterthought expressions.
 /// </summary>
 /// <param name="condition">The for loop condition expression, may be <c>null</c>.</param>
 /// <param name="code">The code body of the for loop.</param>
 public LSLForLoopNode(ILSLExprNode condition, LSLCodeScopeNode code)
     : this(new LSLExpressionListNode(), condition, new LSLExpressionListNode(), code)
 {
 }