Fix [[Class]] property of builtin constructors
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai.u-szeged@partner.samsung.com
This commit is contained in:
@@ -538,105 +538,6 @@ ecma_object_get_class_name (ecma_object_t *obj_p) /**< object */
|
||||
return LIT_MAGIC_STRING_ARGUMENTS_UL;
|
||||
}
|
||||
case ECMA_OBJECT_TYPE_FUNCTION:
|
||||
{
|
||||
lit_magic_string_id_t class_name;
|
||||
|
||||
if (ecma_get_object_is_builtin (obj_p))
|
||||
{
|
||||
ecma_property_t *built_in_id_prop_p = ecma_get_internal_property (obj_p,
|
||||
ECMA_INTERNAL_PROPERTY_BUILT_IN_ID);
|
||||
ecma_builtin_id_t builtin_id = (ecma_builtin_id_t) built_in_id_prop_p->u.internal_property.value;
|
||||
|
||||
switch (builtin_id)
|
||||
{
|
||||
case ECMA_BUILTIN_ID_OBJECT:
|
||||
{
|
||||
class_name = LIT_MAGIC_STRING_OBJECT_UL;
|
||||
break;
|
||||
}
|
||||
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ARRAY_BUILTIN
|
||||
case ECMA_BUILTIN_ID_ARRAY:
|
||||
{
|
||||
class_name = LIT_MAGIC_STRING_ARRAY_UL;
|
||||
break;
|
||||
}
|
||||
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ARRAY_BUILTIN */
|
||||
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_STRING_BUILTIN
|
||||
case ECMA_BUILTIN_ID_STRING:
|
||||
{
|
||||
class_name = LIT_MAGIC_STRING_STRING_UL;
|
||||
break;
|
||||
}
|
||||
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_STRING_BUILTIN */
|
||||
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_BOOLEAN_BUILTIN
|
||||
case ECMA_BUILTIN_ID_BOOLEAN:
|
||||
{
|
||||
class_name = LIT_MAGIC_STRING_BOOLEAN_UL;
|
||||
break;
|
||||
}
|
||||
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_BOOLEAN_BUILTIN */
|
||||
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_NUMBER_BUILTIN
|
||||
case ECMA_BUILTIN_ID_NUMBER:
|
||||
{
|
||||
class_name = LIT_MAGIC_STRING_NUMBER_UL;
|
||||
break;
|
||||
}
|
||||
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_NUMBER_BUILTIN */
|
||||
case ECMA_BUILTIN_ID_FUNCTION:
|
||||
{
|
||||
class_name = LIT_MAGIC_STRING_FUNCTION_UL;
|
||||
break;
|
||||
}
|
||||
#ifdef CONFIG_ECMA_COMPACT_PROFILE
|
||||
case ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR:
|
||||
{
|
||||
class_name = LIT_MAGIC_STRING_COMPACT_PROFILE_ERROR_UL;
|
||||
break;
|
||||
}
|
||||
#endif /* CONFIG_ECMA_COMPACT_PROFILE */
|
||||
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ERROR_BUILTINS
|
||||
case ECMA_BUILTIN_ID_ERROR:
|
||||
case ECMA_BUILTIN_ID_EVAL_ERROR:
|
||||
case ECMA_BUILTIN_ID_RANGE_ERROR:
|
||||
case ECMA_BUILTIN_ID_REFERENCE_ERROR:
|
||||
case ECMA_BUILTIN_ID_SYNTAX_ERROR:
|
||||
case ECMA_BUILTIN_ID_TYPE_ERROR:
|
||||
case ECMA_BUILTIN_ID_URI_ERROR:
|
||||
{
|
||||
class_name = LIT_MAGIC_STRING_ERROR_UL;
|
||||
break;
|
||||
}
|
||||
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ERROR_BUILTINS */
|
||||
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_DATE_BUILTIN
|
||||
case ECMA_BUILTIN_ID_DATE:
|
||||
{
|
||||
class_name = LIT_MAGIC_STRING_DATE_UL;
|
||||
break;
|
||||
}
|
||||
#endif /* CONFIG_ECMA_COMPACT_PROFILE_DISABLE_DATE_BUILTIN */
|
||||
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN
|
||||
case ECMA_BUILTIN_ID_REGEXP:
|
||||
{
|
||||
class_name = LIT_MAGIC_STRING_REGEXP_UL;
|
||||
break;
|
||||
}
|
||||
#endif /* CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN */
|
||||
default:
|
||||
{
|
||||
JERRY_ASSERT (builtin_id == ECMA_BUILTIN_ID_TYPE_ERROR_THROWER);
|
||||
|
||||
class_name = LIT_MAGIC_STRING_FUNCTION_UL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
class_name = LIT_MAGIC_STRING_FUNCTION_UL;
|
||||
}
|
||||
|
||||
return class_name;
|
||||
}
|
||||
case ECMA_OBJECT_TYPE_BOUND_FUNCTION:
|
||||
case ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION:
|
||||
case ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION:
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
// Copyright 2015 University of Szeged.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
Function.prototype.toString = Object.prototype.toString;
|
||||
assert(Array.toString() === "[object Function]");
|
||||
assert(Number.toString() === "[object Function]");
|
||||
assert(String.toString() === "[object Function]");
|
||||
assert(Boolean.toString() === "[object Function]");
|
||||
assert(Object.toString() === "[object Function]");
|
||||
assert(Function.toString() === "[object Function]");
|
||||
assert(Date.toString() === "[object Function]");
|
||||
assert(RegExp.toString() === "[object Function]");
|
||||
|
||||
assert(Math.toString() === "[object Math]");
|
||||
assert(JSON.toString() === "[object JSON]");
|
||||
Reference in New Issue
Block a user