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


C# IScriptable.GetPrototype方法代码示例

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


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

示例1: GetBase

 private static IScriptable GetBase (IScriptable obj, string name)
 {
     do {
         if (obj.Has (name, obj))
             break;
         obj = obj.GetPrototype ();
     }
     while (obj != null);
     return obj;
 }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:10,代码来源:ScriptableObject.cs

示例2: GetProperty

 /// <summary> Gets an indexed property from an object or any object in its prototype chain.
 /// <p>
 /// Searches the prototype chain for a property with integral index
 /// <code>index</code>. Note that if you wish to look for properties with numerical
 /// but non-integral indicies, you should use getProperty(Scriptable,String) with
 /// the string value of the index.
 /// <p>
 /// </summary>
 /// <param name="obj">a JavaScript object
 /// </param>
 /// <param name="index">an integral index
 /// </param>
 /// <returns> the value of a property with index <code>index</code> found in
 /// <code>obj</code> or any object in its prototype chain, or
 /// <code>Scriptable.NOT_FOUND</code> if not found
 /// </returns>
 public static object GetProperty (IScriptable obj, int index)
 {
     IScriptable start = obj;
     object result;
     do {
         result = obj.Get (index, start);
         if (result != UniqueTag.NotFound)
             break;
         obj = obj.GetPrototype ();
     }
     while (obj != null);
     return result;
 }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:29,代码来源:ScriptableObject.cs

示例3: GetPropertyIds

 /// <summary> Returns an array of all ids from an object and its prototypes.
 /// <p>
 /// </summary>
 /// <param name="obj">a JavaScript object
 /// </param>
 /// <returns> an array of all ids from all object in the prototype chain.
 /// If a given id occurs multiple times in the prototype chain,
 /// it will occur only once in this list.
 /// </returns>
 public static object [] GetPropertyIds (IScriptable obj)
 {
     if (obj == null) {
         return ScriptRuntime.EmptyArgs;
     }
     object [] result = obj.GetIds ();
     ObjToIntMap map = null;
     for (; ; ) {
         obj = obj.GetPrototype ();
         if (obj == null) {
             break;
         }
         object [] ids = obj.GetIds ();
         if (ids.Length == 0) {
             continue;
         }
         if (map == null) {
             if (result.Length == 0) {
                 result = ids;
                 continue;
             }
             map = new ObjToIntMap (result.Length + ids.Length);
             for (int i = 0; i != result.Length; ++i) {
                 map.intern (result [i]);
             }
             result = null; // Allow to GC the result
         }
         for (int i = 0; i != ids.Length; ++i) {
             map.intern (ids [i]);
         }
     }
     if (map != null) {
         result = map.getKeys ();
     }
     return result;
 }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:45,代码来源:ScriptableObject.cs

示例4: GetTopScopeValue

 /// <summary> Get arbitrary application-specific value associated with the top scope
 /// of the given scope.
 /// The method first calls {@link #getTopLevelScope(Scriptable scope)}
 /// and then searches the prototype chain of the top scope for the first
 /// object containing the associated value with the given key.
 /// 
 /// </summary>
 /// <param name="scope">the starting scope.
 /// </param>
 /// <param name="key">key object to select particular value.
 /// </param>        
 public static object GetTopScopeValue (IScriptable scope, object key)
 {
     scope = ScriptableObject.GetTopLevelScope (scope);
     for (; ; ) {
         if (scope is ScriptableObject) {
             ScriptableObject so = (ScriptableObject)scope;
             object value = so.GetAssociatedValue (key);
             if (value != null) {
                 return value;
             }
         }
         scope = scope.GetPrototype ();
         if (scope == null) {
             return null;
         }
     }
 }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:28,代码来源:ScriptableObject.cs

