• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# JsAstNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中JsAstNode的典型用法代码示例。如果您正苦于以下问题:C# JsAstNode类的具体用法?C# JsAstNode怎么用?C# JsAstNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JsAstNode类属于命名空间,在下文中一共展示了JsAstNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: IsEquivalentTo

 public override bool IsEquivalentTo(JsAstNode otherNode)
 {
     var otherRegExp = otherNode as JsRegExpLiteral;
     return otherRegExp != null
         && string.CompareOrdinal(Pattern, otherRegExp.Pattern) == 0
         && string.CompareOrdinal(PatternSwitches, otherRegExp.PatternSwitches) == 0;
 }
开发者ID:niravpatel2008,项目名称:spike-build,代码行数:7,代码来源:JsRegExpLiteral.cs


示例2: IsSafe

 public bool IsSafe(JsAstNode node)
 {
     // assume it is unless preven otherwise
     m_isSafe = true;
     node.IfNotNull(n => n.Accept(this));
     return m_isSafe;
 }
开发者ID:niravpatel2008,项目名称:spike-build,代码行数:7,代码来源:JsStatementStartVisitor.cs


示例3: Apply

 public static void Apply(JsAstNode node)
 {
     if (node != null)
     {
         node.Accept(s_instance);
     }
 }
开发者ID:MatthewNichols,项目名称:misakai-baker,代码行数:7,代码来源:JsDetachReferences.cs


示例4: Append

 public void Append(JsAstNode statement)
 {
     if (statement != null)
     {
         Context.UpdateWith(statement.Context);
         Statements.Append(statement);
     }
 }
开发者ID:niravpatel2008,项目名称:spike-build,代码行数:8,代码来源:JsConditionalCompilationComment.cs


示例5: ReplaceChild

 public override bool ReplaceChild(JsAstNode oldNode, JsAstNode newNode)
 {
     if (Operand == oldNode)
     {
         Operand = newNode;
         return true;
     }
     return false;
 }
开发者ID:niravpatel2008,项目名称:spike-build,代码行数:9,代码来源:JsReturnNode.cs


示例6: ReplaceChild

 public override bool ReplaceChild(JsAstNode oldNode, JsAstNode newNode)
 {
     if (Value == oldNode)
     {
         Value = newNode;
         return true;
     }
     return false;
 }
开发者ID:MatthewNichols,项目名称:misakai-baker,代码行数:9,代码来源:JsConditionalCompilationSet.cs


示例7: ReplaceChild

 public override bool ReplaceChild(JsAstNode oldNode, JsAstNode newNode)
 {
     if (Condition == oldNode)
     {
         Condition = newNode;
         return true;
     }
     return false;
 }
开发者ID:MatthewNichols,项目名称:misakai-baker,代码行数:9,代码来源:JsConditionalCompilationIf.cs


示例8: IsEquivalentTo

        public override bool IsEquivalentTo(JsAstNode otherNode)
        {
            var otherThis = otherNode as JsThisLiteral;

            // this really assume we are comparing this operators from the same object scope.
            // if you compare a this-literal from one function to a this-literal from another,
            // it will pop positive -- but it won't actually be equivalent!
            return otherThis != null;
        }
开发者ID:niravpatel2008,项目名称:spike-build,代码行数:9,代码来源:JsThisLiteral.cs


示例9: Apply

        public static bool Apply(TextWriter writer, JsAstNode node)
        {
            if (node != null)
            {
                var visitor = new JsonOutputVisitor(writer);
                node.Accept(visitor);
                return visitor.IsValid;
            }

            return false;
        }
开发者ID:MatthewNichols,项目名称:misakai-baker,代码行数:11,代码来源:JsonOutputVisitor.cs


示例10: Apply

        public static void Apply(TextWriter writer, JsAstNode node, JsSettings settings)
        {
            if (node != null)
            {
                var outputVisitor = new JsOutputVisitor(writer, settings);
                node.Accept(outputVisitor);

                // if there is a symbol map that we are tracking, tell it that we have ended an output run
                // and pass it offsets to the last line and column positions.
                settings.IfNotNull(s => s.SymbolsMap.IfNotNull(m => m.EndOutputRun(outputVisitor.m_lineCount, outputVisitor.m_lineLength)));
            }
        }
