Add retval opcode handler.
This commit is contained in:
@@ -431,7 +431,6 @@ do_number_bitwise_logic (struct __int_data *int_data, /**< interpreter context *
|
|||||||
op (native_call) \
|
op (native_call) \
|
||||||
op (func_decl_n) \
|
op (func_decl_n) \
|
||||||
op (varg_list) \
|
op (varg_list) \
|
||||||
op (retval) \
|
|
||||||
op (construct_decl) \
|
op (construct_decl) \
|
||||||
op (array_decl) \
|
op (array_decl) \
|
||||||
op (prop) \
|
op (prop) \
|
||||||
@@ -1894,6 +1893,31 @@ opfunc_ret (OPCODE opdata __unused, /**< operation data */
|
|||||||
ECMA_TARGET_ID_RESERVED);
|
ECMA_TARGET_ID_RESERVED);
|
||||||
} /* opfunc_ret */
|
} /* opfunc_ret */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 'Return with expression' opcode handler.
|
||||||
|
*
|
||||||
|
* See also: ECMA-262 v5, 12.9
|
||||||
|
*
|
||||||
|
* @return completion value
|
||||||
|
* Returned value is simple and so need not be freed.
|
||||||
|
* However, ecma_free_completion_value may be called for it, but it is a no-op.
|
||||||
|
*/
|
||||||
|
ecma_completion_value_t
|
||||||
|
opfunc_retval (OPCODE opdata __unused, /**< operation data */
|
||||||
|
struct __int_data *int_data __unused) /**< interpreter context */
|
||||||
|
{
|
||||||
|
ecma_completion_value_t ret_value;
|
||||||
|
|
||||||
|
ECMA_TRY_CATCH (expr_val, get_variable_value (int_data, opdata.data.retval.ret_value, false), ret_value);
|
||||||
|
|
||||||
|
ret_value = ecma_make_completion_value (ECMA_COMPLETION_TYPE_RETURN,
|
||||||
|
expr_val.value,
|
||||||
|
ECMA_TARGET_ID_RESERVED);
|
||||||
|
|
||||||
|
ECMA_FINALIZE (expr_val);
|
||||||
|
return ret_value;
|
||||||
|
} /* opfunc_retval */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 'Property getter' opcode handler.
|
* 'Property getter' opcode handler.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
function f_empty()
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f_42()
|
||||||
|
{
|
||||||
|
return 42;
|
||||||
|
}
|
||||||
|
|
||||||
|
function f_expr()
|
||||||
|
{
|
||||||
|
var a = 5;
|
||||||
|
var b = 5;
|
||||||
|
return a + b;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(f_expr() === 10);
|
||||||
|
assert(f_42() === 42);
|
||||||
Reference in New Issue
Block a user