/// <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; }
/// <summary> /// Construct an <see cref="LSLEventHandlerNode" /> with the given parameter list and code body. /// </summary> /// <param name="name">The event handler name.</param> /// <param name="parameterList">The parameter list.</param> /// <param name="code">The code body.</param> /// <exception cref="ArgumentNullException"> /// if <paramref name="name" /> or <paramref name="parameterList" /> or /// <paramref name="code" /> is <c>null</c>. /// </exception> /// <exception cref="LSLInvalidSymbolNameException"><paramref name="name" /> contained characters not allowed in an LSL ID token.</exception> public LSLEventHandlerNode(string name, LSLParameterListNode parameterList, LSLCodeScopeNode code) { if (name == null) { throw new ArgumentNullException("name"); } if (parameterList == null) { throw new ArgumentNullException("parameterList"); } if (code == null) { throw new ArgumentNullException("code"); } if (!LSLTokenTools.IDRegexAnchored.IsMatch(name)) { throw new LSLInvalidSymbolNameException("name provided contained characters not allowed in an LSL ID token."); } ParameterList = parameterList; ParameterList.Parent = this; Name = name; Code = code; Code.Parent = this; Code.CodeScopeType = LSLCodeScopeType.EventHandler; }
/// <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; }
/// <exception cref="ArgumentNullException"> /// <paramref name="parameterList" /> or <paramref name="code" /> is /// <c>null</c>. /// </exception> internal LSLEventHandlerNode(LSLParser.EventHandlerContext context, LSLParameterListNode parameterList, LSLCodeScopeNode code) { if (parameterList == null) { throw new ArgumentNullException("parameterList"); } if (code == null) { throw new ArgumentNullException("code"); } Name = context.handler_name.Text; Code = code; Code.Parent = this; Code.CodeScopeType = LSLCodeScopeType.EventHandler; ParameterList = parameterList; ParameterList.Parent = this; SourceRange = new LSLSourceCodeRange(context); SourceRangeName = new LSLSourceCodeRange(context.handler_name); SourceRangesAvailable = true; }
/// <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; }
/* * /// <summary> * /// Create an <see cref="LSLElseStatementNode" /> 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 LSLElseStatementNode(LSLElseStatementNode other) * { * if (other == null) throw new ArgumentNullException("other"); * * * SourceRangesAvailable = other.SourceRangesAvailable; * if (SourceRangesAvailable) * { * SourceRange = other.SourceRange; * SourceRangeElseKeyword = other.SourceRangeElseKeyword; * } * * Code = other.Code.Clone(); * Code.Parent = this; * * HasErrors = other.HasErrors; * }*/ /// <exception cref="ArgumentNullException"><paramref name="code" /> or <paramref name="code" /> is <c>null</c>.</exception> internal LSLElseStatementNode(LSLParser.ElseStatementContext context, LSLCodeScopeNode code, bool isConstantBranch) { if (context == null) { throw new ArgumentNullException("context"); } if (code == null) { throw new ArgumentNullException("code"); } IsConstantBranch = isConstantBranch; Code = code; Code.Parent = this; Code.CodeScopeType = LSLCodeScopeType.Else; SourceRangeElseKeyword = new LSLSourceCodeRange(context.else_keyword); SourceRange = new LSLSourceCodeRange(SourceRangeElseKeyword, code.SourceRange); SourceRangesAvailable = true; }
/// <summary> /// Construct an <see cref="LSLElseStatementNode" /> with the given code body. /// </summary> /// <param name="code">The code.</param> /// <exception cref="ArgumentNullException"><paramref name="code" /> is <c>null</c>.</exception> public LSLElseStatementNode(LSLCodeScopeNode code) { if (code == null) { throw new ArgumentNullException("code"); } Code = code; Code.Parent = this; Code.CodeScopeType = LSLCodeScopeType.Else; }
/// <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; }
/// <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; }
/// <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="parameterList" /> or <paramref name="code" /> /// is <c>null</c>. /// </exception> internal LSLFunctionDeclarationNode(LSLParser.FunctionDeclarationContext context, LSLParameterListNode parameterList, LSLCodeScopeNode code) { if (parameterList == null) { throw new ArgumentNullException("parameterList"); } if (code == null) { throw new ArgumentNullException("code"); } if (context.return_type != null) { ReturnTypeName = context.return_type.Text; ReturnType = LSLTypeTools.FromLSLTypeName(ReturnTypeName); SourceRangeReturnType = new LSLSourceCodeRange(context.return_type); } else { ReturnTypeName = ""; ReturnType = LSLType.Void; } Name = context.function_name.Text; ParameterList = parameterList; ParameterList.Parent = this; Code = code; Code.Parent = this; Code.CodeScopeType = LSLCodeScopeType.Function; SourceRange = new LSLSourceCodeRange(context); SourceRangeName = new LSLSourceCodeRange(context.function_name); SourceRangesAvailable = true; }
/// <summary> /// Construct an <see cref="LSLFunctionDeclarationNode" /> with the given return type, parameter list, and code body. /// </summary> /// <param name="returnType">The return type of the function.</param> /// <param name="functionName">The name of the function.</param> /// <param name="parameterList">The parameter list node representing the list of parameter definitions for the function.</param> /// <param name="code">The code scope that makes up the function's code body.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="functionName" /> or <paramref name="parameterList" /> or <paramref name="code" /> is <c>null</c>. /// </exception> /// <exception cref="LSLInvalidSymbolNameException"> /// if <paramref name="functionName" /> contains invalid characters for an LSL ID /// token. /// </exception> public LSLFunctionDeclarationNode(LSLType returnType, string functionName, LSLParameterListNode parameterList, LSLCodeScopeNode code) { if (parameterList == null) { throw new ArgumentNullException("parameterList"); } if (code == null) { throw new ArgumentNullException("code"); } if (functionName == null) { throw new ArgumentNullException("functionName"); } if (!LSLTokenTools.IDRegexAnchored.IsMatch(functionName)) { throw new LSLInvalidSymbolNameException( "functionName provided contained characters not allowed in an LSL ID token."); } Name = functionName; ReturnTypeName = returnType == LSLType.Void ? "" : LSLTypeTools.ToLSLTypeName(returnType); ReturnType = returnType; ParameterList = parameterList; ParameterList.Parent = this; Code = code; Code.Parent = this; Code.CodeScopeType = LSLCodeScopeType.Function; }
/* * /// <summary> * /// Create an <see cref="LSLFunctionDeclarationNode" /> 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 LSLFunctionDeclarationNode(LSLFunctionDeclarationNode other) * { * if (other == null) throw new ArgumentNullException("other"); * * * SourceRangesAvailable = other.SourceRangesAvailable; * * if (SourceRangesAvailable) * { * SourceRange = other.SourceRange; * SourceRangeName = other.SourceRangeName; * SourceRangeReturnType = other.SourceRangeReturnType; * SourceRangesAvailable = other.SourceRangesAvailable; * } * * * Name = other.Name; * * ParameterList = other.ParameterList.Clone(); * ParameterList.Parent = this; * * Code = other.Code.Clone(); * Code.Parent = this; * * * HasErrors = other.HasErrors; * }*/ /// <summary> /// Construct an <see cref="LSLFunctionDeclarationNode" /> with the given return type, and code body. /// The function declaration will have an empty parameter list node. /// </summary> /// <param name="returnType">The return type of the function.</param> /// <param name="functionName">The name of the function.</param> /// <param name="code">The code scope that makes up the function's code body.</param> /// <exception cref="ArgumentException"> /// if <paramref name="functionName" /> contains invalid characters for an LSL ID /// token. /// </exception> public LSLFunctionDeclarationNode(LSLType returnType, string functionName, LSLCodeScopeNode code) : this(returnType, functionName, new LSLParameterListNode(), code) { }
/// <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) { }
/// <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) { }