Add 'exit' intrinsic

This commit is contained in:
Ilmir Usmanov 2014-07-31 21:52:25 +04:00
parent 2e0a3d4aca
commit 1d41e8a355
2 changed files with 25 additions and 0 deletions

View File

@ -459,6 +459,16 @@ opfunc_call_1 (OPCODE opdata __unused, struct __int_data *int_data)
ECMA_FINALIZE (cond_value);
}
if (!__strcmp ((const char *) str_value.str_p, "exit"))
{
ECMA_TRY_CATCH (cond_value, get_variable_value (int_data, opdata.data.call_1.arg1_lit_idx, false), ret_value);
JERRY_ASSERT(cond_value.value.value_type == ECMA_TYPE_NUMBER );
ecma_number_t * num_p = (ecma_number_t*)ecma_get_pointer(cond_value.value.value);
opfunc_exitval (getop_exitval ((T_IDX)*num_p), int_data);
ret_value = ecma_make_empty_completion_value ();
ECMA_FINALIZE (cond_value);
}
free_string_literal_copy (&str_value);
return ret_value;

15
tests/jerry/exit.js Normal file
View File

@ -0,0 +1,15 @@
// 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.
exit(0);