package goja

func ( *Runtime) ( FunctionCall) Value {
	return .toCallable(.Argument(0))(FunctionCall{
		This:      .Argument(1),
		Arguments: .createListFromArrayLike(.Argument(2))})
}

func ( *Runtime) ( Value) func( []Value,  *Object) *Object {
	if  := .toObject().self.assertConstructor();  != nil {
		return 
	}
	panic(.NewTypeError("Value is not a constructor"))
}

func ( *Runtime) ( FunctionCall) Value {
	 := .Argument(0)
	 := .toConstructor()
	var  Value
	if len(.Arguments) > 2 {
		 = .Argument(2)
		.toConstructor()
	} else {
		 = 
	}
	return (.createListFromArrayLike(.Argument(1)), .toObject())
}

func ( *Runtime) ( FunctionCall) Value {
	 := .toObject(.Argument(0))
	 := toPropertyKey(.Argument(1))
	 := .toPropertyDescriptor(.Argument(2))

	return .toBoolean(.defineOwnProperty(, , false))
}

func ( *Runtime) ( FunctionCall) Value {
	 := .toObject(.Argument(0))
	 := toPropertyKey(.Argument(1))

	return .toBoolean(.delete(, false))
}

func ( *Runtime) ( FunctionCall) Value {
	 := .toObject(.Argument(0))
	 := toPropertyKey(.Argument(1))
	var  Value
	if len(.Arguments) > 2 {
		 = .Arguments[2]
	}
	return .get(, )
}

func ( *Runtime) ( FunctionCall) Value {
	 := .toObject(.Argument(0))
	 := toPropertyKey(.Argument(1))
	return .valuePropToDescriptorObject(.getOwnProp())
}

func ( *Runtime) ( FunctionCall) Value {
	 := .toObject(.Argument(0))
	if  := .self.proto();  != nil {
		return 
	}

	return _null
}

func ( *Runtime) ( FunctionCall) Value {
	 := .toObject(.Argument(0))
	 := toPropertyKey(.Argument(1))
	return .toBoolean(.hasProperty())
}

func ( *Runtime) ( FunctionCall) Value {
	 := .toObject(.Argument(0))
	return .toBoolean(.self.isExtensible())
}

func ( *Runtime) ( FunctionCall) Value {
	 := .toObject(.Argument(0))
	return .newArrayValues(.self.keys(true, nil))
}

func ( *Runtime) ( FunctionCall) Value {
	 := .toObject(.Argument(0))
	return .toBoolean(.self.preventExtensions(false))
}

func ( *Runtime) ( FunctionCall) Value {
	 := .toObject(.Argument(0))
	var  Value
	if len(.Arguments) >= 4 {
		 = .Argument(3)
	} else {
		 = 
	}
	return .toBoolean(.set(.Argument(1), .Argument(2), , false))
}

func ( *Runtime) ( FunctionCall) Value {
	 := .toObject(.Argument(0))
	var  *Object
	if  := .Argument(1);  != _null {
		 = .toObject()
	}
	return .toBoolean(.self.setProto(, false))
}

func ( *Runtime) ( *Object) objectImpl {
	 := newBaseObjectObj(, .global.ObjectPrototype, classObject)

	._putProp("apply", .newNativeFunc(.builtin_reflect_apply, "apply", 3), true, false, true)
	._putProp("construct", .newNativeFunc(.builtin_reflect_construct, "construct", 2), true, false, true)
	._putProp("defineProperty", .newNativeFunc(.builtin_reflect_defineProperty, "defineProperty", 3), true, false, true)
	._putProp("deleteProperty", .newNativeFunc(.builtin_reflect_deleteProperty, "deleteProperty", 2), true, false, true)
	._putProp("get", .newNativeFunc(.builtin_reflect_get, "get", 2), true, false, true)
	._putProp("getOwnPropertyDescriptor", .newNativeFunc(.builtin_reflect_getOwnPropertyDescriptor, "getOwnPropertyDescriptor", 2), true, false, true)
	._putProp("getPrototypeOf", .newNativeFunc(.builtin_reflect_getPrototypeOf, "getPrototypeOf", 1), true, false, true)
	._putProp("has", .newNativeFunc(.builtin_reflect_has, "has", 2), true, false, true)
	._putProp("isExtensible", .newNativeFunc(.builtin_reflect_isExtensible, "isExtensible", 1), true, false, true)
	._putProp("ownKeys", .newNativeFunc(.builtin_reflect_ownKeys, "ownKeys", 1), true, false, true)
	._putProp("preventExtensions", .newNativeFunc(.builtin_reflect_preventExtensions, "preventExtensions", 1), true, false, true)
	._putProp("set", .newNativeFunc(.builtin_reflect_set, "set", 3), true, false, true)
	._putProp("setPrototypeOf", .newNativeFunc(.builtin_reflect_setPrototypeOf, "setPrototypeOf", 2), true, false, true)

	._putSym(SymToStringTag, valueProp(asciiString("Reflect"), false, false, true))

	return 
}

func ( *Runtime) () *Object {
	 := .global.Reflect
	if  == nil {
		 = &Object{runtime: }
		.global.Reflect = 
		.self = .createReflect()
	}
	return 
}