tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ArgumentsObject-inl.h (1673B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
      2 * vim: set ts=8 sts=2 et sw=2 tw=80:
      3 * This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef vm_ArgumentsObject_inl_h
      8 #define vm_ArgumentsObject_inl_h
      9 
     10 #include "vm/ArgumentsObject.h"
     11 
     12 #include "vm/EnvironmentObject.h"
     13 
     14 #include "vm/EnvironmentObject-inl.h"
     15 
     16 namespace js {
     17 
     18 inline const Value& ArgumentsObject::element(uint32_t i) const {
     19  MOZ_ASSERT(isElement(i));
     20  const Value& v = data()->args[i];
     21  if (IsMagicScopeSlotValue(v)) {
     22    CallObject& callobj =
     23        getFixedSlot(MAYBE_CALL_SLOT).toObject().as<CallObject>();
     24    return callobj.aliasedFormalFromArguments(v);
     25  }
     26  return v;
     27 }
     28 
     29 inline void ArgumentsObject::setElement(uint32_t i, const Value& v) {
     30  MOZ_ASSERT(isElement(i));
     31  Value value = data()->args[i];
     32  if (IsMagicScopeSlotValue(value)) {
     33    CallObject& callobj =
     34        getFixedSlot(MAYBE_CALL_SLOT).toObject().as<CallObject>();
     35    callobj.setAliasedFormalFromArguments(value, v);
     36  } else {
     37    setArg(i, v);
     38  }
     39 }
     40 
     41 inline bool ArgumentsObject::maybeGetElements(uint32_t start, uint32_t count,
     42                                              Value* vp) {
     43  MOZ_ASSERT(start + count >= start);
     44 
     45  uint32_t length = initialLength();
     46  if (start > length || start + count > length || hasOverriddenElement()) {
     47    return false;
     48  }
     49 
     50  for (uint32_t i = start, end = start + count; i < end; ++i, ++vp) {
     51    *vp = element(i);
     52  }
     53  return true;
     54 }
     55 
     56 } /* namespace js */
     57 
     58 #endif /* vm_ArgumentsObject_inl_h */