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:
@@ -320,6 +320,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
|
||||
case ECMA_INTERNAL_PROPERTY_CODE: /* an integer */
|
||||
case ECMA_INTERNAL_PROPERTY_BUILT_IN_ID: /* an integer */
|
||||
case ECMA_INTERNAL_PROPERTY_BUILT_IN_ROUTINE_ID: /* an integer */
|
||||
case ECMA_INTERNAL_PROPERTY_EXTENSION_ID: /* an integer */
|
||||
case ECMA_INTERNAL_PROPERTY_NON_INSTANTIATED_BUILT_IN_MASK_0_31: /* an integer (bit-mask) */
|
||||
case ECMA_INTERNAL_PROPERTY_NON_INSTANTIATED_BUILT_IN_MASK_32_63: /* an integer (bit-mask) */
|
||||
{
|
||||
|
||||
@@ -223,6 +223,9 @@ typedef enum
|
||||
([[Built-in routine ID]]) */
|
||||
ECMA_INTERNAL_PROPERTY_BUILT_IN_ROUTINE_ID,
|
||||
|
||||
/** Identifier of implementation-defined extension object */
|
||||
ECMA_INTERNAL_PROPERTY_EXTENSION_ID,
|
||||
|
||||
/**
|
||||
* Bit-mask of non-instantiated built-in's properties (bits 0-31)
|
||||
*/
|
||||
@@ -374,6 +377,8 @@ typedef enum
|
||||
of ECMA-262 v5 specification */
|
||||
ECMA_OBJECT_TYPE_ARGUMENTS, /**< Arguments object (10.6) */
|
||||
ECMA_OBJECT_TYPE_ARRAY, /**< Array object (15.4) */
|
||||
ECMA_OBJECT_TYPE_EXTENSION, /**< Extension (implementation-defined) object
|
||||
* See also: ecma_extension_instantiate */
|
||||
// ECMA_OBJECT_TYPE_HOST, /**< Host object */
|
||||
ECMA_OBJECT_TYPE__COUNT /**< number of object types */
|
||||
} ecma_object_type_t;
|
||||
@@ -733,7 +738,7 @@ FIXME (Move to library that should define the type (literal.h /* ? */))
|
||||
typedef uint32_t literal_index_t;
|
||||
|
||||
/**
|
||||
* Identifiers of ECMA magic string constants
|
||||
* Identifiers of ECMA and implementation-defined magic string constants
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
|
||||
@@ -876,17 +876,18 @@ ecma_string_to_number (const ecma_string_t *str_p) /**< ecma-string */
|
||||
*/
|
||||
ssize_t
|
||||
ecma_string_to_zt_string (const ecma_string_t *string_desc_p, /**< ecma-string descriptor */
|
||||
ecma_char_t *buffer_p, /**< destination buffer */
|
||||
ecma_char_t *buffer_p, /**< destination buffer pointer (can be NULL if buffer_size == 0) */
|
||||
ssize_t buffer_size) /**< size of buffer */
|
||||
{
|
||||
JERRY_ASSERT (string_desc_p != NULL);
|
||||
JERRY_ASSERT (string_desc_p->refs > 0);
|
||||
JERRY_ASSERT (buffer_p != NULL);
|
||||
JERRY_ASSERT (buffer_size > 0);
|
||||
JERRY_ASSERT (buffer_p != NULL || buffer_size == 0);
|
||||
JERRY_ASSERT (buffer_size >= 0);
|
||||
|
||||
ssize_t required_buffer_size = ((ecma_string_get_length (string_desc_p) + 1) * ((ssize_t) sizeof (ecma_char_t)));
|
||||
|
||||
if (required_buffer_size > buffer_size)
|
||||
if (required_buffer_size > buffer_size
|
||||
|| buffer_size == 0)
|
||||
{
|
||||
return -required_buffer_size;
|
||||
}
|
||||
|
||||
@@ -787,6 +787,7 @@ ecma_free_internal_property (ecma_property_t *property_p) /**< the property */
|
||||
case ECMA_INTERNAL_PROPERTY_CODE: /* an integer */
|
||||
case ECMA_INTERNAL_PROPERTY_BUILT_IN_ID: /* an integer */
|
||||
case ECMA_INTERNAL_PROPERTY_BUILT_IN_ROUTINE_ID: /* an integer */
|
||||
case ECMA_INTERNAL_PROPERTY_EXTENSION_ID: /* an integer */
|
||||
case ECMA_INTERNAL_PROPERTY_NON_INSTANTIATED_BUILT_IN_MASK_0_31: /* an integer (bit-mask) */
|
||||
case ECMA_INTERNAL_PROPERTY_NON_INSTANTIATED_BUILT_IN_MASK_32_63: /* an integer (bit-mask) */
|
||||
{
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/* 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-gc.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-init-finalize.h"
|
||||
#include "ecma-lcache.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 */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,36 @@
|
||||
/* 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 ECMA_INIT_FINALIZE_H
|
||||
#define ECMA_INIT_FINALIZE_H
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \addtogroup ecmainitfinalize Initialization and finalization of ECMA
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern void ecma_init (void);
|
||||
extern void ecma_finalize (void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ECMA_INIT_FINALIZE_H */
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
/* 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.
|
||||
@@ -16,7 +16,6 @@
|
||||
/*
|
||||
* List of ECMA magic strings
|
||||
*/
|
||||
|
||||
ECMA_MAGIC_STRING_DEF (ECMA_MAGIC_STRING_ARGUMENTS, "arguments")
|
||||
ECMA_MAGIC_STRING_DEF (ECMA_MAGIC_STRING_EVAL, "eval")
|
||||
ECMA_MAGIC_STRING_DEF (ECMA_MAGIC_STRING_PROTOTYPE, "prototype")
|
||||
@@ -208,3 +207,8 @@ ECMA_MAGIC_STRING_DEF (ECMA_MAGIC_STRING_RIGHT_SQUARE_CHAR, "]")
|
||||
ECMA_MAGIC_STRING_DEF (ECMA_MAGIC_STRING_COLON_CHAR, ":")
|
||||
ECMA_MAGIC_STRING_DEF (ECMA_MAGIC_STRING_SPACE_CHAR, " ")
|
||||
ECMA_MAGIC_STRING_DEF (ECMA_MAGIC_STRING__EMPTY, "")
|
||||
|
||||
/*
|
||||
* Implementation-defined magic strings
|
||||
*/
|
||||
ECMA_MAGIC_STRING_DEF (ECMA_MAGIC_STRING_JERRY_UL, "Jerry")
|
||||
|
||||
Reference in New Issue
Block a user