Skip to content

Commit dba42e0

Browse files
committed
Addressing reviews.
JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
1 parent f0eb57a commit dba42e0

File tree

8 files changed

+413
-344
lines changed

8 files changed

+413
-344
lines changed

jerry-core/ecma/operations/ecma-eval.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,28 +84,21 @@ ecma_op_eval_chars_buffer (const lit_utf8_byte_t *code_p, /**< code characters b
8484
{
8585
JERRY_ASSERT (code_p != NULL);
8686

87-
ecma_value_t ret_value;
88-
8987
ecma_compiled_code_t *bytecode_data_p;
90-
ecma_object_t *parse_status;
9188

9289
bool is_strict_call = (is_direct && is_called_from_strict_mode_code);
9390

94-
parse_status = parser_parse_eval (code_p,
95-
code_buffer_size,
96-
is_strict_call,
97-
&bytecode_data_p);
91+
ecma_value_t parse_status = parser_parse_eval (code_p,
92+
code_buffer_size,
93+
is_strict_call,
94+
&bytecode_data_p);
9895

99-
if (parse_status == NULL)
100-
{
101-
ret_value = vm_run_eval (bytecode_data_p, is_direct);
102-
}
103-
else
96+
if (ECMA_IS_VALUE_ERROR (parse_status))
10497
{
105-
ret_value = ecma_make_error_obj_value (parse_status);
98+
return parse_status;
10699
}
107100

108-
return ret_value;
101+
return vm_run_eval (bytecode_data_p, is_direct);
109102
} /* ecma_op_eval_chars_buffer */
110103

111104
/**

jerry-core/jerry-api.h

Lines changed: 86 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,49 @@ typedef uint32_t jerry_length_t;
9292
*/
9393
typedef uint32_t jerry_value_t;
9494

95+
96+
/**
97+
* Description of ECMA property descriptor
98+
*/
99+
typedef struct
100+
{
101+
/** Is [[Value]] defined? */
102+
bool is_value_defined;
103+
104+
/** Is [[Get]] defined? */
105+
bool is_get_defined;
106+
107+
/** Is [[Set]] defined? */
108+
bool is_set_defined;
109+
110+
/** Is [[Writable]] defined? */
111+
bool is_writable_defined;
112+
113+
/** [[Writable]] */
114+
bool is_writable;
115+
116+
/** Is [[Enumerable]] defined? */
117+
bool is_enumerable_defined;
118+
119+
/** [[Enumerable]] */
120+
bool is_enumerable;
121+
122+
/** Is [[Configurable]] defined? */
123+
bool is_configurable_defined;
124+
125+
/** [[Configurable]] */
126+
bool is_configurable;
127+
128+
/** [[Value]] */
129+
jerry_value_t value;
130+
131+
/** [[Get]] */
132+
jerry_value_t getter;
133+
134+
/** [[Set]] */
135+
jerry_value_t setter;
136+
} jerry_property_descriptor_t;
137+
95138
/**
96139
* Type of an external function handler
97140
*/
@@ -108,9 +151,9 @@ typedef void (*jerry_object_free_callback_t) (const uintptr_t native_p);
108151
/**
109152
* Function type applied for each data property of an object
110153
*/
111-
typedef bool (*jerry_object_field_foreach_t) (const jerry_value_t property_name_p,
112-
const jerry_value_t property_value,
113-
void *user_data_p);
154+
typedef bool (*jerry_object_property_foreach_t) (const jerry_value_t property_name_p,
155+
const jerry_value_t property_value,
156+
void *user_data_p);
114157

115158

116159
/**
@@ -134,7 +177,7 @@ void jerry_gc (void);
134177
* Parser and executor functions
135178
*/
136179
bool jerry_run_simple (const jerry_char_t *, size_t, jerry_init_flag_t);
137-
jerry_value_t jerry_parse (const jerry_char_t *, size_t); // true value if success
180+
jerry_value_t jerry_parse (const jerry_char_t *, size_t);
138181
jerry_value_t jerry_run (void);
139182
jerry_value_t jerry_eval (const jerry_char_t *, size_t, bool);
140183

@@ -149,28 +192,45 @@ jerry_value_t jerry_get_global (void);
149192
bool jerry_value_is_array (const jerry_value_t);
150193
bool jerry_value_is_boolean (const jerry_value_t);
151194
bool jerry_value_is_constructor (const jerry_value_t);
152-
bool jerry_value_is_error (const jerry_value_t);
153195
bool jerry_value_is_function (const jerry_value_t);
154196
bool jerry_value_is_number (const jerry_value_t);
155197
bool jerry_value_is_null (const jerry_value_t);
156198
bool jerry_value_is_object (const jerry_value_t);
157199
bool jerry_value_is_string (const jerry_value_t);
158200
bool jerry_value_is_undefined (const jerry_value_t);
159201

202+
/**
203+
* Error flag manipulation functions
204+
*/
205+
bool jerry_value_has_error_flag (const jerry_value_t);
206+
void jerry_value_clear_error_flag (jerry_value_t *);
207+
void jerry_value_set_error_flag (jerry_value_t *);
208+
160209
/**
161210
* Getter functions of 'jerry_value_t'
162211
*/
163212
bool jerry_get_boolean_value (const jerry_value_t);
164213
double jerry_get_number_value (const jerry_value_t);
165214

215+
/**
216+
* Functions of string values
217+
*/
218+
jerry_size_t jerry_get_string_size (const jerry_value_t);
219+
jerry_length_t jerry_get_string_length (const jerry_value_t);
220+
jerry_size_t jerry_string_to_char_buffer (const jerry_value_t, jerry_char_t *, jerry_size_t);
221+
222+
/**
223+
* Functions of array object values
224+
*/
225+
uint32_t jerry_get_array_length (const jerry_value_t);
226+
166227
/**
167228
* Converters of 'jerry_value_t'
168229
*/
169230
bool jerry_value_to_boolean (const jerry_value_t);
170231
jerry_value_t jerry_value_to_number (const jerry_value_t);
171232
jerry_value_t jerry_value_to_object (const jerry_value_t);
172233
jerry_value_t jerry_value_to_string (const jerry_value_t);
173-
jerry_value_t jerry_value_remove_error_flag (const jerry_value_t);
174234

175235
/**
176236
* Acquire types with reference counter (increase the references)
@@ -197,53 +257,38 @@ jerry_value_t jerry_create_string (const jerry_char_t *);
197257
jerry_value_t jerry_create_string_sz (const jerry_char_t *, jerry_size_t);
198258
jerry_value_t jerry_create_undefined (void);
199259

200-
/**
201-
* Functions of array objects
202-
*/
203-
jerry_value_t jerry_set_array_index_value (const jerry_value_t, uint32_t, const jerry_value_t);
204-
jerry_value_t jerry_get_array_index_value (const jerry_value_t , uint32_t);
205-
uint32_t jerry_get_array_length (const jerry_value_t);
206-
207-
/**
208-
* Functions of 'jerry_string_t'
209-
*/
210-
jerry_size_t jerry_get_string_size (const jerry_value_t);
211-
jerry_length_t jerry_get_string_length (const jerry_value_t);
212-
jerry_size_t jerry_string_to_char_buffer (const jerry_value_t, jerry_char_t *, jerry_size_t);
213-
214260
/**
215261
* General API functions of JS objects
216262
*/
217263
bool jerry_has_property (const jerry_value_t, const jerry_value_t);
218264
bool jerry_has_own_property (const jerry_value_t, const jerry_value_t);
219265
bool jerry_delete_property (const jerry_value_t, const jerry_value_t);
220266

221-
jerry_value_t jerry_set_data_property (const jerry_value_t, const jerry_value_t, const jerry_value_t);
222-
jerry_value_t jerry_set_own_data_property (const jerry_value_t, const jerry_value_t, const jerry_value_t);
223-
jerry_value_t jerry_get_data_property (const jerry_value_t, const jerry_value_t);
224-
jerry_value_t jerry_get_own_data_property (const jerry_value_t, const jerry_value_t);
225-
226-
jerry_value_t jerry_define_own_data_property (const jerry_value_t,
227-
const jerry_value_t,
228-
bool,
229-
bool,
230-
bool,
231-
const jerry_value_t);
232-
jerry_value_t jerry_define_own_accessor_property (const jerry_value_t,
233-
const jerry_value_t,
234-
bool,
235-
bool,
236-
const jerry_value_t,
237-
const jerry_value_t);
238-
239-
jerry_value_t jerry_function_call (const jerry_value_t, const jerry_value_t, const jerry_value_t[], jerry_size_t);
240-
jerry_value_t jerry_object_construct (const jerry_value_t, const jerry_value_t[], jerry_size_t);
267+
jerry_value_t jerry_set_property (const jerry_value_t, const jerry_value_t, const jerry_value_t);
268+
jerry_value_t jerry_set_own_property (const jerry_value_t, const jerry_value_t, const jerry_value_t);
269+
jerry_value_t jerry_set_property_by_index (const jerry_value_t, uint32_t, const jerry_value_t);
270+
jerry_value_t jerry_get_property (const jerry_value_t, const jerry_value_t);
271+
jerry_value_t jerry_get_own_property (const jerry_value_t, const jerry_value_t);
272+
jerry_value_t jerry_get_property_by_index (const jerry_value_t , uint32_t);
273+
274+
void jerry_init_property_descriptor (jerry_property_descriptor_t *);
275+
jerry_value_t jerry_define_own_property (const jerry_value_t,
276+
const jerry_value_t,
277+
const jerry_property_descriptor_t *);
278+
279+
bool jerry_get_own_property_descriptor (const jerry_value_t,
280+
const jerry_value_t,
281+
jerry_property_descriptor_t *);
282+
void jerry_free_property_descriptor_fields (const jerry_property_descriptor_t *);
283+
284+
jerry_value_t jerry_call_function (const jerry_value_t, const jerry_value_t, const jerry_value_t[], jerry_size_t);
285+
jerry_value_t jerry_construct_object (const jerry_value_t, const jerry_value_t[], jerry_size_t);
241286

242287
jerry_value_t jerry_get_object_keys (const jerry_value_t);
243288

244289
bool jerry_get_object_native_handle (const jerry_value_t, uintptr_t *);
245290
void jerry_set_object_native_handle (const jerry_value_t, uintptr_t, jerry_object_free_callback_t);
246-
bool jerry_foreach_object_field (const jerry_value_t, jerry_object_field_foreach_t, void *);
291+
bool jerry_foreach_object_property (const jerry_value_t, jerry_object_property_foreach_t, void *);
247292

248293
/**
249294
* Snapshot functions

0 commit comments

Comments
 (0)