开发者ID:MatthewNichols,项目名称:misakai-baker,代码行数:12,代码来源:JsOutputVisitor.cs


示例11: Match

        public bool Match(JsAstNode node, string identifiers)
        {
            // set the match to false
            m_isMatch = false;

            // identifiers cannot be null or blank and must match: IDENT(.IDENT)*
            // since for JS there has to be at least a global object, the dot must be AFTER the first character.
            if (node != null && !string.IsNullOrEmpty(identifiers))
            {
                // get all the parts
                var parts = identifiers.Split('.');

                // each part must be a valid JavaScript identifier. Assume everything is valid
                // unless at least one is invalid -- then forget it
                var isValid = true;
                foreach (var part in parts)
                {
                    if (!JsScanner.IsValidIdentifier(part))
                    {
                        isValid = false;
                        break;
                    }
                }

                // must be valid to continue
                if (isValid)
                {
                    // save the parts and start the index on the last one, since we'll be walking backwards
                    m_parts = parts;
                    m_index = parts.Length - 1;

                    node.Accept(this);
                }
            }

            return m_isMatch;
        }
开发者ID:niravpatel2008,项目名称:spike-build,代码行数:37,代码来源:JsMatchPropertiesVisitor.cs


示例12: ReplaceChild

        /// <summary>
        /// Replace the existing direct child node of the block with a new node.
        /// </summary>
        /// <param name="oldNode">existing statement node to replace.</param>
        /// <param name="newNode">node with which to replace the existing node.</param>
        /// <returns>true if the replacement was a succeess; false otherwise</returns>
        public override bool ReplaceChild(JsAstNode oldNode, JsAstNode newNode)
        {
            for (int ndx = m_list.Count - 1; ndx >= 0; --ndx)
            {
                if (m_list[ndx] == oldNode)
                {
                    m_list[ndx].IfNotNull(n => n.Parent = (n.Parent == this) ? null : n.Parent);
                    if (newNode == null)
                    {
                        // just remove it
                        m_list.RemoveAt(ndx);
                    }
                    else
                    {
                        JsBlock newBlock = newNode as JsBlock;
                        if (newBlock != null)
                        {
                            // the new "statement" is a block. That means we need to insert all
                            // the statements from the new block at the location of the old item.
                            m_list.RemoveAt(ndx);
                            InsertRange(ndx, newBlock.m_list);
                        }
                        else
                        {
                            // not a block -- slap it in there
                            m_list[ndx] = newNode;
                            newNode.Parent = this;
                        }
                    }

                    return true;
                }
            }

            return false;
        }
开发者ID:MatthewNichols,项目名称:misakai-baker,代码行数:42,代码来源:JsBlock.cs


示例13: ReplaceChild

 public override bool ReplaceChild(JsAstNode oldNode, JsAstNode newNode)
 {
     if (TryBlock == oldNode)
     {
         TryBlock = ForceToBlock(newNode);
         return true;
     }
     if (CatchParameter == oldNode)
     {
         CatchParameter = newNode as JsParameterDeclaration;
         return true;
     }
     if (CatchBlock == oldNode)
     {
         CatchBlock = ForceToBlock(newNode);
         return true;
     }
     if (FinallyBlock == oldNode)
     {
         FinallyBlock = ForceToBlock(newNode);
         return true;
     }
     return false;
 }
开发者ID:MatthewNichols,项目名称:misakai-baker,代码行数:24,代码来源:JsTryNode.cs


示例14: Insert

 /// <summary>
 /// Insert a new node into the given position index within the block
 /// </summary>
 /// <param name="position">zero-based index into which the new node will be inserted</param>
 /// <param name="item">new node to insert into the block</param>
 public void Insert(int position, JsAstNode item)
 {
     if (item != null)
     {
         var block = item as JsBlock;
         if (block != null)
         {
             InsertRange(position, block.Children);
         }
         else
         {
             item.Parent = this;
             m_list.Insert(position, item);
         }
     }
 }
开发者ID:MatthewNichols,项目名称:misakai-baker,代码行数:21,代码来源:JsBlock.cs


