mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Introducing partially implemented Global object constructor.
This commit is contained in:
parent
e25e4d6cab
commit
16cab18ae9
56
src/libecmaoperations/ecma-global-object.c
Normal file
56
src/libecmaoperations/ecma-global-object.c
Normal file
@ -0,0 +1,56 @@
|
||||
/* 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 "globals.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-global-object.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-magic-strings.h"
|
||||
|
||||
/** \addtogroup ecma ---TODO---
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmaglobalobject ECMA Global object related routines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Global Object construction routine.
|
||||
*
|
||||
* See also: ECMA-262 v5, 15.1
|
||||
*
|
||||
* @return pointer to the constructed object
|
||||
*/
|
||||
ecma_object_t*
|
||||
ecma_op_create_global_object( void)
|
||||
{
|
||||
ecma_object_t *glob_obj_p = ecma_create_object( NULL, true, ECMA_OBJECT_TYPE_GENERAL);
|
||||
|
||||
ecma_property_t *undefined_prop_p = ecma_create_named_data_property( glob_obj_p,
|
||||
ecma_get_magic_string( ECMA_MAGIC_STRING_UNDEFINED),
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE);
|
||||
JERRY_ASSERT( ecma_is_value_undefined( undefined_prop_p->u.named_data_property.value) );
|
||||
|
||||
TODO( /* Define NaN, Infinity, eval, parseInt, parseFloat, isNaN, isFinite properties */ );
|
||||
|
||||
return glob_obj_p;
|
||||
} /* ecma_op_create_global_object */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
35
src/libecmaoperations/ecma-global-object.h
Normal file
35
src/libecmaoperations/ecma-global-object.h
Normal file
@ -0,0 +1,35 @@
|
||||
/* 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_GLOBAL_OBJECT_H
|
||||
#define ECMA_GLOBAL_OBJECT_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
/** \addtogroup ecma ---TODO---
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmaglobalobject ECMA Global object related routines
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern ecma_object_t* ecma_op_create_global_object( void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !ECMA_GLOBAL_OBJECT_H */
|
||||
@ -44,6 +44,8 @@ ecma_get_magic_string( ecma_magic_string_id_t id) /**< magic string id */
|
||||
return (ecma_char_t*) "constructor";
|
||||
case ECMA_MAGIC_STRING_CALLER:
|
||||
return (ecma_char_t*) "caller";
|
||||
case ECMA_MAGIC_STRING_UNDEFINED:
|
||||
return (ecma_char_t*) "undefined";
|
||||
}
|
||||
|
||||
JERRY_UNREACHABLE();
|
||||
|
||||
@ -34,7 +34,8 @@ typedef enum
|
||||
ECMA_MAGIC_STRING_EVAL, /**< "eval" */
|
||||
ECMA_MAGIC_STRING_PROTOTYPE, /**< "prototype" */
|
||||
ECMA_MAGIC_STRING_CONSTRUCTOR, /**< "constructor" */
|
||||
ECMA_MAGIC_STRING_CALLER /**< "caller" */
|
||||
ECMA_MAGIC_STRING_CALLER, /**< "caller" */
|
||||
ECMA_MAGIC_STRING_UNDEFINED /**< undefined */
|
||||
} ecma_magic_string_id_t;
|
||||
|
||||
extern const ecma_char_t* ecma_get_magic_string( ecma_magic_string_id_t id);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user