当前位置: 首页>>代码示例>>C#>>正文


C# NET.Node类代码示例

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


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


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