示例15: InsertAfter

 /// <summary>
 /// Insert the given statement node after an existing node in the block.
 /// </summary>
 /// <param name="after">exisitng child node of the block</param>
 /// <param name="item">node to insert after the existing node</param>
 public void InsertAfter(JsAstNode after, JsAstNode item)
 {
     if (item != null)
     {
         int index = m_list.IndexOf(after);
         if (index >= 0)
         {
             var block = item as JsBlock;
             if (block != null)
             {
                 // don't insert a block into a block -- insert the new block's
                 // children instead (don't want nested blocks)
                 InsertRange(index + 1, block.Children);
             }
             else
             {
                 item.Parent = this;
                 m_list.Insert(index + 1, item);
             }
         }
     }
 }
开发者ID:MatthewNichols,项目名称:misakai-baker,代码行数:27,代码来源:JsBlock.cs


示例16: Append

 /// <summary>
 /// Append the given statement node to the end of the block
 /// </summary>
 /// <param name="element">node to add to the block</param>
 public void Append(JsAstNode element)
 {
     if (element != null)
     {
         element.Parent = this;
         m_list.Add(element);
     }
 }
开发者ID:MatthewNichols,项目名称:misakai-baker,代码行数:12,代码来源:JsBlock.cs


示例17: IndexOf

 /// <summary>
 /// Gets the zero-based index of the given syntax tree node within the block, or -1 if the node is not a direct child of the block
 /// </summary>
 /// <param name="child">node to find</param>
 /// <returns>zero-based index of the node in the block, or -1 if the node is not a direct child of the block</returns>
 public int IndexOf(JsAstNode child)
 {
     return m_list.IndexOf(child);
 }
开发者ID:MatthewNichols,项目名称:misakai-baker,代码行数:9,代码来源:JsBlock.cs


示例18: ReplaceNodeCheckParens

        private static void ReplaceNodeCheckParens(JsAstNode oldNode, JsAstNode newNode)
        {
            var grouping = oldNode.Parent as JsGroupingOperator;
            if (grouping != null)
            {
                if (newNode != null)
                {
                    var targetPrecedence = grouping.Parent.Precedence;
                    var conditional = grouping.Parent as JsConditional;
                    if (conditional != null)
                    {
                        // the conditional is weird in that the different parts need to be
                        // compared against different precedences, not the precedence of the
                        // conditional itself. The condition should be compared to logical-or,
                        // and the true/false expressions against assignment.
                        targetPrecedence = conditional.Condition == grouping
                            ? JsOperatorPrecedence.LogicalOr
                            : JsOperatorPrecedence.Assignment;
                    }

                    if (newNode.Precedence >= targetPrecedence)
                    {
                        // don't need the parens anymore, so replace the grouping operator
                        // with the new node, thereby eliminating the parens
                        grouping.Parent.ReplaceChild(grouping, newNode);
                    }
                    else
                    {
                        // still need the parens; just replace the node with the literal
                        oldNode.Parent.ReplaceChild(oldNode, newNode);
                    }
                }
                else
                {
                    // eliminate the parens
                    grouping.Parent.ReplaceChild(grouping, null);
                }
            }
            else
            {
                // just replace the node with the literal
                oldNode.Parent.ReplaceChild(oldNode, newNode);
            }
        }
开发者ID:niravpatel2008,项目名称:spike-build,代码行数:44,代码来源:JsEvaluateLiteralVisitor.cs


示例19: GetFunctionGuess

 internal override string GetFunctionGuess(JsAstNode target)
 {
     return Operand2 == target
         ? IsAssign ? Operand1.GetFunctionGuess(this) : Parent.GetFunctionGuess(this)
         : string.Empty;
 }
开发者ID:MatthewNichols,项目名称:misakai-baker,代码行数:6,代码来源:JsBinaryOperator.cs


示例20: ReplaceChild

 public override bool ReplaceChild(JsAstNode oldNode, JsAstNode newNode)
 {
     if (Statement == oldNode)
     {
         Statement = newNode;
         return true;
     }
     return false;
 }
开发者ID:MatthewNichols,项目名称:misakai-baker,代码行数:9,代码来源:JsLabeledStatement.cs



注:本文中的JsAstNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# JsDate类代码示例发布时间:2022-05-24
下一篇:
C# JsArray类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap