/// <summary>
        ///     Build a <see cref="LSLParameterSignature" /> object based off the signature of this parameter declaration node, with the given parameter index.
        /// </summary>
        /// <param name="parameterNode">The <see cref="ILSLParameterNode"/>.</param>
        /// <param name="parameterIndex">The parameter index to use for the created paramter signature.</param>
        /// <returns>The created <see cref="LSLParameterSignature" />.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="parameterNode"/> is <see langword="null" />.</exception>
        public static LSLParameterSignature CreateSignature(this ILSLParameterNode parameterNode, int parameterIndex)
        {
            if (parameterNode == null)
            {
                throw new ArgumentNullException("parameterNode");
            }

            return(new LSLParameterSignature(parameterNode.Type, parameterNode.Name, false, parameterIndex));
        }
Beispiel #2
0
 void ILSLSyntaxWarningListener.ParameterHidesGlobalVariable(LSLSourceCodeRange location,
                                                             ILSLEventSignature eventHandlerSignature,
                                                             ILSLParameterNode parameter, ILSLVariableDeclarationNode globalVariable)
 {
     _warningActionQueue.Enqueue(location.StartIndex,
                                 () =>
                                 SyntaxWarningListener.ParameterHidesGlobalVariable(location, eventHandlerSignature, parameter,
                                                                                    globalVariable));
 }
 /// <summary>
 ///     A parameter name of a library defined event handler hides the definition of a global variable.
 /// </summary>
 /// <param name="location">The location in source code of the parameter that hides the global variable.</param>
 /// <param name="eventHandlerSignature">The event handler signature to which the parameter definition belongs to.</param>
 /// <param name="parameter">The signature of the parameter that hides the global variable.</param>
 /// <param name="globalVariable">The variable declaration node of the global variable that was hidden.</param>
 public virtual void ParameterHidesGlobalVariable(LSLSourceCodeRange location,
                                                  ILSLEventSignature eventHandlerSignature,
                                                  ILSLParameterNode parameter, ILSLVariableDeclarationNode globalVariable)
 {
     OnWarning(location,
               string.Format(
                   "Parameter \"{0}\" of event handler \"{1}\" hides global variable \"{2}\" defined on line {3}.",
                   parameter.Name, eventHandlerSignature.Name, globalVariable.Name,
                   MapLineNumber(globalVariable.SourceRange.LineStart)));
 }
Beispiel #4
0
 /// <summary>
 ///     Construct an <see cref="LSLVariableNode" /> that references a local parameter node.
 /// </summary>
 /// <param name="declarationNode">A parameter node that declares the parameter variable.</param>
 /// <param name="sourceRange">Optional source range for the area the reference exists in.</param>
 internal static LSLVariableNode CreateParameterReference(ILSLParameterNode declarationNode, LSLSourceCodeRange sourceRange = null)
 {
     return(new LSLVariableNode
     {
         Name = declarationNode.Name,
         TypeName = declarationNode.Type.ToLSLTypeName(),
         Type = declarationNode.Type,
         ExpressionType = LSLExpressionType.ParameterVariable,
         IsConstant = false,
         SourceRange = sourceRange
     });
 }
Beispiel #5
0
        /// <summary>
        ///     Construct an <see cref="LSLVariableDeclarationNode" /> that represents a parameter.
        /// </summary>
        /// <returns>The created variable declaration node.</returns>
        /// <param name="declarationNode">A parameter node that declares the parameter variable.</param>
        /// <exception cref="ArgumentNullException"><paramref name="declarationNode"/> is <c>null</c>.</exception>
        public static LSLVariableDeclarationNode CreateParameter(ILSLParameterNode declarationNode)
        {
            if (declarationNode == null)
            {
                throw new ArgumentNullException("declarationNode");
            }

            var n = new LSLVariableDeclarationNode
            {
                VariableNode          = LSLVariableNode.CreateParameterReference(declarationNode),
                SourceRange           = declarationNode.SourceRange,
                SourceRangesAvailable = true
            };

            n.VariableNode.Parent = n;

            return(n);
        }
Beispiel #6
0
        /// <summary>
        ///     Create an <see cref="LSLParameterNode" /> 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 LSLParameterNode(ILSLParameterNode other)
        {
            if (other == null)
            {
                throw new ArgumentNullException("other");
            }


            SourceRangesAvailable = other.SourceRangesAvailable;
            if (SourceRangesAvailable)
            {
                SourceRange     = other.SourceRange;
                SourceRangeName = other.SourceRangeName;
                SourceRangeType = other.SourceRangeType;
            }

            TypeName       = other.TypeName;
            Type           = other.Type;
            Name           = other.Name;
            ParameterIndex = other.ParameterIndex;

            HasErrors = other.HasErrors;
        }
Beispiel #7
0
 /// <summary>
 ///     Visits a parameter definition of either a user defined function or event handler during syntax tree traversal.
 /// </summary>
 /// <param name="node">The Syntax Tree Node.</param>
 /// <seealso cref="LSLValidatorNodeVisitor{T}.VisitParameterDefinitionList">
 ///     VisitParameterDefinitionList calls this method
 ///     while visiting its children.
 /// </seealso>
 /// <returns>An object of type (T) from the visitor implementation of this function.</returns>
 public virtual T VisitParameterDefinition(ILSLParameterNode node)
 {
     return(default(T));
 }
Beispiel #8
0
 void ILSLSyntaxWarningListener.LocalVariableHidesParameter(LSLSourceCodeRange location,
                                                            ILSLFunctionSignature functionSignature,
                                                            ILSLVariableDeclarationNode localVariable, ILSLParameterNode parameter)
 {
     _warningActionQueue.Enqueue(location.StartIndex,
                                 () =>
                                 SyntaxWarningListener.LocalVariableHidesParameter(location, functionSignature, localVariable,
                                                                                   parameter));
 }
 /// <summary>
 ///     A local variable name inside of a library defined event handler hides the definition of one of the event handlers
 ///     parameters.
 /// </summary>
 /// <param name="location">The location in source code of the local variable that hides the event handler parameter.</param>
 /// <param name="eventHandlerSignature">The signature of the event handler in which the local variable is defined.</param>
 /// <param name="localVariable">The variable declaration node of the local variable that hides the parameter.</param>
 /// <param name="parameter">The parameter node of the parameter that was hidden.</param>
 public virtual void LocalVariableHidesParameter(LSLSourceCodeRange location,
                                                 ILSLEventSignature eventHandlerSignature,
                                                 ILSLVariableDeclarationNode localVariable, ILSLParameterNode parameter)
 {
     OnWarning(location,
               string.Format("Local variable \"{0}\" in event handler \"{1}\" hides parameter \"{2}\".",
                             localVariable.Name, eventHandlerSignature.Name, parameter.Name));
 }