const njs_object_init_t njs_array_constructor_init = {
- njs_array_constructor_properties,
- nxt_nitems(njs_array_constructor_properties),
+ njs_array_constructor_properties,
+ nxt_nitems(njs_array_constructor_properties),
};
const njs_object_init_t njs_array_prototype_init = {
- njs_array_prototype_properties,
- nxt_nitems(njs_array_prototype_properties),
+ njs_array_prototype_properties,
+ nxt_nitems(njs_array_prototype_properties),
};
const njs_object_init_t njs_boolean_constructor_init = {
- njs_boolean_constructor_properties,
- nxt_nitems(njs_boolean_constructor_properties),
+ njs_boolean_constructor_properties,
+ nxt_nitems(njs_boolean_constructor_properties),
};
const njs_object_init_t njs_boolean_prototype_init = {
- njs_boolean_prototype_properties,
- nxt_nitems(njs_boolean_prototype_properties),
+ njs_boolean_prototype_properties,
+ nxt_nitems(njs_boolean_prototype_properties),
};
njs_value_t *values;
njs_object_t *function_prototype;
+ /*
+ * Copy both prototypes and functions arrays by one memcpy()
+ * because they are stored together.
+ */
size = NJS_PROTOTYPE_MAX * sizeof(njs_object_t)
+ NJS_FUNCTION_MAX * sizeof(njs_function_t);
nxt_int_t
-njs_add_external(nxt_lvlhsh_t *hash, nxt_mem_cache_pool_t *mcp, uintptr_t object,
- njs_external_t *external, nxt_uint_t n)
+njs_add_external(nxt_lvlhsh_t *hash, nxt_mem_cache_pool_t *mcp,
+ uintptr_t object, njs_external_t *external, nxt_uint_t n)
{
nxt_int_t ret;
njs_extern_t *ext;
const njs_object_init_t njs_function_constructor_init = {
- njs_function_constructor_properties,
- nxt_nitems(njs_function_constructor_properties),
+ njs_function_constructor_properties,
+ nxt_nitems(njs_function_constructor_properties),
};
const njs_object_init_t njs_function_prototype_init = {
- njs_function_prototype_properties,
- nxt_nitems(njs_function_prototype_properties),
+ njs_function_prototype_properties,
+ nxt_nitems(njs_function_prototype_properties),
};
const njs_object_init_t njs_eval_function_init = {
- njs_eval_function_properties,
- nxt_nitems(njs_eval_function_properties),
+ njs_eval_function_properties,
+ nxt_nitems(njs_eval_function_properties),
};
/*
* The return_address is required in njs_frame_t only, however, it
- * can be stored here just after function adddress has been fetched.
+ * can be stored here just after function address has been fetched.
*/
union {
njs_function_t *function;
nxt_inline nxt_bool_t njs_generator_is_constant(njs_parser_node_t *node);
-static const nxt_str_t no_label = { 0, NULL };
+static const nxt_str_t no_label = { 0, NULL };
static nxt_int_t
const njs_object_init_t njs_number_constructor_init = {
- njs_number_constructor_properties,
- nxt_nitems(njs_number_constructor_properties),
+ njs_number_constructor_properties,
+ nxt_nitems(njs_number_constructor_properties),
};
const njs_object_init_t njs_number_prototype_init = {
- njs_number_prototype_properties,
- nxt_nitems(njs_number_prototype_properties),
+ njs_number_prototype_properties,
+ nxt_nitems(njs_number_prototype_properties),
};
const njs_object_init_t njs_object_constructor_init = {
- njs_object_constructor_properties,
- nxt_nitems(njs_object_constructor_properties),
+ njs_object_constructor_properties,
+ nxt_nitems(njs_object_constructor_properties),
};
const njs_object_init_t njs_object_prototype_init = {
- njs_object_prototype_properties,
- nxt_nitems(njs_object_prototype_properties),
+ njs_object_prototype_properties,
+ nxt_nitems(njs_object_prototype_properties),
};
const njs_object_init_t njs_regexp_constructor_init = {
- njs_regexp_constructor_properties,
- nxt_nitems(njs_regexp_constructor_properties),
+ njs_regexp_constructor_properties,
+ nxt_nitems(njs_regexp_constructor_properties),
};
const njs_object_init_t njs_regexp_prototype_init = {
- njs_regexp_prototype_properties,
- nxt_nitems(njs_regexp_prototype_properties),
+ njs_regexp_prototype_properties,
+ nxt_nitems(njs_regexp_prototype_properties),
};
const njs_object_init_t njs_string_constructor_init = {
- njs_string_constructor_properties,
- nxt_nitems(njs_string_constructor_properties),
+ njs_string_constructor_properties,
+ nxt_nitems(njs_string_constructor_properties),
};
},
/* ECMAScript 6, codePointAt(). */
-
{
.type = NJS_METHOD,
.name = njs_string("codePointAt"),
const njs_object_init_t njs_string_prototype_init = {
- njs_string_prototype_properties,
- nxt_nitems(njs_string_prototype_properties),
+ njs_string_prototype_properties,
+ nxt_nitems(njs_string_prototype_properties),
};
dst->data = NULL;
return NXT_ERROR;
-
}
nxt_lvlhsh_t variables_hash;
nxt_lvlhsh_t values_hash;
+ /*
+ * The prototypes and functions arrays must be togther because
+ * they are copied from njs_vm_shared_t by single memcpy()
+ * in njs_builtin_objects_clone().
+ */
njs_object_t prototypes[NJS_PROTOTYPE_MAX];
njs_function_t functions[NJS_FUNCTION_MAX];
nxt_lvlhsh_t values_hash;
nxt_lvlhsh_t null_proto_hash;
+ /*
+ * The prototypes and functions arrays must be togther because they are
+ * copied to njs_vm_t by single memcpy() in njs_builtin_objects_clone().
+ */
njs_object_t prototypes[NJS_PROTOTYPE_MAX];
njs_function_t functions[NJS_FUNCTION_MAX];
};
{ nxt_string("a = []; a[5] = 5; a.join()"),
nxt_string(",,,,,5") },
- { nxt_string("a = []; a[5] = 5; a +''"),
+ { nxt_string("a = []; a[5] = 5; a"),
nxt_string(",,,,,5") },
- { nxt_string("a = []; a.concat([]) +''"),
+ { nxt_string("a = []; a.concat([])"),
nxt_string("") },
/* Array.toString(). */
/**/
- { nxt_string("a = [1,2,3]; a.concat(4, [5, 6, 7], 8) +''"),
+ { nxt_string("a = [1,2,3]; a.concat(4, [5, 6, 7], 8)"),
nxt_string("1,2,3,4,5,6,7,8") },
{ nxt_string("a = []; a[100] = a.length; a[100] +' '+ a.length"),
nxt_string("6") },
{ nxt_string("var a = [1,2,3];"
- "a.forEach(function(v, i, a) { a[i+3] = a.length });"
- "a +''"),
+ "a.forEach(function(v, i, a) { a[i+3] = a.length }); a"),
nxt_string("1,2,3,3,4,5") },
{ nxt_string("var a = [];"
"a"),
nxt_string("01:01|АБВ,02:02|АБВ,03:03|АБВ,") },
- { nxt_string("$r.external('YES')"),
+ { nxt_string("$r.some_method('YES')"),
nxt_string("АБВ") },
- { nxt_string("for (p in $r.external);"),
+ { nxt_string("for (p in $r.some_method);"),
nxt_string("undefined") },
{ nxt_string("'uri' in $r"),
nxt_string("false") },
#if 0
- { nxt_string("$r.external.call($r, 'YES')"),
+ { nxt_string("$r.some_method.call($r, 'YES')"),
nxt_string("АБВ") },
- { nxt_string("$r.external.apply($r, ['YES'])"),
+ { nxt_string("$r.some_method.apply($r, ['YES'])"),
nxt_string("АБВ") },
#endif
{ nxt_string("'abcdefgh'.search('def')"),
nxt_string("3") },
- { nxt_string("''.match(/^$/) +''"),
+ { nxt_string("''.match(/^$/)"),
nxt_string("") },
- { nxt_string("''.match(/^$/g) +''"),
+ { nxt_string("''.match(/^$/g)"),
nxt_string("") },
- { nxt_string("'abcdefgh'.match(/def/) +''"),
+ { nxt_string("'abcdefgh'.match(/def/)"),
nxt_string("def") },
- { nxt_string("'abc ABC aBc'.match(/abc/ig) +''"),
+ { nxt_string("'abc ABC aBc'.match(/abc/ig)"),
nxt_string("abc,ABC,aBc") },
/* Functions. */
{ nxt_string("a = (0, function(a) { return a + 1 }(2)); a"),
nxt_string("3") },
+ { nxt_string("var a = 0, function(a) { return a + 1 }(2); a"),
+ nxt_string("SyntaxError") },
+
+ { nxt_string("var a = (0, function(a) { return a + 1 }(2)); a"),
+ nxt_string("3") },
+
{ nxt_string("var a = +function f(a) { return a + 1 }(2)"
"var b = f(5); a"),
nxt_string("ReferenceError") },
{ nxt_string("var o = new Object(); o"),
nxt_string("[object Object]") },
- { nxt_string("var o = new Object(1); o +''"),
+ { nxt_string("var o = new Object(1); o"),
nxt_string("1") },
{ nxt_string("var o = {}; o === Object(o)"),
{ nxt_string("({}).constructor === Object"),
nxt_string("true") },
- { nxt_string("var a = Array(3); a +''"),
+ { nxt_string("var a = Array(3); a"),
nxt_string(",,") },
{ nxt_string("var a = Array(); a.length"),
{ nxt_string("var a = Array(0); a.length"),
nxt_string("0") },
- { nxt_string("var a = Array(true); a +''"),
+ { nxt_string("var a = Array(true); a"),
nxt_string("true") },
- { nxt_string("var a = Array(1,'two',3); a +''"),
+ { nxt_string("var a = Array(1,'two',3); a"),
nxt_string("1,two,3") },
{ nxt_string("var a = Array(-1)"),
{ nxt_string("var a = Array(Infinity)"),
nxt_string("RangeError") },
- { nxt_string("var a = new Array(3); a +''"),
+ { nxt_string("var a = new Array(3); a"),
nxt_string(",,") },
{ nxt_string("Array.name"),
{ nxt_string("Array.constructor === Function"),
nxt_string("true") },
- { nxt_string("var a = []; a.join = 'OK'; a +''"),
+ { nxt_string("var a = []; a.join = 'OK'; a"),
nxt_string("[object Array]") },
{ nxt_string("[].__proto__ === Array.prototype"),
{ nxt_string("RegExp.constructor === Function"),
nxt_string("true") },
- { nxt_string("var a = 0, function(a) { return a + 1 }(2); a"),
- nxt_string("SyntaxError") },
-
- { nxt_string("var a = (0, function(a) { return a + 1 }(2)); a"),
- nxt_string("3") },
-
#if 0
{ nxt_string("Object.prototype.toString.call()"),
nxt_string("[object Undefined]") },
NULL,
0 },
- { nxt_string("external"),
+ { nxt_string("some_method"),
NJS_EXTERN_METHOD,
NULL,
0,