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

C# NET.Node类代码示例

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

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



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

示例1: initScript

 /// <summary> Script (for associating file/url names with toplevel scripts.)</summary>
 internal void initScript (ScriptOrFnNode scriptNode, Node body)
 {
     Node children = body.FirstChild;
     if (children != null) {
         scriptNode.addChildrenToBack (children);
     }
 }
开发者ID:hazzik,项目名称:EcmaScript.NET,代码行数:8,代码来源:NodeFactory.cs


示例2: addBeforeCurrent

 private static Node addBeforeCurrent(Node parent, Node previous, Node current, Node toAdd)
 {
     if (previous == null) {
         if (!(current == parent.FirstChild))
             Context.CodeBug ();
         parent.addChildToFront (toAdd);
     }
     else {
         if (!(current == previous.Next))
             Context.CodeBug ();
         parent.addChildAfter (toAdd, previous);
     }
     return toAdd;
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:14,代码来源:NodeTransformer.cs


示例3: CreateSwitch

        /// <summary> Statement leaf nodes.</summary>

        internal Node CreateSwitch (Node expr, int lineno)
        {
            //
            // The switch will be rewritten from:
            //
            // switch (expr) {
            //   case test1: statements1;
            //   ...
            //   default: statementsDefault;
            //   ...
            //   case testN: statementsN;
            // }
            //
            // to:
            //
            // {
            //     switch (expr) {
            //       case test1: goto label1;
            //       ...
            //       case testN: goto labelN;
            //     }
            //     goto labelDefault;
            //   label1:
            //     statements1;
            //   ...
            //   labelDefault:
            //     statementsDefault;
            //   ...
            //   labelN:
            //     statementsN;
            //   breakLabel:
            // }
            //
            // where inside switch each "break;" without label will be replaced
            // by "goto breakLabel".
            //
            // If the original switch does not have the default label, then
            // the transformed code would contain after the switch instead of
            //     goto labelDefault;
            // the following goto:
            //     goto breakLabel;
            //

            Node.Jump switchNode = new Node.Jump (Token.SWITCH, expr, lineno);
            Node block = new Node (Token.BLOCK, switchNode);
            return block;
        }
开发者ID:hazzik,项目名称:EcmaScript.NET,代码行数:49,代码来源:NodeFactory.cs


示例4: replaceCurrent

 private static Node replaceCurrent(Node parent, Node previous, Node current, Node replacement)
 {
     if (previous == null) {
         if (!(current == parent.FirstChild))
             Context.CodeBug ();
         parent.replaceChild (current, replacement);
     }
     else if (previous.next == current) {
         // Check cachedPrev.next == current is necessary due to possible
         // tree mutations
         parent.replaceChildAfter (previous, replacement);
     }
     else {
         parent.replaceChild (current, replacement);
     }
     return replacement;
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:17,代码来源:NodeTransformer.cs


示例5: addSwitchCase

        /// <summary> If caseExpression argument is null it indicate default label.</summary>
        internal void addSwitchCase(Node switchBlock, Node caseExpression, Node statements)
        {
            if (switchBlock.Type != Token.BLOCK)
                throw Context.CodeBug ();
            Node.Jump switchNode = (Node.Jump)switchBlock.FirstChild;
            if (switchNode.Type != Token.SWITCH)
                throw Context.CodeBug ();

            Node gotoTarget = Node.newTarget ();
            if (caseExpression != null) {
                Node.Jump caseNode = new Node.Jump (Token.CASE, caseExpression);
                caseNode.target = gotoTarget;
                switchNode.addChildToBack (caseNode);
            }
            else {
                switchNode.Default = gotoTarget;
            }
            switchBlock.addChildToBack (gotoTarget);
            switchBlock.addChildToBack (statements);
        }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:21,代码来源:NodeFactory.cs


示例6: visitCall

 protected internal virtual void visitCall (Node node, ScriptOrFnNode tree)
 {
 }
开发者ID:hazzik,项目名称:EcmaScript.NET,代码行数:3,代码来源:NodeTransformer.cs


示例7: Node

 public Node(int nodeType, Node child)
 {
     Type = nodeType;
     first = last = child;
     child.next = null;
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:6,代码来源:Node.cs


示例8: Jump

 internal Jump(int Type, Node child)
     : base(Type, child)
 {
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:4,代码来源:Node.cs


示例9: generatePrintIds

 private static void generatePrintIds(Node n, ObjToIntMap map)
 {
     if (Token.printTrees) {
         map.put (n, map.size ());
         for (Node cursor = n.FirstChild; cursor != null; cursor = cursor.Next) {
             generatePrintIds (cursor, map);
         }
     }
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:9,代码来源:Node.cs


示例10: replaceChildAfter

 public void replaceChildAfter(Node prevChild, Node newChild)
 {
     Node child = prevChild.next;
     newChild.next = child.next;
     prevChild.next = newChild;
     if (child == last)
         last = newChild;
     child.next = null;
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:9,代码来源:Node.cs


示例11: removeChild

 public void removeChild(Node child)
 {
     Node prev = getChildBefore (child);
     if (prev == null)
         first = first.next;
     else
         prev.next = child.next;
     if (child == last)
         last = prev;
     child.next = null;
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:11,代码来源:Node.cs


示例12: VisitExpression

        void VisitExpression (Node node, int contextFlags)
        {
            if (VisitExpressionOptimized (node, contextFlags))
                return;

            int type = node.Type;
            Node child = node.FirstChild;
            int savedStackDepth = itsStackDepth;
            switch (type) {


                case Token.FUNCTION: {
                        int fnIndex = node.getExistingIntProp (Node.FUNCTION_PROP);
                        FunctionNode fn = scriptOrFn.getFunctionNode (fnIndex);

                        // See comments in visitStatement for Token.FUNCTION case					
                        switch (fn.FunctionType) {
                            case FunctionNode.FUNCTION_EXPRESSION:
                                addIndexOp (Icode_CLOSURE_EXPR, fnIndex);
                                break;
                            default:
                                throw Context.CodeBug ();
                        }

                        stackChange (1);
                    }
                    break;


                case Token.LOCAL_LOAD: {
                        int localIndex = getLocalBlockRef (node);
                        addIndexOp (Token.LOCAL_LOAD, localIndex);
                        stackChange (1);
                    }
                    break;


                case Token.COMMA: {
                        Node lastChild = node.LastChild;
                        while (child != lastChild) {
                            VisitExpression (child, 0);
                            addIcode (Icode_POP);
                            stackChange (-1);
                            child = child.Next;
                        }
                        // Preserve tail context flag if any
                        VisitExpression (child, contextFlags & ECF_TAIL);
                    }
                    break;


                case Token.USE_STACK:
                    // Indicates that stack was modified externally,
                    // like placed catch object
                    stackChange (1);
                    break;


                case Token.REF_CALL:
                case Token.CALL:
                case Token.NEW: {
                        if (type == Token.NEW) {
                            VisitExpression (child, 0);
                        }
                        else {
                            generateCallFunAndThis (child);
                        }
                        int argCount = 0;
                        while ((child = child.Next) != null) {
                            VisitExpression (child, 0);
                            ++argCount;
                        }
                        int callType = node.getIntProp (Node.SPECIALCALL_PROP, Node.NON_SPECIALCALL);
                        if (callType != Node.NON_SPECIALCALL) {
                            // embed line number and source filename
                            addIndexOp (Icode_CALLSPECIAL, argCount);
                            addUint8 (callType);
                            addUint8 (type == Token.NEW ? 1 : 0);
                            addUint16 (itsLineNumber & 0xFFFF);
                        }
                        else {
                            if (type == Token.CALL) {
                                if ((contextFlags & ECF_TAIL) != 0) {
                                    type = Icode_TAIL_CALL;
                                }
                            }
                            addIndexOp (type, argCount);
                        }
                        // adjust stack
                        if (type == Token.NEW) {
                            // new: f, args -> result
                            stackChange (-argCount);
                        }
                        else {
                            // call: f, thisObj, args -> result
                            // ref_call: f, thisObj, args -> ref
                            stackChange (-1 - argCount);
                        }
                        if (argCount > itsData.itsMaxCalleeArgs) {
                            itsData.itsMaxCalleeArgs = argCount;
//.........这里部分代码省略.........
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:101,代码来源:Interpreter.cs


示例13: VisitExpressionOptimized

        bool VisitExpressionOptimized (Node node, int contextFlags)
        {
            return false;
#if FALKSE
            if (node.Type == Token.ADD) {
                Node next = node.Next;
                if (next == null)
                    return false;
                switch (next.Type) { 
                    case Token.NAME:
                    case Token.STRING:
                        return true;
                }
            }
            return false;
#endif
        }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:17,代码来源:Interpreter.cs


示例14: VisitStatement

        void VisitStatement (Node node)
        {
            int type = node.Type;
            Node child = node.FirstChild;
            switch (type) {


                case Token.FUNCTION: {
                        int fnIndex = node.getExistingIntProp (Node.FUNCTION_PROP);
                        int fnType = scriptOrFn.getFunctionNode (fnIndex).FunctionType;
                        // Only function expressions or function expression
                        // statements needs closure code creating new function
                        // object on stack as function statements are initialized
                        // at script/function start
                        // In addition function expression can not present here
                        // at statement level, they must only present as expressions.
                        if (fnType == FunctionNode.FUNCTION_EXPRESSION_STATEMENT) {
                            addIndexOp (Icode_CLOSURE_STMT, fnIndex);
                        }
                        else {
                            if (fnType != FunctionNode.FUNCTION_STATEMENT) {
                                throw Context.CodeBug ();
                            }
                        }
                    }
                    break;


                case Token.SCRIPT:
                case Token.LABEL:
                case Token.LOOP:
                case Token.BLOCK:
                case Token.EMPTY:
                case Token.WITH:
                    updateLineNumber (node);
                    while (child != null) {
                        VisitStatement (child);
                        child = child.Next;
                    }
                    break;


                case Token.ENTERWITH:
                    VisitExpression (child, 0);
                    addToken (Token.ENTERWITH);
                    stackChange (-1);
                    break;


                case Token.LEAVEWITH:
                    addToken (Token.LEAVEWITH);
                    break;


                case Token.LOCAL_BLOCK: {
                        int local = allocLocal ();
                        node.putIntProp (Node.LOCAL_PROP, local);
                        updateLineNumber (node);
                        while (child != null) {
                            VisitStatement (child);
                            child = child.Next;
                        }
                        addIndexOp (Icode_LOCAL_CLEAR, local);
                        releaseLocal (local);
                    }
                    break;

                case Token.DEBUGGER:
                    updateLineNumber (node);
                    addIcode (Icode_DEBUGGER);
                    break;

                case Token.SWITCH:
                    updateLineNumber (node); {
                        // See comments in IRFactory.createSwitch() for description
                        // of SWITCH node
                        Node switchNode = (Node.Jump)node;
                        VisitExpression (child, 0);
                        for (Node.Jump caseNode = (Node.Jump)child.Next; caseNode != null; caseNode = (Node.Jump)caseNode.Next) {
                            if (caseNode.Type != Token.CASE)
                                throw badTree (caseNode);
                            Node test = caseNode.FirstChild;
                            addIcode (Icode_DUP);
                            stackChange (1);
                            VisitExpression (test, 0);
                            addToken (Token.SHEQ);
                            stackChange (-1);
                            // If true, Icode_IFEQ_POP will jump and remove case
                            // value from stack
                            addGoto (caseNode.target, Icode_IFEQ_POP);
                            stackChange (-1);
                        }
                        addIcode (Icode_POP);
                        stackChange (-1);
                    }
                    break;


                case Token.TARGET:
                    markTargetLabel (node);
//.........这里部分代码省略.........
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:101,代码来源:Interpreter.cs


示例15: badTree

 ApplicationException badTree (Node node)
 {
     throw new ApplicationException (node.ToString ());
 }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:4,代码来源:Interpreter.cs


示例16: addChildToFront

 public void addChildToFront(Node child)
 {
     child.next = first;
     first = child;
     if (last == null) {
         last = child;
     }
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:8,代码来源:Node.cs


示例17: getChildBefore

 public Node getChildBefore(Node child)
 {
     if (child == first)
         return null;
     Node n = first;
     while (n.next != child) {
         n = n.next;
         if (n == null)
             throw new ApplicationException ("node is not a child");
     }
     return n;
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:12,代码来源:Node.cs


示例18: replaceChild

 public void replaceChild(Node child, Node newChild)
 {
     newChild.next = child.next;
     if (child == first) {
         first = newChild;
     }
     else {
         Node prev = getChildBefore (child);
         prev.next = newChild;
     }
     if (child == last)
         last = newChild;
     child.next = null;
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:14,代码来源:Node.cs


示例19: appendPrintId

 private static void appendPrintId(Node n, ObjToIntMap printIds, System.Text.StringBuilder sb)
 {
     if (Token.printTrees) {
         if (n != null) {
             int id = printIds.Get (n, -1);
             sb.Append ('#');
             if (id != -1) {
                 sb.Append (id + 1);
             }
             else {
                 sb.Append ("<not_available>");
             }
         }
     }
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:15,代码来源:Node.cs


示例20: addChildAfter

 /// <summary> Add 'child' after 'node'.</summary>
 public void addChildAfter(Node newChild, Node node)
 {
     if (newChild.next != null)
         throw new ApplicationException ("newChild had siblings in addChildAfter");
     newChild.next = node.next;
     node.next = newChild;
     if (last == node)
         last = newChild;
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:10,代码来源:Node.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# MetaMetadataNS.MetaMetadataCompositeField类代码示例发布时间:2022-05-24
下一篇:
C# NET.Context类代码示例发布时间: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