Introducing ecma_get_magic_string that returns pointer to requested magic string that is used in an ECMA routine.

This commit is contained in:
Ruben Ayrapetyan
2014-07-30 17:56:53 +04:00
parent b059212e32
commit df224408fc
3 changed files with 105 additions and 3 deletions
@@ -0,0 +1,55 @@
/* 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-magic-strings.h"
/** \addtogroup ecma ---TODO---
* @{
*
* \addtogroup ecmamagicstrings Collection of magic string constants used in ECMA
* @{
*/
/**
* Get specified magic string
*
* @return pointer to magic string contant
*/
const ecma_char_t*
ecma_get_magic_string( 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";
}
JERRY_UNREACHABLE();
} /* ecma_get_magic_string */
/**
* @}
* @}
*/
@@ -0,0 +1,47 @@
/* 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 ---TODO---
* @{
*
* \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_id_t;
extern const ecma_char_t* ecma_get_magic_string( ecma_magic_string_id_t id);
/**
* @}
* @}
*/
#endif /* ECMA_MAGIC_STRINGS_H */