Fix the types of builtin prototype objects (#3663)

In ES2015 many builtin prototypes are no longer valid instances of their
respective classes. This change updates affected prototypes to be
regular objects as required.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
This commit is contained in:
Dániel Bátyai
2020-04-06 12:00:58 +02:00
committed by GitHub
parent 73a78bd223
commit 48fa2ec01b
41 changed files with 372 additions and 272 deletions
@@ -46,14 +46,99 @@ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_ARRAY,
array)
#endif /* ENABLED (JERRY_BUILTIN_ARRAY) */
#if ENABLED (JERRY_BUILTIN_STRING)
#if ENABLED (JERRY_ES2015)
# if ENABLED (JERRY_BUILTIN_STRING)
/* The String.prototype object (21.1.3) */
BUILTIN (ECMA_BUILTIN_ID_STRING_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
string_prototype)
# endif /* ENABLED (JERRY_BUILTIN_STRING) */
# if ENABLED (JERRY_BUILTIN_BOOLEAN)
/* The Boolean.prototype object (19.3.3) */
BUILTIN (ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
boolean_prototype)
# endif /* ENABLED (JERRY_BUILTIN_BOOLEAN) */
# if ENABLED (JERRY_BUILTIN_NUMBER)
/* The Number.prototype object (20.1.3) */
BUILTIN (ECMA_BUILTIN_ID_NUMBER_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
number_prototype)
# endif /* ENABLED (JERRY_BUILTIN_NUMBER) */
# if ENABLED (JERRY_BUILTIN_DATE)
/* The Date.prototype object (20.3.4) */
BUILTIN (ECMA_BUILTIN_ID_DATE_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
date_prototype)
# endif /* ENABLED (JERRY_BUILTIN_DATE) */
# if ENABLED (JERRY_BUILTIN_REGEXP)
/* The RegExp.prototype object (21.2.5) */
BUILTIN (ECMA_BUILTIN_ID_REGEXP_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
regexp_prototype)
# endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
#else /* !ENABLED (JERRY_ES2015) */
# if ENABLED (JERRY_BUILTIN_STRING)
/* The String.prototype object (15.5.4) */
BUILTIN (ECMA_BUILTIN_ID_STRING_PROTOTYPE,
ECMA_OBJECT_TYPE_CLASS,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
string_prototype)
# endif /* ENABLED (JERRY_BUILTIN_STRING) */
# if ENABLED (JERRY_BUILTIN_BOOLEAN)
/* The Boolean.prototype object (15.6.4) */
BUILTIN (ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE,
ECMA_OBJECT_TYPE_CLASS,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
boolean_prototype)
# endif /* ENABLED (JERRY_BUILTIN_BOOLEAN) */
# if ENABLED (JERRY_BUILTIN_NUMBER)
/* The Number.prototype object (15.7.4) */
BUILTIN (ECMA_BUILTIN_ID_NUMBER_PROTOTYPE,
ECMA_OBJECT_TYPE_CLASS,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
number_prototype)
# endif /* ENABLED (JERRY_BUILTIN_NUMBER) */
# if ENABLED (JERRY_BUILTIN_DATE)
/* The Date.prototype object (15.9.4) */
BUILTIN (ECMA_BUILTIN_ID_DATE_PROTOTYPE,
ECMA_OBJECT_TYPE_CLASS,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
date_prototype)
# endif /* ENABLED (JERRY_BUILTIN_DATE) */
# if ENABLED (JERRY_BUILTIN_REGEXP)
/* The RegExp.prototype object (15.10.6) */
BUILTIN (ECMA_BUILTIN_ID_REGEXP_PROTOTYPE,
ECMA_OBJECT_TYPE_CLASS,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
regexp_prototype)
# endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
#endif /* !ENABLED (JERRY_ES2015) */
#if ENABLED (JERRY_BUILTIN_STRING)
/* The String object (15.5.1) */
BUILTIN_ROUTINE (ECMA_BUILTIN_ID_STRING,
ECMA_OBJECT_TYPE_FUNCTION,
@@ -63,13 +148,6 @@ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_STRING,
#endif /* ENABLED (JERRY_BUILTIN_STRING) */
#if ENABLED (JERRY_BUILTIN_BOOLEAN)
/* The Boolean.prototype object (15.6.4) */
BUILTIN (ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE,
ECMA_OBJECT_TYPE_CLASS,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
boolean_prototype)
/* The Boolean object (15.6.1) */
BUILTIN_ROUTINE (ECMA_BUILTIN_ID_BOOLEAN,
ECMA_OBJECT_TYPE_FUNCTION,
@@ -79,13 +157,6 @@ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_BOOLEAN,
#endif /* ENABLED (JERRY_BUILTIN_BOOLEAN) */
#if ENABLED (JERRY_BUILTIN_NUMBER)
/* The Number.prototype object (15.7.4) */
BUILTIN (ECMA_BUILTIN_ID_NUMBER_PROTOTYPE,
ECMA_OBJECT_TYPE_CLASS,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
number_prototype)
/* The Number object (15.7.1) */
BUILTIN_ROUTINE (ECMA_BUILTIN_ID_NUMBER,
ECMA_OBJECT_TYPE_FUNCTION,
@@ -137,13 +208,6 @@ BUILTIN (ECMA_BUILTIN_ID_JSON,
#endif /* ENABLED (JERRY_BUILTIN_JSON) */
#if ENABLED (JERRY_BUILTIN_DATE)
/* The Date.prototype object (15.9.4) */
BUILTIN (ECMA_BUILTIN_ID_DATE_PROTOTYPE,
ECMA_OBJECT_TYPE_CLASS,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
date_prototype)
/* The Date object (15.9.3) */
BUILTIN_ROUTINE (ECMA_BUILTIN_ID_DATE,
ECMA_OBJECT_TYPE_FUNCTION,
@@ -153,13 +217,6 @@ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_DATE,
#endif /* ENABLED (JERRY_BUILTIN_DATE) */
#if ENABLED (JERRY_BUILTIN_REGEXP)
/* The RegExp.prototype object (15.10.6) */
BUILTIN (ECMA_BUILTIN_ID_REGEXP_PROTOTYPE,
ECMA_OBJECT_TYPE_CLASS,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
regexp_prototype)
/* The RegExp object (15.10) */
BUILTIN_ROUTINE (ECMA_BUILTIN_ID_REGEXP,
ECMA_OBJECT_TYPE_FUNCTION,