11cb0ef41Sopenharmony_ci// Copyright 2018 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#ifndef V8_EXECUTION_ARGUMENTS_INL_H_
61cb0ef41Sopenharmony_ci#define V8_EXECUTION_ARGUMENTS_INL_H_
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci#include "src/execution/arguments.h"
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ci#include "src/handles/handles-inl.h"
111cb0ef41Sopenharmony_ci#include "src/objects/objects-inl.h"  // TODO(jkummerow): Just smi-inl.h.
121cb0ef41Sopenharmony_ci#include "src/objects/tagged-index.h"
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_cinamespace v8 {
151cb0ef41Sopenharmony_cinamespace internal {
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_citemplate <ArgumentsType T>
181cb0ef41Sopenharmony_ciArguments<T>::ChangeValueScope::ChangeValueScope(Isolate* isolate,
191cb0ef41Sopenharmony_ci                                                 Arguments* args, int index,
201cb0ef41Sopenharmony_ci                                                 Object value)
211cb0ef41Sopenharmony_ci    : location_(args->address_of_arg_at(index)) {
221cb0ef41Sopenharmony_ci  old_value_ = handle(Object(*location_), isolate);
231cb0ef41Sopenharmony_ci  *location_ = value.ptr();
241cb0ef41Sopenharmony_ci}
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_citemplate <ArgumentsType T>
271cb0ef41Sopenharmony_ciint Arguments<T>::smi_value_at(int index) const {
281cb0ef41Sopenharmony_ci  Object obj = (*this)[index];
291cb0ef41Sopenharmony_ci  int value = Smi::ToInt(obj);
301cb0ef41Sopenharmony_ci  DCHECK_IMPLIES(obj.IsTaggedIndex(), value == tagged_index_value_at(index));
311cb0ef41Sopenharmony_ci  return value;
321cb0ef41Sopenharmony_ci}
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_citemplate <ArgumentsType T>
351cb0ef41Sopenharmony_ciuint32_t Arguments<T>::positive_smi_value_at(int index) const {
361cb0ef41Sopenharmony_ci  int value = smi_value_at(index);
371cb0ef41Sopenharmony_ci  DCHECK_LE(0, value);
381cb0ef41Sopenharmony_ci  return value;
391cb0ef41Sopenharmony_ci}
401cb0ef41Sopenharmony_ci
411cb0ef41Sopenharmony_citemplate <ArgumentsType T>
421cb0ef41Sopenharmony_ciint Arguments<T>::tagged_index_value_at(int index) const {
431cb0ef41Sopenharmony_ci  return static_cast<int>(TaggedIndex::cast((*this)[index]).value());
441cb0ef41Sopenharmony_ci}
451cb0ef41Sopenharmony_ci
461cb0ef41Sopenharmony_citemplate <ArgumentsType T>
471cb0ef41Sopenharmony_cidouble Arguments<T>::number_value_at(int index) const {
481cb0ef41Sopenharmony_ci  return (*this)[index].Number();
491cb0ef41Sopenharmony_ci}
501cb0ef41Sopenharmony_ci
511cb0ef41Sopenharmony_ci}  // namespace internal
521cb0ef41Sopenharmony_ci}  // namespace v8
531cb0ef41Sopenharmony_ci
541cb0ef41Sopenharmony_ci#endif  // V8_EXECUTION_ARGUMENTS_INL_H_
55