Implementing 'multiplication' opcode handler and unit test for the opcode.

This commit is contained in:
Ruben Ayrapetyan
2014-07-21 21:59:15 +04:00
parent 9b2b248728
commit 739d19be5b
8 changed files with 372 additions and 41 deletions
+17 -17
View File
@@ -38,9 +38,9 @@
* Returned value must be freed with ecma_free_completion_value.
*/
ecma_CompletionValue_t
ecma_op_get_value( ecma_Reference_t *ref_p) /**< ECMA-reference */
ecma_op_get_value( ecma_Reference_t ref) /**< ECMA-reference */
{
const ecma_Value_t base = ref_p->base;
const ecma_Value_t base = ref.base;
const bool is_unresolvable_reference = ecma_IsValueUndefined( base);
const bool has_primitive_base = ( ecma_IsValueBoolean( base)
|| base.m_ValueType == ECMA_TYPE_NUMBER
@@ -64,14 +64,14 @@ ecma_op_get_value( ecma_Reference_t *ref_p) /**< ECMA-reference */
JERRY_ASSERT( obj_p != NULL && !obj_p->m_IsLexicalEnvironment );
// GetValue_4.b case 1
/* return [[Get]]( base as this, ref_p->referenced_name_p) */
/* return [[Get]]( base as this, ref.referenced_name_p) */
JERRY_UNIMPLEMENTED();
} else
{ // GetValue_4.b case 2
/*
ecma_Object_t *obj_p = ecma_ToObject( base);
JERRY_ASSERT( obj_p != NULL && !obj_p->m_IsLexicalEnvironment );
ecma_Property_t *property = obj_p->[[GetProperty]]( ref_p->referenced_name_p);
ecma_Property_t *property = obj_p->[[GetProperty]]( ref.referenced_name_p);
if ( property->m_Type == ECMA_PROPERTY_NAMEDDATA )
{
return ecma_MakeCompletionValue( ECMA_COMPLETION_TYPE_NORMAL,
@@ -103,7 +103,7 @@ ecma_op_get_value( ecma_Reference_t *ref_p) /**< ECMA-reference */
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->m_IsLexicalEnvironment );
return ecma_OpGetBindingValue( lex_env_p, ref_p->referenced_name_p, ref_p->is_strict);
return ecma_OpGetBindingValue( lex_env_p, ref.referenced_name_p, ref.is_strict);
}
} /* ecma_op_get_value */
@@ -116,10 +116,10 @@ ecma_op_get_value( ecma_Reference_t *ref_p) /**< ECMA-reference */
* Returned value must be freed with ecma_free_completion_value.
*/
ecma_CompletionValue_t
ecma_op_put_value(ecma_Reference_t *ref_p, /**< ECMA-reference */
ecma_op_put_value(ecma_Reference_t ref, /**< ECMA-reference */
ecma_Value_t value) /**< ECMA-value */
{
const ecma_Value_t base = ref_p->base;
const ecma_Value_t base = ref.base;
const bool is_unresolvable_reference = ecma_IsValueUndefined( base);
const bool has_primitive_base = ( ecma_IsValueBoolean( base)
|| base.m_ValueType == ECMA_TYPE_NUMBER
@@ -130,7 +130,7 @@ ecma_op_put_value(ecma_Reference_t *ref_p, /**< ECMA-reference */
if ( is_unresolvable_reference ) // PutValue_3
{
if ( ref_p->is_strict ) // PutValue_3.a
if ( ref.is_strict ) // PutValue_3.a
{
return ecma_MakeThrowValue( ecma_NewStandardError( ECMA_ERROR_REFERENCE));
} else // PutValue_3.b
@@ -138,7 +138,7 @@ ecma_op_put_value(ecma_Reference_t *ref_p, /**< ECMA-reference */
/*
ecma_Object_t *global_object_p = ecma_GetGlobalObject();
return global_object_p->[[Put]]( ref_p->referenced_name_p, value, false);
return global_object_p->[[Put]]( ref.referenced_name_p, value, false);
*/
JERRY_UNIMPLEMENTED();
@@ -149,7 +149,7 @@ ecma_op_put_value(ecma_Reference_t *ref_p, /**< ECMA-reference */
{
// PutValue_4.b case 1
/* return [[Put]]( base as this, ref_p->referenced_name_p, value, ref_p->is_strict); */
/* return [[Put]]( base as this, ref.referenced_name_p, value, ref.is_strict); */
JERRY_UNIMPLEMENTED();
} else
{
@@ -161,10 +161,10 @@ ecma_op_put_value(ecma_Reference_t *ref_p, /**< ECMA-reference */
JERRY_ASSERT( obj_p != NULL && !obj_p->m_IsLexicalEnvironment );
// PutValue_sub_2
if ( !obj_p->[[CanPut]]( ref_p->referenced_name_p) )
if ( !obj_p->[[CanPut]]( ref.referenced_name_p) )
{
// PutValue_sub_2.a
if ( ref_p->is_strict )
if ( ref.is_strict )
{
return ecma_MakeThrowValue( ecma_NewStandardError( ECMA_ERROR_TYPE));
} else
@@ -176,13 +176,13 @@ ecma_op_put_value(ecma_Reference_t *ref_p, /**< ECMA-reference */
}
// PutValue_sub_3
ecma_Property_t *own_prop = obj_p->[[GetOwnProperty]]( ref_p->referenced_name_p);
ecma_Property_t *own_prop = obj_p->[[GetOwnProperty]]( ref.referenced_name_p);
// PutValue_sub_4
if ( ecma_OpIsDataDescriptor( own_prop) )
{
// PutValue_sub_4.a
if ( ref_p->is_strict )
if ( ref.is_strict )
{
return ecma_MakeThrowValue( ecma_NewStandardError( ECMA_ERROR_TYPE));
} else
@@ -194,7 +194,7 @@ ecma_op_put_value(ecma_Reference_t *ref_p, /**< ECMA-reference */
}
// PutValue_sub_5
ecma_Property_t *prop = obj_p->[[GetProperty]]( ref_p->referenced_name_p);
ecma_Property_t *prop = obj_p->[[GetProperty]]( ref.referenced_name_p);
// PutValue_sub_6
if ( ecma_OpIsAccessorDescriptor( prop) )
@@ -208,7 +208,7 @@ ecma_op_put_value(ecma_Reference_t *ref_p, /**< ECMA-reference */
} else // PutValue_sub_7
{
// PutValue_sub_7.a
if ( ref_p->is_strict )
if ( ref.is_strict )
{
return ecma_MakeThrowValue( ecma_NewStandardError( ECMA_ERROR_TYPE));
}
@@ -229,7 +229,7 @@ ecma_op_put_value(ecma_Reference_t *ref_p, /**< ECMA-reference */
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->m_IsLexicalEnvironment );
return ecma_OpSetMutableBinding( lex_env_p, ref_p->referenced_name_p, value, ref_p->is_strict);
return ecma_OpSetMutableBinding( lex_env_p, ref.referenced_name_p, value, ref.is_strict);
}
} /* ecma_op_put_value */
@@ -0,0 +1,48 @@
/* 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-number-arithmetic.h"
/** \addtogroup ecma ---TODO---
* @{
*/
/**
* \addtogroup numberarithmetic ECMA number arithmetic operations
* @{
*/
/**
* ECMA-defined number multiplication.
*
* See also:
* ECMA-262 v5, 11.5.1
*
* @return number - result of multiplication.
*/
ecma_Number_t
ecma_op_number_multiply(ecma_Number_t left_num, /**< left operand */
ecma_Number_t right_num) /**< right operand */
{
TODO( Implement according to ECMA );
return left_num * right_num;
} /* ecma_op_number_multiply */
/**
* @}
* @}
*/
@@ -0,0 +1,37 @@
/* 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_NUMBER_H
#define ECMA_NUMBER_H
#include "ecma-globals.h"
/** \addtogroup ecma ---TODO---
* @{
*/
/**
* \addtogroup numberarithmetic ECMA number arithmetic operations
* @{
*/
extern ecma_Number_t ecma_op_number_multiply( ecma_Number_t left_num, ecma_Number_t right_num);
/**
* @}
* @}
*/
#endif /* ECMA_NUMBER_H */
+2 -2
View File
@@ -29,8 +29,8 @@
extern ecma_Reference_t ecma_OpGetIdentifierReference( ecma_Object_t *lex_env_p, ecma_Char_t *name_p, bool is_strict);
extern ecma_CompletionValue_t ecma_op_get_value( ecma_Reference_t *ref_p);
extern ecma_CompletionValue_t ecma_op_put_value( ecma_Reference_t *ref_p, ecma_Value_t value);
extern ecma_CompletionValue_t ecma_op_get_value( ecma_Reference_t ref);
extern ecma_CompletionValue_t ecma_op_put_value( ecma_Reference_t ref, ecma_Value_t value);
/**
* @}