Introducing ecma_is_string_magic, ecma_init and ecma_finalize interfaces, 'magic-string' container type for ecma-strings. Renaming ecma_is_magic_string to ecma_is_zt_string_magic. Moving magic-string related routines to ecma-helpers-string.c.
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-magic-strings.h"
|
||||
#include "ecma-number-arithmetic.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-objects-general.h"
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-magic-strings.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "jerry-libc.h"
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lex-env.h"
|
||||
#include "ecma-magic-strings.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-objects-general.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/* Copyright 2014 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-operations.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_init */
|
||||
|
||||
/**
|
||||
* Finalize ECMA components
|
||||
*/
|
||||
void
|
||||
ecma_finalize (void)
|
||||
{
|
||||
ecma_finalize_builtins ();
|
||||
} /* ecma_finalize */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
@@ -28,6 +28,11 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* ECMA-262 v5, 8.7.1 and 8.7.2 */
|
||||
extern ecma_completion_value_t ecma_op_get_value (ecma_reference_t ref);
|
||||
extern ecma_completion_value_t ecma_op_put_value (ecma_reference_t ref,
|
||||
ecma_value_t value);
|
||||
|
||||
/* ECMA-262 v5, Table 17. Abstract methods of Environment Records */
|
||||
extern ecma_completion_value_t ecma_op_has_binding (ecma_object_t *lex_env_p,
|
||||
ecma_string_t *name_p);
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
/* Copyright 2014 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-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-magic-strings.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmamagicstrings Collection of magic string constants used in ECMA
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get specified magic string as zero-terminated string
|
||||
*
|
||||
* @return pointer to zero-terminated magic string
|
||||
*/
|
||||
const ecma_char_t*
|
||||
ecma_get_magic_string_zt (ecma_magic_string_id_t id) /**< magic string id */
|
||||
{
|
||||
TODO(Support UTF-16);
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case ECMA_MAGIC_STRING_ARGUMENTS: return (ecma_char_t*) "arguments";
|
||||
case ECMA_MAGIC_STRING_EVAL: return (ecma_char_t*) "eval";
|
||||
case ECMA_MAGIC_STRING_PROTOTYPE: return (ecma_char_t*) "prototype";
|
||||
case ECMA_MAGIC_STRING_CONSTRUCTOR: return (ecma_char_t*) "constructor";
|
||||
case ECMA_MAGIC_STRING_CALLER: return (ecma_char_t*) "caller";
|
||||
case ECMA_MAGIC_STRING_CALLEE: return (ecma_char_t*) "callee";
|
||||
case ECMA_MAGIC_STRING_UNDEFINED: return (ecma_char_t*) "undefined";
|
||||
case ECMA_MAGIC_STRING_NULL: return (ecma_char_t*) "null";
|
||||
case ECMA_MAGIC_STRING_FALSE: return (ecma_char_t*) "false";
|
||||
case ECMA_MAGIC_STRING_TRUE: return (ecma_char_t*) "true";
|
||||
case ECMA_MAGIC_STRING_NUMBER: return (ecma_char_t*) "number";
|
||||
case ECMA_MAGIC_STRING_STRING: return (ecma_char_t*) "string";
|
||||
case ECMA_MAGIC_STRING_OBJECT: return (ecma_char_t*) "object";
|
||||
case ECMA_MAGIC_STRING_FUNCTION: return (ecma_char_t*) "function";
|
||||
case ECMA_MAGIC_STRING_LENGTH: return (ecma_char_t*) "length";
|
||||
case ECMA_MAGIC_STRING_NAN: return (ecma_char_t*) "NaN";
|
||||
case ECMA_MAGIC_STRING_INFINITY: return (ecma_char_t*) "Infinity";
|
||||
case ECMA_MAGIC_STRING__COUNT: break;
|
||||
}
|
||||
|
||||
JERRY_UNREACHABLE();
|
||||
} /* ecma_get_magic_string_zt */
|
||||
|
||||
/**
|
||||
* Get specified magic string
|
||||
*
|
||||
* @return ecma-string containing specified magic string
|
||||
*/
|
||||
ecma_string_t*
|
||||
ecma_get_magic_string (ecma_magic_string_id_t id) /**< magic string id */
|
||||
{
|
||||
return ecma_new_ecma_string (ecma_get_magic_string_zt (id));
|
||||
} /* ecma_get_magic_string */
|
||||
|
||||
/**
|
||||
* Check if passed string equals to one of magic strings
|
||||
* and if equal magic string was found, return it's id in 'out_id_p' argument.
|
||||
*
|
||||
* @return true - if magic string equal to passed string was found,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool
|
||||
ecma_is_magic_string (ecma_char_t *zt_string_p, /**< zero-terminated string */
|
||||
ecma_magic_string_id_t *out_id_p) /**< out: magic string's id */
|
||||
{
|
||||
TODO (Improve performance of search);
|
||||
|
||||
|
||||
for (ecma_magic_string_id_t id = 0;
|
||||
id < ECMA_MAGIC_STRING__COUNT;
|
||||
id++)
|
||||
{
|
||||
if (ecma_compare_zt_strings (zt_string_p, ecma_get_magic_string_zt (id)))
|
||||
{
|
||||
*out_id_p = id;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
*out_id_p = ECMA_MAGIC_STRING__COUNT;
|
||||
|
||||
return false;
|
||||
} /* ecma_is_magic_string */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
@@ -1,62 +0,0 @@
|
||||
/* Copyright 2014 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_MAGIC_STRINGS_H
|
||||
#define ECMA_MAGIC_STRINGS_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmamagicstrings Collection of magic string constants used in ECMA
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Identifiers of ECMA magic string constants
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_MAGIC_STRING_ARGUMENTS, /**< "arguments" */
|
||||
ECMA_MAGIC_STRING_EVAL, /**< "eval" */
|
||||
ECMA_MAGIC_STRING_PROTOTYPE, /**< "prototype" */
|
||||
ECMA_MAGIC_STRING_CONSTRUCTOR, /**< "constructor" */
|
||||
ECMA_MAGIC_STRING_CALLER, /**< "caller" */
|
||||
ECMA_MAGIC_STRING_CALLEE, /**< "callee" */
|
||||
ECMA_MAGIC_STRING_UNDEFINED, /**< "undefined" */
|
||||
ECMA_MAGIC_STRING_NULL, /**< "null" */
|
||||
ECMA_MAGIC_STRING_FALSE, /**< "false" */
|
||||
ECMA_MAGIC_STRING_TRUE, /**< "true" */
|
||||
ECMA_MAGIC_STRING_NUMBER, /**< "number" */
|
||||
ECMA_MAGIC_STRING_STRING, /**< "string" */
|
||||
ECMA_MAGIC_STRING_OBJECT, /**< "object" */
|
||||
ECMA_MAGIC_STRING_FUNCTION, /**< "function" */
|
||||
ECMA_MAGIC_STRING_LENGTH, /**< "length" */
|
||||
ECMA_MAGIC_STRING_NAN, /**< "NaN" */
|
||||
ECMA_MAGIC_STRING_INFINITY, /**< "Infinity" */
|
||||
ECMA_MAGIC_STRING__COUNT /**< number of magic strings */
|
||||
} ecma_magic_string_id_t;
|
||||
|
||||
extern const ecma_char_t* ecma_get_magic_string_zt (ecma_magic_string_id_t id);
|
||||
extern ecma_string_t* ecma_get_magic_string (ecma_magic_string_id_t id);
|
||||
extern bool ecma_is_magic_string (ecma_char_t *zt_string_p, ecma_magic_string_id_t *out_id_p);
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ECMA_MAGIC_STRINGS_H */
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lex-env.h"
|
||||
#include "ecma-magic-strings.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-objects-arguments.h"
|
||||
#include "ecma-objects-general.h"
|
||||
|
||||
@@ -16,20 +16,19 @@
|
||||
#ifndef JERRY_ECMA_OPERATIONS_H
|
||||
#define JERRY_ECMA_OPERATIONS_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-lex-env.h"
|
||||
#include "ecma-reference.h"
|
||||
#include "globals.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmaoperations ECMA-defined operations
|
||||
*/
|
||||
|
||||
/**
|
||||
* \addtogroup ecmainitfinalize Initialization and finalization of ECMA components
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern ecma_completion_value_t ecma_op_get_value (ecma_reference_t ref);
|
||||
extern ecma_completion_value_t ecma_op_put_value (ecma_reference_t ref,
|
||||
ecma_value_t value);
|
||||
extern void ecma_init (void);
|
||||
extern void ecma_finalize (void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
Reference in New Issue
Block a user