本文整理汇总了C#中AstNode.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# AstNode.GetLength方法的具体用法?C# AstNode.GetLength怎么用?C# AstNode.GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AstNode
的用法示例。
在下文中一共展示了AstNode.GetLength方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ThrowStatement
public ThrowStatement(int pos, AstNode expr) : base(pos, expr.GetLength())
{
{
type = Token.THROW;
}
SetExpression(expr);
}
示例2: SetBody
/// <summary>Sets loop body.</summary>
/// <remarks>
/// Sets loop body. Sets the parent of the body to this loop node,
/// and updates its offset to be relative. Extends the length of this
/// node to include the body.
/// </remarks>
public virtual void SetBody(AstNode body)
{
this.body = body;
int end = body.GetPosition() + body.GetLength();
this.SetLength(end - this.GetPosition());
body.SetParent(this);
}
示例3: SetLeftAndRight
public virtual void SetLeftAndRight(AstNode left, AstNode right)
{
AssertNotNull(left);
AssertNotNull(right);
// compute our bounds while children have absolute positions
int beg = left.GetPosition();
int end = right.GetPosition() + right.GetLength();
SetBounds(beg, end);
// this updates their positions to be parent-relative
SetLeft(left);
SetRight(right);
}
示例4: SetBody
/// <summary>Sets function body, and sets its parent to this node.</summary>
/// <remarks>
/// Sets function body, and sets its parent to this node.
/// Also sets the encoded source bounds based on the body bounds.
/// Assumes the function node absolute position has already been set,
/// and the body node's absolute position and length are set.<p>
/// </remarks>
/// <param name="body">
/// function body. Its parent is set to this node, and its
/// position is updated to be relative to this node.
/// </param>
/// <exception cref="System.ArgumentException">
/// if body is
/// <code>null</code>
/// </exception>
public virtual void SetBody(AstNode body)
{
AssertNotNull(body);
this.body = body;
if (true.Equals(body.GetProp(Node.EXPRESSION_CLOSURE_PROP)))
{
SetIsExpressionClosure(true);
}
int absEnd = body.GetPosition() + body.GetLength();
body.SetParent(this);
this.SetLength(absEnd - this.position);
SetEncodedSourceBounds(this.position, absEnd);
}
示例5: ExpressionStatement
/// <summary>
/// Constructs a new
/// <code>ExpressionStatement</code>
/// wrapping
/// the specified expression. Sets this node's position to the
/// position of the wrapped node, and sets the wrapped node's
/// position to zero. Sets this node's length to the length of
/// the wrapped node.
/// </summary>
/// <param name="expr">the wrapped expression</param>
public ExpressionStatement(AstNode expr) : this(expr.GetPosition(), expr.GetLength(), expr)
{
}
示例6: UnaryExpression
/// <summary>
/// Constructs a new UnaryExpression with the specified operator
/// and operand.
/// </summary>
/// <remarks>
/// Constructs a new UnaryExpression with the specified operator
/// and operand. It sets the parent of the operand, and sets its own bounds
/// to encompass the operator and operand.
/// </remarks>
/// <param name="operator">the node type</param>
/// <param name="operatorPosition">the absolute position of the operator.</param>
/// <param name="operand">the operand expression</param>
/// <param name="postFix">true if the operator follows the operand. Int</param>
/// <exception cref="System.ArgumentException">
/// } if
/// <code>operand</code>
/// is
/// <code>null</code>
/// </exception>
public UnaryExpression(int @operator, int operatorPosition, AstNode operand, bool postFix)
{
AssertNotNull(operand);
int beg = postFix ? operand.GetPosition() : operatorPosition;
// JavaScript only has ++ and -- postfix operators, so length is 2
int end = postFix ? operatorPosition + 2 : operand.GetPosition() + operand.GetLength();
SetBounds(beg, end);
SetOperator(@operator);
SetOperand(operand);
isPostfix = postFix;
}
示例7: ParenthesizedExpression
public ParenthesizedExpression(AstNode expr) : this(expr != null ? expr.GetPosition() : 0, expr != null ? expr.GetLength() : 1, expr)
{
}
示例8: AddStatement
/// <summary>Adds a statement to the end of the statement list.</summary>
/// <remarks>
/// Adds a statement to the end of the statement list.
/// Sets the parent of the new statement to this node, updates
/// its start offset to be relative to this node, and sets the
/// length of this node to include the new child.
/// </remarks>
/// <param name="statement">a child statement</param>
/// <exception cref="System.ArgumentException">
/// } if statement is
/// <code>null</code>
/// </exception>
public virtual void AddStatement(AstNode statement)
{
AssertNotNull(statement);
if (statements == null)
{
statements = new List<AstNode>();
}
int end = statement.GetPosition() + statement.GetLength();
this.SetLength(end - this.GetPosition());
statements.Add(statement);
statement.SetParent(this);
}