Inheritance: IdScriptableObject
コード例 #1
0
ファイル: ScriptRuntime.cs プロジェクト: hazzik/Rhino.Net
		public static void SetBuiltinProtoAndParent(ScriptableObject @object, Scriptable scope, TopLevel.Builtins type)
		{
			scope = ScriptableObject.GetTopLevelScope(scope);
			@object.SetParentScope(scope);
			@object.SetPrototype(TopLevel.GetBuiltinPrototype(scope, type));
		}
コード例 #2
0
ファイル: ScriptRuntime.cs プロジェクト: hazzik/Rhino.Net
		public static Scriptable NewBuiltinObject(Context cx, Scriptable scope, TopLevel.Builtins type, object[] args)
		{
			scope = ScriptableObject.GetTopLevelScope(scope);
			Function ctor = TopLevel.GetBuiltinCtor(cx, scope, type);
			if (args == null)
			{
				args = ScriptRuntime.emptyArgs;
			}
			return ctor.Construct(cx, scope, args);
		}
コード例 #3
0
ファイル: TopLevel.cs プロジェクト: hazzik/Rhino.Net
		/// <summary>
		/// Get the cached built-in object prototype from this scope with the
		/// given <code>type</code>.
		/// </summary>
		/// <remarks>
		/// Get the cached built-in object prototype from this scope with the
		/// given <code>type</code>. Returns null if
		/// <see cref="CacheBuiltins()">CacheBuiltins()</see>
		/// has not
		/// been called on this object.
		/// </remarks>
		/// <param name="type">the built-in type</param>
		/// <returns>the built-in prototype</returns>
		public virtual Scriptable GetBuiltinPrototype(TopLevel.Builtins type)
		{
			BaseFunction func = GetBuiltinCtor(type);
			object proto = func != null ? func.GetPrototypeProperty() : null;
			return proto is Scriptable ? (Scriptable)proto : null;
		}
コード例 #4
0
ファイル: TopLevel.cs プロジェクト: hazzik/Rhino.Net
		/// <summary>
		/// Get the cached built-in object constructor from this scope with the
		/// given <code>type</code>.
		/// </summary>
		/// <remarks>
		/// Get the cached built-in object constructor from this scope with the
		/// given <code>type</code>. Returns null if
		/// <see cref="CacheBuiltins()">CacheBuiltins()</see>
		/// has not
		/// been called on this object.
		/// </remarks>
		/// <param name="type">the built-in type</param>
		/// <returns>the built-in constructor</returns>
		public virtual BaseFunction GetBuiltinCtor(TopLevel.Builtins type)
		{
			return ctors != null ? ctors.Get(type) : null;
		}
コード例 #5
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());
		}
コード例 #6
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());
		}