Example #1
0
        /// <summary>
        ///     Create an <see cref="LSLExpressionListNode" /> by cloning from another.
        /// </summary>
        /// <param name="other">The other node to clone from.</param>
        /// <exception cref="ArgumentNullException"><paramref name="other" /> is <c>null</c>.</exception>
        private LSLExpressionListNode(LSLExpressionListNode other)
        {
            if (other == null)
            {
                throw new ArgumentNullException("other");
            }

            ListType = other.ListType;


            foreach (var expr in other._expressions)
            {
                Add(expr.Clone());
            }

            SourceRangesAvailable = other.SourceRangesAvailable;

            if (SourceRangesAvailable)
            {
                SourceRange = other.SourceRange;

                foreach (var commaRange in other.SourceRangeCommaList)
                {
                    _sourceRangeCommaList.Add(commaRange);
                }
            }

            HasErrors = other.HasErrors;
        }
Example #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;
        }
        /// <summary>
        ///     Create a <see cref="LSLListLiteralNode" /> with the given <see cref="LSLExpressionListNode" /> as content.
        /// </summary>
        /// <param name="expressionListNode">The expression list node.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expressionListNode" /> is <c>null</c>.</exception>
        public LSLListLiteralNode(LSLExpressionListNode expressionListNode)
        {
            if (expressionListNode == null)
            {
                throw new ArgumentNullException("expressionListNode");
            }

            ExpressionListNode        = expressionListNode;
            ExpressionListNode.Parent = this;

            SourceRangesAvailable = true;
        }
Example #4
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;
        }
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="context" /> or <paramref name="expressionListNode" /> is
        ///     <c>null</c>.
        /// </exception>
        internal LSLListLiteralNode(LSLParser.ListLiteralContext context, LSLExpressionListNode expressionListNode)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

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

            ExpressionListNode        = expressionListNode;
            ExpressionListNode.Parent = this;

            SourceRange             = new LSLSourceCodeRange(context);
            SourceRangeOpenBracket  = new LSLSourceCodeRange(context.open_bracket);
            SourceRangeCloseBracket = new LSLSourceCodeRange(context.close_bracket);

            SourceRangesAvailable = true;
        }
Example #6
0
        /// <summary>
        ///     Construct an <see cref="LSLFunctionCallNode" /> with an arguments list.
        ///     This represents a call to a library function, since it has no definition node.
        /// </summary>
        /// <param name="functionSignature">The signature of the library function.</param>
        /// <param name="argumentList">The argument list node.</param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="functionSignature" /> or <paramref name="argumentList" /> is
        ///     <c>null</c>.
        /// </exception>
        public LSLFunctionCallNode(ILSLFunctionSignature functionSignature, LSLExpressionListNode argumentList)
        {
            if (functionSignature == null)
            {
                throw new ArgumentNullException("functionSignature");
            }
            if (argumentList == null)
            {
                throw new ArgumentNullException("argumentList");
            }


            Signature = new LSLFunctionSignature(functionSignature);

            Name = functionSignature.Name;

            ArgumentExpressionList        = argumentList;
            ArgumentExpressionList.Parent = this;

            _libraryFunction = true;
        }
Example #7
0
        /// <summary>
        ///     Construct an <see cref="LSLFunctionCallNode" /> with an arguments list and definition reference. <para/>
        ///     <paramref name="definition" /> receives this node as a new reference in <see cref="LSLFunctionDeclarationNode.References" />.
        /// </summary>
        /// <param name="argumentList">The argument list node.</param>
        /// <param name="definition">The function definition node.</param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="definition" /> or <paramref name="argumentList" /> is
        ///     <c>null</c>.
        /// </exception>
        public LSLFunctionCallNode(LSLFunctionDeclarationNode definition, LSLExpressionListNode argumentList)
        {
            if (definition == null)
            {
                throw new ArgumentNullException("definition");
            }
            if (argumentList == null)
            {
                throw new ArgumentNullException("argumentList");
            }


            Name = definition.Name;

            ArgumentExpressionList        = argumentList;
            ArgumentExpressionList.Parent = this;

            Definition = definition;
            Definition.AddReference(this);

            Signature = definition.CreateSignature();
        }
Example #8
0
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="context" /> or <paramref name="signature" /> or
        ///     <paramref name="argumentExpressionList" /> is <c>null</c>.
        /// </exception>
        internal LSLFunctionCallNode(
            LSLParser.Expr_FunctionCallContext context,
            ILSLFunctionSignature signature,
            LSLExpressionListNode argumentExpressionList)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

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

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


            Signature = signature;

            Name = context.function_name.Text;

            _libraryFunction              = true;
            ArgumentExpressionList        = argumentExpressionList;
            argumentExpressionList.Parent = this;

            SourceRange             = new LSLSourceCodeRange(context);
            SourceRangeOpenParenth  = new LSLSourceCodeRange(context.open_parenth);
            SourceRangeCloseParenth = new LSLSourceCodeRange(context.close_parenth);
            SourceRangeName         = new LSLSourceCodeRange(context.function_name);

            SourceRangesAvailable = true;
        }
Example #9
0
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="context" /> or <paramref name="preDefinition" /> or
        ///     <paramref name="argumentExpressionList" /> is <c>null</c>.
        /// </exception>
        internal LSLFunctionCallNode(
            LSLParser.Expr_FunctionCallContext context,
            LSLPreDefinedFunctionSignature preDefinition,
            LSLExpressionListNode argumentExpressionList)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

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

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

            Definition = preDefinition.DefinitionNode;
            Signature  = preDefinition;

            Name = context.function_name.Text;

            ArgumentExpressionList = argumentExpressionList;

            argumentExpressionList.Parent = this;

            SourceRange             = new LSLSourceCodeRange(context);
            SourceRangeOpenParenth  = new LSLSourceCodeRange(context.open_parenth);
            SourceRangeCloseParenth = new LSLSourceCodeRange(context.close_parenth);
            SourceRangeName         = new LSLSourceCodeRange(context.function_name);

            SourceRangesAvailable = true;
        }
Example #10
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)
 {
 }
Example #11
0
 /// <summary>
 ///     Construct an <see cref="LSLForLoopNode" /> without afterthought expressions.
 /// </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="code">The code body of the for loop.</param>
 /// <exception cref="ArgumentNullException"><paramref name="initExpressions" /> is <c>null</c>.</exception>
 public LSLForLoopNode(LSLExpressionListNode initExpressions, ILSLExprNode condition, LSLCodeScopeNode code)
     : this(initExpressions, condition, new LSLExpressionListNode(), code)
 {
 }