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


C# Node.putProp方法代码示例

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


在下文中一共展示了Node.putProp方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateTryCatchFinally

        /// <summary> Try/Catch/Finally
        /// 
        /// The IRFactory tries to express as much as possible in the tree;
        /// the responsibilities remaining for Codegen are to add the Java
        /// handlers: (Either (but not both) of TARGET and FINALLY might not
        /// be defined)
        /// - a catch handler for javascript exceptions that unwraps the
        /// exception onto the stack and GOTOes to the catch target
        /// - a finally handler
        /// ... and a goto to GOTO around these handlers.
        /// </summary>
        internal Node CreateTryCatchFinally(Node tryBlock, Node catchBlocks, Node finallyBlock, int lineno)
        {
            bool hasFinally = (finallyBlock != null) && (finallyBlock.Type != Token.BLOCK || finallyBlock.hasChildren ());

            // short circuit
            if (tryBlock.Type == Token.BLOCK && !tryBlock.hasChildren () && !hasFinally) {
                return tryBlock;
            }

            bool hasCatch = catchBlocks.hasChildren ();

            // short circuit
            if (!hasFinally && !hasCatch) {
                // bc finally might be an empty block...
                return tryBlock;
            }

            Node handlerBlock = new Node (Token.LOCAL_BLOCK);
            Node.Jump pn = new Node.Jump (Token.TRY, tryBlock, lineno);
            pn.putProp (Node.LOCAL_BLOCK_PROP, handlerBlock);

            if (hasCatch) {
                // jump around catch code
                Node endCatch = Node.newTarget ();
                pn.addChildToBack (makeJump (Token.GOTO, endCatch));

                // make a TARGET for the catch that the tcf node knows about
                Node catchTarget = Node.newTarget ();
                pn.target = catchTarget;
                // mark it
                pn.addChildToBack (catchTarget);

                //
                //  Given
                //
                //   try {
                //       tryBlock;
                //   } catch (e if condition1) {
                //       something1;
                //   ...
                //
                //   } catch (e if conditionN) {
                //       somethingN;
                //   } catch (e) {
                //       somethingDefault;
                //   }
                //
                //  rewrite as
                //
                //   try {
                //       tryBlock;
                //       goto after_catch:
                //   } catch (x) {
                //       with (newCatchScope(e, x)) {
                //           if (condition1) {
                //               something1;
                //               goto after_catch;
                //           }
                //       }
                //   ...
                //       with (newCatchScope(e, x)) {
                //           if (conditionN) {
                //               somethingN;
                //               goto after_catch;
                //           }
                //       }
                //       with (newCatchScope(e, x)) {
                //           somethingDefault;
                //           goto after_catch;
                //       }
                //   }
                // after_catch:
                //
                // If there is no default catch, then the last with block
                // arround  "somethingDefault;" is replaced by "rethrow;"

                // It is assumed that catch handler generation will store
                // exeception object in handlerBlock register

                // Block with local for exception scope objects
                Node catchScopeBlock = new Node (Token.LOCAL_BLOCK);

                // expects catchblocks children to be (cond block) pairs.
                Node cb = catchBlocks.FirstChild;
                bool hasDefault = false;
                int scopeIndex = 0;
                while (cb != null) {
                    int catchLineNo = cb.Lineno;

//.........这里部分代码省略.........
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:101,代码来源:NodeFactory.cs

示例2: CreatePropertyGet

 internal Node CreatePropertyGet(Node target, string ns, string name, int memberTypeFlags)
 {
     if (ns == null && memberTypeFlags == 0) {
         if (target == null) {
             return CreateName (name);
         }
         checkActivationName (name, Token.GETPROP);
         if (ScriptRuntime.isSpecialProperty (name)) {
             Node rf = new Node (Token.REF_SPECIAL, target);
             rf.putProp (Node.NAME_PROP, name);
             return new Node (Token.GET_REF, rf);
         }
         return new Node (Token.GETPROP, target, CreateString (name));
     }
     Node elem = CreateString (name);
     memberTypeFlags |= Node.PROPERTY_FLAG;
     return CreateMemberRefGet (target, ns, elem, memberTypeFlags);
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:18,代码来源:NodeFactory.cs

示例3: CreateObjectLiteral

 /// <summary> Object Literals
 /// <BR> CreateObjectLiteral rewrites its argument as object
 /// creation plus object property entries, so later compiler
 /// stages don't need to know about object literals.
 /// </summary>
 internal Node CreateObjectLiteral(ObjArray elems)
 {
     int size = elems.size () / 2;
     Node obj = new Node (Token.OBJECTLIT);
     object [] properties;
     if (size == 0) {
         properties = ScriptRuntime.EmptyArgs;
     }
     else {
         properties = new object [size];
         for (int i = 0; i != size; ++i) {
             properties [i] = elems.Get (2 * i);
             Node value = (Node)elems.Get (2 * i + 1);
             obj.addChildToBack (value);
         }
     }
     obj.putProp (Node.OBJECT_IDS_PROP, properties);
     return obj;
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:24,代码来源:NodeFactory.cs

示例4: CreateForIn

        /// <summary> For .. In
        /// 
        /// </summary>
        internal Node CreateForIn(Node loop, Node lhs, Node obj, Node body, bool isForEach)
        {
            int type = lhs.Type;

            Node lvalue;
            if (type == Token.VAR) {
                /*
                * check that there was only one variable given.
                * we can't do this in the parser, because then the
                * parser would have to know something about the
                * 'init' node of the for-in loop.
                */
                Node lastChild = lhs.LastChild;
                if (lhs.FirstChild != lastChild) {
                    parser.ReportError ("msg.mult.index");
                }
                lvalue = Node.newString (Token.NAME, lastChild.String);
            }
            else {
                lvalue = makeReference (lhs);
                if (lvalue == null) {
                    parser.ReportError ("msg.bad.for.in.lhs");
                    return obj;
                }
            }

            Node localBlock = new Node (Token.LOCAL_BLOCK);

            int initType = (isForEach) ? Token.ENUM_INIT_VALUES : Token.ENUM_INIT_KEYS;
            Node init = new Node (initType, obj);
            init.putProp (Node.LOCAL_BLOCK_PROP, localBlock);
            Node cond = new Node (Token.ENUM_NEXT);
            cond.putProp (Node.LOCAL_BLOCK_PROP, localBlock);
            Node id = new Node (Token.ENUM_ID);
            id.putProp (Node.LOCAL_BLOCK_PROP, localBlock);

            Node newBody = new Node (Token.BLOCK);
            Node assign = simpleAssignment (lvalue, id);
            newBody.addChildToBack (new Node (Token.EXPR_VOID, assign));
            newBody.addChildToBack (body);

            loop = CreateWhile (loop, cond, newBody);
            loop.addChildToFront (init);
            if (type == Token.VAR)
                loop.addChildToFront (lhs);
            localBlock.addChildToBack (loop);

            return localBlock;
        }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:52,代码来源:NodeFactory.cs

示例5: CreateArrayLiteral

 internal Node CreateArrayLiteral(ObjArray elems, int skipCount)
 {
     int length = elems.size ();
     int [] skipIndexes = null;
     if (skipCount != 0) {
         skipIndexes = new int [skipCount];
     }
     Node array = new Node (Token.ARRAYLIT);
     for (int i = 0, j = 0; i != length; ++i) {
         Node elem = (Node)elems.Get (i);
         if (elem != null) {
             array.addChildToBack (elem);
         }
         else {
             skipIndexes [j] = i;
             ++j;
         }
     }
     if (skipCount != 0) {
         array.putProp (Node.SKIP_INDEXES_PROP, skipIndexes);
     }
     return array;
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:23,代码来源:NodeFactory.cs

示例6: CreateUseLocal

 internal Node CreateUseLocal(Node localBlock)
 {
     if (Token.LOCAL_BLOCK != localBlock.Type)
         throw Context.CodeBug ();
     Node result = new Node (Token.LOCAL_LOAD);
     result.putProp (Node.LOCAL_BLOCK_PROP, localBlock);
     return result;
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:8,代码来源:NodeFactory.cs


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