示例5: nameOrFunction

        private static object nameOrFunction(Context cx, IScriptable scope, IScriptable parentScope, string name, bool asFunctionCall)
        {
            object result;
            IScriptable thisObj = scope; // It is used only if asFunctionCall==true.

            XMLObject firstXMLObject = null;
            for (; ; ) {
                if (scope is BuiltinWith) {
                    IScriptable withObj = scope.GetPrototype ();
                    if (withObj is XMLObject) {
                        XMLObject xmlObj = (XMLObject)withObj;
                        if (xmlObj.EcmaHas (cx, name)) {
                            // function this should be the target object of with
                            thisObj = xmlObj;
                            result = xmlObj.EcmaGet (cx, name);
                            break;
                        }
                        if (firstXMLObject == null) {
                            firstXMLObject = xmlObj;
                        }
                    }
                    else {
                        result = ScriptableObject.GetProperty (withObj, name);
                        if (result != UniqueTag.NotFound) {
                            // function this should be the target object of with
                            thisObj = withObj;
                            break;
                        }
                    }
                }
                else if (scope is BuiltinCall) {
                    // NativeCall does not prototype chain and Scriptable.get
                    // can be called directly.
                    result = scope.Get (name, scope);
                    if (result != UniqueTag.NotFound) {
                        if (asFunctionCall) {
                            // ECMA 262 requires that this for nested funtions
                            // should be top scope
                            thisObj = ScriptableObject.GetTopLevelScope (parentScope);
                        }
                        break;
                    }
                }
                else {
                    // Can happen if embedding decided that nested
                    // scopes are useful for what ever reasons.
                    result = ScriptableObject.GetProperty (scope, name);
                    if (result != UniqueTag.NotFound) {
                        thisObj = scope;
                        break;
                    }
                }
                scope = parentScope;
                parentScope = parentScope.ParentScope;
                if (parentScope == null) {
                    result = topScopeName (cx, scope, name);
                    if (result == UniqueTag.NotFound) {
                        if (firstXMLObject == null || asFunctionCall) {
                            throw NotFoundError (scope, name);
                        }
                        // The name was not found, but we did find an XML
                        // object in the scope chain and we are looking for name,
                        // not function. The result should be an empty XMLList
                        // in name context.
                        result = firstXMLObject.EcmaGet (cx, name);
                    }
                    // For top scope thisObj for functions is always scope itself.
                    thisObj = scope;
                    break;
                }
            }

            if (asFunctionCall) {
                if (!(result is ICallable)) {
                    throw NotFunctionError (result, name);
                }
                storeScriptable (cx, thisObj);
            }

            return result;
        }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:81,代码来源:ScriptRuntime.cs

示例6: jsDelegatesTo

        /// <summary> Delegates to
        /// 
        /// </summary>
        /// <returns> true iff rhs appears in lhs' proto chain
        /// </returns>
        protected internal static bool jsDelegatesTo(IScriptable lhs, IScriptable rhs)
        {
            IScriptable proto = lhs.GetPrototype ();

            while (proto != null) {
                if (proto.Equals (rhs))
                    return true;
                proto = proto.GetPrototype ();
            }

            return false;
        }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:17,代码来源:ScriptRuntime.cs

示例7: bind

        /// <summary> Returns the object in the scope chain that has a given property.
        /// 
        /// The order of evaluation of an assignment expression involves
        /// evaluating the lhs to a reference, evaluating the rhs, and then
        /// modifying the reference with the rhs value. This method is used
        /// to 'bind' the given name to an object containing that property
        /// so that the side effects of evaluating the rhs do not affect
        /// which property is modified.
        /// Typically used in conjunction with setName.
        /// 
        /// See ECMA 10.1.4
        /// </summary>
        public static IScriptable bind(Context cx, IScriptable scope, string id)
        {
            IScriptable firstXMLObject = null;
            IScriptable parent = scope.ParentScope;
            if (parent != null) {
                // Check for possibly nested "with" scopes first
                while (scope is BuiltinWith) {
                    IScriptable withObj = scope.GetPrototype ();
                    if (withObj is XMLObject) {
                        XMLObject xmlObject = (XMLObject)withObj;
                        if (xmlObject.EcmaHas (cx, id)) {
                            return xmlObject;
                        }
                        if (firstXMLObject == null) {
                            firstXMLObject = xmlObject;
                        }
                    }
                    else {
                        if (ScriptableObject.HasProperty (withObj, id)) {
                            return withObj;
                        }
                    }
                    scope = parent;
                    parent = parent.ParentScope;
                    if (parent == null) {

                        goto childScopesChecks_brk;
                    }
                }
                for (; ; ) {
                    if (ScriptableObject.HasProperty (scope, id)) {
                        return scope;
                    }
                    scope = parent;
                    parent = parent.ParentScope;
                    if (parent == null) {

                        goto childScopesChecks_brk;
                    }
                }
            }

            childScopesChecks_brk:
            ;

            // scope here is top scope
            if (cx.useDynamicScope) {
                scope = checkDynamicScope (cx.topCallScope, scope);
            }
            if (ScriptableObject.HasProperty (scope, id)) {
                return scope;
            }
            // Nothing was found, but since XML objects always bind
            // return one if found
            return firstXMLObject;
        }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:68,代码来源:ScriptRuntime.cs

示例8: nameIncrDecr

        public static object nameIncrDecr(IScriptable scopeChain, string id, int incrDecrMask)
        {
            IScriptable target;
            object value;
            {
                do {
                    target = scopeChain;
                    do {
                        value = target.Get (id, scopeChain);
                        if (value != UniqueTag.NotFound) {

                            goto search_brk;
                        }
                        target = target.GetPrototype ();
                    }
                    while (target != null);
                    scopeChain = scopeChain.ParentScope;
                }
                while (scopeChain != null);
                throw NotFoundError (scopeChain, id);
            }

            search_brk:
            ;

            return doScriptableIncrDecr (target, id, scopeChain, value, incrDecrMask);
        }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:27,代码来源:ScriptRuntime.cs


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