Extension description syntax; extension instantiation, field values and calls with arguments (except strings); example of a simple extension.

String arguments support is supposed to be added in a subsequent commit.
This commit is contained in:
Ruben Ayrapetyan
2015-02-24 16:38:49 +03:00
parent 3d9635300b
commit 79695bf3cd
32 changed files with 1031 additions and 111 deletions
@@ -25,7 +25,6 @@
#include "ecma-objects.h"
#include "ecma-function-object.h"
#include "ecma-objects-general.h"
#include "ecma-operations.h"
#include "ecma-try-catch-macro.h"
/** \addtogroup ecma ECMA
@@ -1,62 +0,0 @@
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* 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.
*/
#include "ecma-builtins.h"
#include "ecma-helpers.h"
#include "ecma-gc.h"
#include "ecma-lcache.h"
#include "ecma-operations.h"
#include "ecma-stack.h"
#include "mem-allocator.h"
/** \addtogroup ecma ECMA
* @{
*
* \addtogroup ecmainitfinalize Initialization and finalization of ECMA components
* @{
*/
/**
* Initialize ECMA components
*/
void
ecma_init (void)
{
ecma_strings_init ();
ecma_init_builtins ();
ecma_lcache_init ();
ecma_stack_init ();
mem_register_a_try_give_memory_back_callback (ecma_try_to_give_back_some_memory);
} /* ecma_init */
/**
* Finalize ECMA components
*/
void
ecma_finalize (void)
{
mem_unregister_a_try_give_memory_back_callback (ecma_try_to_give_back_some_memory);
ecma_stack_finalize ();
ecma_finalize_builtins ();
ecma_lcache_invalidate_all ();
ecma_gc_run ();
} /* ecma_finalize */
/**
* @}
* @}
*/
+18 -1
View File
@@ -16,6 +16,7 @@
#include "ecma-array-object.h"
#include "ecma-builtins.h"
#include "ecma-exceptions.h"
#include "ecma-extension.h"
#include "ecma-globals.h"
#include "ecma-function-object.h"
#include "ecma-lcache.h"
@@ -58,6 +59,7 @@ ecma_op_object_get (ecma_object_t *obj_p, /**< the object */
case ECMA_OBJECT_TYPE_FUNCTION:
case ECMA_OBJECT_TYPE_BOUND_FUNCTION:
case ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION:
case ECMA_OBJECT_TYPE_EXTENSION:
case ECMA_OBJECT_TYPE_STRING:
{
return ecma_op_general_object_get (obj_p, property_name_p);
@@ -121,6 +123,13 @@ ecma_op_object_get_own_property_longpath (ecma_object_t *obj_p, /**< the object
break;
}
case ECMA_OBJECT_TYPE_EXTENSION:
{
prop_p = ecma_op_extension_object_get_own_property (obj_p, property_name_p);
break;
}
default:
{
JERRY_ASSERT (false);
@@ -132,7 +141,8 @@ ecma_op_object_get_own_property_longpath (ecma_object_t *obj_p, /**< the object
if (unlikely (prop_p == NULL))
{
if (is_builtin
&& type != ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION)
&& type != ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION
&& type != ECMA_OBJECT_TYPE_EXTENSION)
{
prop_p = ecma_builtin_try_to_instantiate_property (obj_p, property_name_p);
}
@@ -199,6 +209,7 @@ ecma_op_object_get_property (ecma_object_t *obj_p, /**< the object */
* [ECMA_OBJECT_TYPE_FUNCTION] = &ecma_op_general_object_get_property,
* [ECMA_OBJECT_TYPE_BOUND_FUNCTION] = &ecma_op_general_object_get_property,
* [ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION] = &ecma_op_general_object_get_property,
* [ECMA_OBJECT_TYPE_EXTENSION] = &ecma_op_general_object_get_property,
* [ECMA_OBJECT_TYPE_ARGUMENTS] = &ecma_op_general_object_get_property,
* [ECMA_OBJECT_TYPE_STRING] = &ecma_op_general_object_get_property
* };
@@ -240,6 +251,7 @@ ecma_op_object_put (ecma_object_t *obj_p, /**< the object */
* [ECMA_OBJECT_TYPE_FUNCTION] = &ecma_op_general_object_put,
* [ECMA_OBJECT_TYPE_BOUND_FUNCTION] = &ecma_op_general_object_put,
* [ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION] = &ecma_op_general_object_put,
* [ECMA_OBJECT_TYPE_EXTENSION] = &ecma_op_general_object_put,
* [ECMA_OBJECT_TYPE_ARGUMENTS] = &ecma_op_general_object_put,
* [ECMA_OBJECT_TYPE_STRING] = &ecma_op_general_object_put
* };
@@ -279,6 +291,7 @@ ecma_op_object_can_put (ecma_object_t *obj_p, /**< the object */
* [ECMA_OBJECT_TYPE_FUNCTION] = &ecma_op_general_object_can_put,
* [ECMA_OBJECT_TYPE_BOUND_FUNCTION] = &ecma_op_general_object_can_put,
* [ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION] = &ecma_op_general_object_can_put,
* [ECMA_OBJECT_TYPE_EXTENSION] = &ecma_op_general_object_can_put,
* [ECMA_OBJECT_TYPE_ARGUMENTS] = &ecma_op_general_object_can_put,
* [ECMA_OBJECT_TYPE_STRING] = &ecma_op_general_object_can_put
* };
@@ -317,6 +330,7 @@ ecma_op_object_delete (ecma_object_t *obj_p, /**< the object */
case ECMA_OBJECT_TYPE_FUNCTION:
case ECMA_OBJECT_TYPE_BOUND_FUNCTION:
case ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION:
case ECMA_OBJECT_TYPE_EXTENSION:
case ECMA_OBJECT_TYPE_STRING:
{
return ecma_op_general_object_delete (obj_p,
@@ -368,6 +382,7 @@ ecma_op_object_default_value (ecma_object_t *obj_p, /**< the object */
* [ECMA_OBJECT_TYPE_FUNCTION] = &ecma_op_general_object_default_value,
* [ECMA_OBJECT_TYPE_BOUND_FUNCTION] = &ecma_op_general_object_default_value,
* [ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION] = &ecma_op_general_object_default_value,
* [ECMA_OBJECT_TYPE_EXTENSION] = &ecma_op_general_object_default_value,
* [ECMA_OBJECT_TYPE_ARGUMENTS] = &ecma_op_general_object_default_value,
* [ECMA_OBJECT_TYPE_STRING] = &ecma_op_general_object_default_value
* };
@@ -407,6 +422,7 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
case ECMA_OBJECT_TYPE_FUNCTION:
case ECMA_OBJECT_TYPE_BOUND_FUNCTION:
case ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION:
case ECMA_OBJECT_TYPE_EXTENSION:
case ECMA_OBJECT_TYPE_STRING:
{
return ecma_op_general_object_define_own_property (obj_p,
@@ -461,6 +477,7 @@ ecma_op_object_has_instance (ecma_object_t *obj_p, /**< the object */
case ECMA_OBJECT_TYPE_GENERAL:
case ECMA_OBJECT_TYPE_STRING:
case ECMA_OBJECT_TYPE_ARGUMENTS:
case ECMA_OBJECT_TYPE_EXTENSION:
{
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
}
@@ -1,38 +0,0 @@
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* 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.
*/
#ifndef JERRY_ECMA_OPERATIONS_H
#define JERRY_ECMA_OPERATIONS_H
#include "jrt.h"
/** \addtogroup ecma ECMA
* @{
*/
/**
* \addtogroup ecmainitfinalize Initialization and finalization of ECMA components
* @{
*/
extern void ecma_init (void);
extern void ecma_finalize (void);
/**
* @}
* @}
*/
#endif /* JERRY_ECMA_OPERATIONS_H */
@@ -119,7 +119,7 @@ ecma_op_create_string_object (const ecma_value_t *arguments_list_p, /**< list of
* Returned value must be freed with ecma_free_completion_value
*/
ecma_property_t*
ecma_op_string_object_get_own_property (ecma_object_t *obj_p, /**< the array object */
ecma_op_string_object_get_own_property (ecma_object_t *obj_p, /**< the string object */
ecma_string_t *property_name_p) /**< property name */
{
JERRY_ASSERT (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_STRING);