// Copyright 2018 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_EXECUTION_ARGUMENTS_INL_H_ #define V8_EXECUTION_ARGUMENTS_INL_H_ #include "src/execution/arguments.h" #include "src/handles/handles-inl.h" #include "src/objects/objects-inl.h" // TODO(jkummerow): Just smi-inl.h. #include "src/objects/tagged-index.h" namespace v8 { namespace internal { template Arguments::ChangeValueScope::ChangeValueScope(Isolate* isolate, Arguments* args, int index, Tagged value) : location_(args->address_of_arg_at(index)) { old_value_ = handle(Object(*location_), isolate); *location_ = value.ptr(); } template int Arguments::smi_value_at(int index) const { Tagged obj = (*this)[index]; int value = Smi::ToInt(obj); DCHECK_IMPLIES(IsTaggedIndex(obj), value == tagged_index_value_at(index)); return value; } template uint32_t Arguments::positive_smi_value_at(int index) const { int value = smi_value_at(index); DCHECK_LE(0, value); return value; } template int Arguments::tagged_index_value_at(int index) const { return static_cast(TaggedIndex::cast((*this)[index]).value()); } template double Arguments::number_value_at(int index) const { return Object::Number((*this)[index]); } template Handle Arguments::atOrUndefined(Isolate* isolate, int index) const { if (index >= length_) { return Handle::cast(isolate->factory()->undefined_value()); } return at(index); } } // namespace internal } // namespace v8 #endif // V8_EXECUTION_ARGUMENTS_INL_H_