diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.cpp b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.cpp index c52025869..92890efbd 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.cpp +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include "ecma-alloc.h" #include "ecma-builtins.h" #include "ecma-conversion.h" #include "ecma-exceptions.h" diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.inc.h b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.inc.h index 623a4232e..3190572db 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.inc.h +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.inc.h @@ -26,6 +26,18 @@ # define OBJECT_VALUE(name, obj_getter, prop_writable, prop_enumerable, prop_configurable) #endif /* !OBJECT_VALUE */ +#ifndef NUMBER_VALUE +# define NUMBER_VALUE(name, number_value, prop_writable, prop_enumerable, prop_configurable) +#endif /* !NUMBER_VALUE */ + +#ifndef SIMPLE_VALUE +# define SIMPLE_VALUE(name, simple_value, prop_writable, prop_enumerable, prop_configurable) +#endif /* !SIMPLE_VALUE */ + +#ifndef STRING_VALUE +# define STRING_VALUE(name, magic_string_id, prop_writable, prop_enumerable, prop_configurable) +#endif /* !STRING_VALUE */ + #ifndef ROUTINE # define ROUTINE(name, c_function_name, args_number, length_prop_value) #endif /* !ROUTINE */ @@ -40,6 +52,40 @@ OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_PROPERTY_NOT_ENUMERABLE, ECMA_PROPERTY_CONFIGURABLE) +// ECMA-262 v5, 15.10.7.1 +STRING_VALUE (LIT_MAGIC_STRING_SOURCE, + LIT_MAGIC_STRING_EMPTY_NON_CAPTURE_GROUP, + ECMA_PROPERTY_NOT_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_NOT_CONFIGURABLE) + +// ECMA-262 v5, 15.10.7.2 +SIMPLE_VALUE (LIT_MAGIC_STRING_GLOBAL, + ECMA_SIMPLE_VALUE_FALSE, + ECMA_PROPERTY_NOT_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_NOT_CONFIGURABLE) + +// ECMA-262 v5, 15.10.7.3 +SIMPLE_VALUE (LIT_MAGIC_STRING_IGNORECASE_UL, + ECMA_SIMPLE_VALUE_FALSE, + ECMA_PROPERTY_NOT_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_NOT_CONFIGURABLE) +// ECMA-262 v5, 15.10.7.4 +SIMPLE_VALUE (LIT_MAGIC_STRING_MULTILINE, + ECMA_SIMPLE_VALUE_FALSE, + ECMA_PROPERTY_NOT_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_NOT_CONFIGURABLE) + +// ECMA-262 v5, 15.10.7.5 +NUMBER_VALUE (LIT_MAGIC_STRING_LASTINDEX_UL, + 0, + ECMA_PROPERTY_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_NOT_CONFIGURABLE) + ROUTINE (LIT_MAGIC_STRING_EXEC, ecma_builtin_regexp_prototype_exec, 1, 1) ROUTINE (LIT_MAGIC_STRING_TEST, ecma_builtin_regexp_prototype_test, 1, 1) ROUTINE (LIT_MAGIC_STRING_TO_STRING_UL, ecma_builtin_regexp_prototype_to_string, 0, 0) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp.inc.h b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp.inc.h index 0aa366c46..d9329a6e2 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp.inc.h +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp.inc.h @@ -30,14 +30,6 @@ # define NUMBER_VALUE(name, number_value, prop_writable, prop_enumerable, prop_configurable) #endif /* !NUMBER_VALUE */ -#ifndef SIMPLE_VALUE -# define SIMPLE_VALUE(name, simple_value, prop_writable, prop_enumerable, prop_configurable) -#endif /* !SIMPLE_VALUE */ - -#ifndef STRING_VALUE -# define STRING_VALUE(name, magic_string_id, prop_writable, prop_enumerable, prop_configurable) -#endif /* !STRING_VALUE */ - /* Object identifier */ OBJECT_ID (ECMA_BUILTIN_ID_REGEXP) @@ -48,40 +40,6 @@ OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_PROPERTY_NOT_ENUMERABLE, ECMA_PROPERTY_NOT_CONFIGURABLE) -// ECMA-262 v5, 15.10.7.1 -STRING_VALUE (LIT_MAGIC_STRING_SOURCE, - LIT_MAGIC_STRING_REGEXP_SOURCE_UL, - ECMA_PROPERTY_NOT_WRITABLE, - ECMA_PROPERTY_NOT_ENUMERABLE, - ECMA_PROPERTY_NOT_CONFIGURABLE) - -// ECMA-262 v5, 15.10.7.2 -SIMPLE_VALUE (LIT_MAGIC_STRING_GLOBAL, - ECMA_SIMPLE_VALUE_FALSE, - ECMA_PROPERTY_NOT_WRITABLE, - ECMA_PROPERTY_NOT_ENUMERABLE, - ECMA_PROPERTY_NOT_CONFIGURABLE) - -// ECMA-262 v5, 15.10.7.3 -SIMPLE_VALUE (LIT_MAGIC_STRING_IGNORECASE_UL, - ECMA_SIMPLE_VALUE_FALSE, - ECMA_PROPERTY_NOT_WRITABLE, - ECMA_PROPERTY_NOT_ENUMERABLE, - ECMA_PROPERTY_NOT_CONFIGURABLE) -// ECMA-262 v5, 15.10.7.4 -SIMPLE_VALUE (LIT_MAGIC_STRING_MULTILINE, - ECMA_SIMPLE_VALUE_FALSE, - ECMA_PROPERTY_NOT_WRITABLE, - ECMA_PROPERTY_NOT_ENUMERABLE, - ECMA_PROPERTY_NOT_CONFIGURABLE) - -// ECMA-262 v5, 15.10.7.5 -NUMBER_VALUE (LIT_MAGIC_STRING_LASTINDEX_UL, - 0, - ECMA_PROPERTY_NOT_WRITABLE, - ECMA_PROPERTY_NOT_ENUMERABLE, - ECMA_PROPERTY_NOT_CONFIGURABLE) - // ECMA-262 v5, 15.10.5 NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 2, diff --git a/tests/jerry/regexp-construct.js b/tests/jerry/regexp-construct.js index 5af9f68bc..c16128672 100644 --- a/tests/jerry/regexp-construct.js +++ b/tests/jerry/regexp-construct.js @@ -136,3 +136,28 @@ assert (r.source == "(?:)"); assert (r.global == false); assert (r.ignoreCase == false); assert (r.multiline == false); + +/* RegExp properties */ +assert (RegExp.length === 2); +assert (RegExp.prototype.source === "(?:)"); +assert (RegExp.prototype.global === false); +assert (RegExp.prototype.ignoreCase === false); +assert (RegExp.prototype.multiline === false); + +RegExp.prototype.source = "a"; +RegExp.prototype.global = true; +RegExp.prototype.ignoreCase = true; +RegExp.prototype.multiline = true; +assert (RegExp.prototype.source === "(?:)"); +assert (RegExp.prototype.global === false); +assert (RegExp.prototype.ignoreCase === false); +assert (RegExp.prototype.multiline === false); + +delete RegExp.prototype.source; +delete RegExp.prototype.global; +delete RegExp.prototype.ignoreCase; +delete RegExp.prototype.multiline; +assert (RegExp.prototype.source === "(?:)"); +assert (RegExp.prototype.global === false); +assert (RegExp.prototype.ignoreCase === false); +assert (RegExp.prototype.multiline === false);