コード例 #1
0
ファイル: TopLevel.cs プロジェクト: hazzik/Rhino.Net
		/// <summary>
		/// Static helper method to get a built-in object prototype with the given
		/// <code>type</code> from the given <code>scope</code>.
		/// </summary>
		/// <remarks>
		/// Static helper method to get a built-in object prototype with the given
		/// <code>type</code> from the given <code>scope</code>. If the scope is not
		/// an instance of this class or does have a cache of built-ins,
		/// the prototype is looked up via normal property lookup.
		/// </remarks>
		/// <param name="scope">the top-level scope</param>
		/// <param name="type">the built-in type</param>
		/// <returns>the built-in prototype</returns>
		public static Scriptable GetBuiltinPrototype(Scriptable scope, TopLevel.Builtins type)
		{
			// must be called with top level scope
			System.Diagnostics.Debug.Assert(scope.GetParentScope() == null);
			if (scope is TopLevel)
			{
				Scriptable result = ((TopLevel)scope).GetBuiltinPrototype(type);
				if (result != null)
				{
					return result;
				}
			}
			// fall back to normal prototype lookup
			return ScriptableObject.GetClassPrototype(scope, type.ToString());
		}
コード例 #2
0
ファイル: TopLevel.cs プロジェクト: hazzik/Rhino.Net
		/// <summary>
		/// Static helper method to get a built-in object constructor with the given
		/// <code>type</code> from the given <code>scope</code>.
		/// </summary>
		/// <remarks>
		/// Static helper method to get a built-in object constructor with the given
		/// <code>type</code> from the given <code>scope</code>. If the scope is not
		/// an instance of this class or does have a cache of built-ins,
		/// the constructor is looked up via normal property lookup.
		/// </remarks>
		/// <param name="cx">the current Context</param>
		/// <param name="scope">the top-level scope</param>
		/// <param name="type">the built-in type</param>
		/// <returns>the built-in constructor</returns>
		public static Function GetBuiltinCtor(Context cx, Scriptable scope, TopLevel.Builtins type)
		{
			// must be called with top level scope
			System.Diagnostics.Debug.Assert(scope.GetParentScope() == null);
			if (scope is TopLevel)
			{
				Function result = ((TopLevel)scope).GetBuiltinCtor(type);
				if (result != null)
				{
					return result;
				}
			}
			// fall back to normal constructor lookup
			return ScriptRuntime.GetExistingCtor(cx, scope, type.ToString());
		}