Browse Source

Fixing some Prototype values

Sebastien Ros 12 years ago
parent
commit
461857c4db

+ 1 - 1
Jint/Native/Function/FunctionConstructor.cs

@@ -92,7 +92,7 @@ namespace Jint.Native.Function
                             {
                             {
                                 Type = SyntaxNodes.Identifier,
                                 Type = SyntaxNodes.Identifier,
                                 Name = x
                                 Name = x
-                            }),
+                            }).ToArray(),
                         FunctionDeclarations = new List<FunctionDeclaration>(),
                         FunctionDeclarations = new List<FunctionDeclaration>(),
                         VariableDeclarations = new List<VariableDeclaration>()
                         VariableDeclarations = new List<VariableDeclaration>()
                     },  
                     },  

+ 4 - 1
Jint/Native/Global/GlobalObject.cs

@@ -18,11 +18,14 @@ namespace Jint.Native.Global
             global.Prototype = null;
             global.Prototype = null;
             global.Extensible = true;
             global.Extensible = true;
             
             
-                        return global;
+            return global;
         }
         }
 
 
         public void Configure()
         public void Configure()
         {
         {
+            // this is implementation dependent, and only to pass some unit tests
+            Prototype = Engine.Object.PrototypeObject;
+
             // Global object properties
             // Global object properties
             FastAddProperty("Object", Engine.Object, true, false, true);
             FastAddProperty("Object", Engine.Object, true, false, true);
             FastAddProperty("Function", Engine.Function, true, false, true);
             FastAddProperty("Function", Engine.Function, true, false, true);

+ 2 - 0
Jint/Native/Json/JsonInstance.cs

@@ -25,11 +25,13 @@ namespace Jint.Native.Json
         public static JsonInstance CreateJsonObject(Engine engine)
         public static JsonInstance CreateJsonObject(Engine engine)
         {
         {
             var json = new JsonInstance(engine);
             var json = new JsonInstance(engine);
+            json.Prototype = engine.Object.PrototypeObject;
             return json;
             return json;
         }
         }
 
 
         public void Configure()
         public void Configure()
         {
         {
+
             FastAddProperty("parse", new ClrFunctionInstance<JsonInstance, object>(Engine, Parse), true, false, true);
             FastAddProperty("parse", new ClrFunctionInstance<JsonInstance, object>(Engine, Parse), true, false, true);
             FastAddProperty("stringify", new ClrFunctionInstance<JsonInstance, object>(Engine, Stringify), true, false, true);
             FastAddProperty("stringify", new ClrFunctionInstance<JsonInstance, object>(Engine, Stringify), true, false, true);
         }
         }

+ 1 - 1
Jint/Native/Math/MathInstance.cs

@@ -23,7 +23,7 @@ namespace Jint.Native.Math
         {
         {
             var math = new MathInstance(engine);
             var math = new MathInstance(engine);
             math.Extensible = true;
             math.Extensible = true;
-            math.Prototype = engine.Object.Prototype;
+            math.Prototype = engine.Object.PrototypeObject;
 
 
             
             
             return math;
             return math;

+ 4 - 3
Jint/Native/Object/ObjectConstructor.cs

@@ -34,7 +34,7 @@ namespace Jint.Native.Object
         {
         {
             Prototype = Engine.Function.PrototypeObject;
             Prototype = Engine.Function.PrototypeObject;
 
 
-            FastAddProperty("getPrototypeOf", new ClrFunctionInstance<object, object>(Engine, GetPrototypeOf), false, false, false);
+            FastAddProperty("getPrototypeOf", new ClrFunctionInstance<object, object>(Engine, GetPrototypeOf, 1), false, false, false);
             FastAddProperty("getOwnPropertyDescriptor", new ClrFunctionInstance<object, object>(Engine, GetOwnPropertyDescriptor), false, false, false);
             FastAddProperty("getOwnPropertyDescriptor", new ClrFunctionInstance<object, object>(Engine, GetOwnPropertyDescriptor), false, false, false);
             FastAddProperty("getOwnPropertyNames", new ClrFunctionInstance<object, object>(Engine, GetOwnPropertyNames), false, false, false);
             FastAddProperty("getOwnPropertyNames", new ClrFunctionInstance<object, object>(Engine, GetOwnPropertyNames), false, false, false);
             FastAddProperty("create", new ClrFunctionInstance<object, object>(Engine, Create), false, false, false);
             FastAddProperty("create", new ClrFunctionInstance<object, object>(Engine, Create), false, false, false);
@@ -105,12 +105,13 @@ namespace Jint.Native.Object
 
 
         public object GetPrototypeOf(object thisObject, object[] arguments)
         public object GetPrototypeOf(object thisObject, object[] arguments)
         {
         {
-            if (TypeConverter.GetType(thisObject) != TypeCode.Object)
+            var oArg = arguments.Length > 0 ? arguments[0] : Undefined.Instance;
+            if (TypeConverter.GetType(oArg) != TypeCode.Object)
             {
             {
                 throw new JavaScriptException(Engine.TypeError);
                 throw new JavaScriptException(Engine.TypeError);
             }
             }
 
 
-            var o = thisObject as ObjectInstance;
+            var o = oArg as ObjectInstance;
 
 
             return o.Prototype ?? Null.Instance;
             return o.Prototype ?? Null.Instance;
         }
         }