Skip to content

Commit 9402e3d

Browse files
committed
Fix [[Class]] property of builtin constructors
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai [email protected]
1 parent 4f108ab commit 9402e3d

File tree

2 files changed

+27
-99
lines changed

2 files changed

+27
-99
lines changed

jerry-core/ecma/operations/ecma-objects.cpp

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -538,105 +538,6 @@ ecma_object_get_class_name (ecma_object_t *obj_p) /**< object */
538538
return LIT_MAGIC_STRING_ARGUMENTS_UL;
539539
}
540540
case ECMA_OBJECT_TYPE_FUNCTION:
541-
{
542-
lit_magic_string_id_t class_name;
543-
544-
if (ecma_get_object_is_builtin (obj_p))
545-
{
546-
ecma_property_t *built_in_id_prop_p = ecma_get_internal_property (obj_p,
547-
ECMA_INTERNAL_PROPERTY_BUILT_IN_ID);
548-
ecma_builtin_id_t builtin_id = (ecma_builtin_id_t) built_in_id_prop_p->u.internal_property.value;
549-
550-
switch (builtin_id)
551-
{
552-
case ECMA_BUILTIN_ID_OBJECT:
553-
{
554-
class_name = LIT_MAGIC_STRING_OBJECT_UL;
555-
break;
556-
}
557-
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ARRAY_BUILTIN
558-
case ECMA_BUILTIN_ID_ARRAY:
559-
{
560-
class_name = LIT_MAGIC_STRING_ARRAY_UL;
561-
break;
562-
}
563-
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ARRAY_BUILTIN */
564-
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_STRING_BUILTIN
565-
case ECMA_BUILTIN_ID_STRING:
566-
{
567-
class_name = LIT_MAGIC_STRING_STRING_UL;
568-
break;
569-
}
570-
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_STRING_BUILTIN */
571-
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_BOOLEAN_BUILTIN
572-
case ECMA_BUILTIN_ID_BOOLEAN:
573-
{
574-
class_name = LIT_MAGIC_STRING_BOOLEAN_UL;
575-
break;
576-
}
577-
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_BOOLEAN_BUILTIN */
578-
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_NUMBER_BUILTIN
579-
case ECMA_BUILTIN_ID_NUMBER:
580-
{
581-
class_name = LIT_MAGIC_STRING_NUMBER_UL;
582-
break;
583-
}
584-
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_NUMBER_BUILTIN */
585-
case ECMA_BUILTIN_ID_FUNCTION:
586-
{
587-
class_name = LIT_MAGIC_STRING_FUNCTION_UL;
588-
break;
589-
}
590-
#ifdef CONFIG_ECMA_COMPACT_PROFILE
591-
case ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR:
592-
{
593-
class_name = LIT_MAGIC_STRING_COMPACT_PROFILE_ERROR_UL;
594-
break;
595-
}
596-
#endif /* CONFIG_ECMA_COMPACT_PROFILE */
597-
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ERROR_BUILTINS
598-
case ECMA_BUILTIN_ID_ERROR:
599-
case ECMA_BUILTIN_ID_EVAL_ERROR:
600-
case ECMA_BUILTIN_ID_RANGE_ERROR:
601-
case ECMA_BUILTIN_ID_REFERENCE_ERROR:
602-
case ECMA_BUILTIN_ID_SYNTAX_ERROR:
603-
case ECMA_BUILTIN_ID_TYPE_ERROR:
604-
case ECMA_BUILTIN_ID_URI_ERROR:
605-
{
606-
class_name = LIT_MAGIC_STRING_ERROR_UL;
607-
break;
608-
}
609-
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ERROR_BUILTINS */
610-
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_DATE_BUILTIN
611-
case ECMA_BUILTIN_ID_DATE:
612-
{
613-
class_name = LIT_MAGIC_STRING_DATE_UL;
614-
break;
615-
}
616-
#endif /* CONFIG_ECMA_COMPACT_PROFILE_DISABLE_DATE_BUILTIN */
617-
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN
618-
case ECMA_BUILTIN_ID_REGEXP:
619-
{
620-
class_name = LIT_MAGIC_STRING_REGEXP_UL;
621-
break;
622-
}
623-
#endif /* CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN */
624-
default:
625-
{
626-
JERRY_ASSERT (builtin_id == ECMA_BUILTIN_ID_TYPE_ERROR_THROWER);
627-
628-
class_name = LIT_MAGIC_STRING_FUNCTION_UL;
629-
break;
630-
}
631-
}
632-
}
633-
else
634-
{
635-
class_name = LIT_MAGIC_STRING_FUNCTION_UL;
636-
}
637-
638-
return class_name;
639-
}
640541
case ECMA_OBJECT_TYPE_BOUND_FUNCTION:
641542
case ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION:
642543
case ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION:
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2015 Samsung Electronics Co., Ltd.
2+
// Copyright 2015 University of Szeged.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
Function.prototype.toString = Object.prototype.toString;
17+
assert(Array.toString() === "[object Function]");
18+
assert(Number.toString() === "[object Function]");
19+
assert(String.toString() === "[object Function]");
20+
assert(Boolean.toString() === "[object Function]");
21+
assert(Object.toString() === "[object Function]");
22+
assert(Function.toString() === "[object Function]");
23+
assert(Date.toString() === "[object Function]");
24+
assert(RegExp.toString() === "[object Function]");
25+
26+
assert(Math.toString() === "[object Math]");
27+
assert(JSON.toString() === "[object JSON]");

0 commit comments

Comments
 (0)