LCOV - code coverage report
Current view: top level - js/src/vm - EnvironmentObject-inl.h (source / functions) Hit Total Coverage
Test: output.info Lines: 23 34 67.6 %
Date: 2017-07-14 16:53:18 Functions: 5 6 83.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2             :  * vim: set ts=8 sts=4 et sw=4 tw=99:
       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_EnvironmentObject_inl_h
       8             : #define vm_EnvironmentObject_inl_h
       9             : 
      10             : #include "vm/EnvironmentObject.h"
      11             : 
      12             : #include "jsobjinlines.h"
      13             : 
      14             : #include "vm/TypeInference-inl.h"
      15             : 
      16             : namespace js {
      17             : 
      18             : inline LexicalEnvironmentObject&
      19         677 : NearestEnclosingExtensibleLexicalEnvironment(JSObject* env)
      20             : {
      21         677 :     while (!IsExtensibleLexicalEnvironment(env))
      22           0 :         env = env->enclosingEnvironment();
      23         677 :     return env->as<LexicalEnvironmentObject>();
      24             : }
      25             : 
      26             : inline void
      27       11272 : EnvironmentObject::setAliasedBinding(JSContext* cx, uint32_t slot, PropertyName* name,
      28             :                                      const Value& v)
      29             : {
      30       11272 :     if (isSingleton()) {
      31           6 :         MOZ_ASSERT(name);
      32           6 :         AddTypePropertyId(cx, this, NameToId(name), v);
      33             : 
      34             :         // Keep track of properties which have ever been overwritten.
      35           6 :         if (!getSlot(slot).isUndefined()) {
      36           0 :             Shape* shape = lookup(cx, name);
      37           0 :             shape->setOverwritten();
      38             :         }
      39             :     }
      40             : 
      41       11272 :     setSlot(slot, v);
      42       11272 : }
      43             : 
      44             : inline void
      45        1746 : EnvironmentObject::setAliasedBinding(JSContext* cx, EnvironmentCoordinate ec, PropertyName* name,
      46             :                                      const Value& v)
      47             : {
      48        1746 :     setAliasedBinding(cx, ec.slot(), name, v);
      49        1746 : }
      50             : 
      51             : inline void
      52        9526 : EnvironmentObject::setAliasedBinding(JSContext* cx, const BindingIter& bi, const Value& v)
      53             : {
      54        9526 :     MOZ_ASSERT(bi.location().kind() == BindingLocation::Kind::Environment);
      55        9526 :     setAliasedBinding(cx, bi.location().slot(), bi.name()->asPropertyName(), v);
      56        9526 : }
      57             : 
      58             : inline void
      59           0 : CallObject::setAliasedFormalFromArguments(JSContext* cx, const Value& argsValue, jsid id,
      60             :                                           const Value& v)
      61             : {
      62           0 :     setSlot(ArgumentsObject::SlotFromMagicScopeSlotValue(argsValue), v);
      63           0 :     if (isSingleton())
      64           0 :         AddTypePropertyId(cx, this, id, v);
      65           0 : }
      66             : 
      67             : }  /* namespace js */
      68             : 
      69             : inline JSObject*
      70       34361 : JSObject::enclosingEnvironment() const
      71             : {
      72       34361 :     if (is<js::EnvironmentObject>())
      73       33441 :         return &as<js::EnvironmentObject>().enclosingEnvironment();
      74             : 
      75         920 :     if (is<js::DebugEnvironmentProxy>())
      76           0 :         return &as<js::DebugEnvironmentProxy>().enclosingEnvironment();
      77             : 
      78         920 :     if (is<js::GlobalObject>())
      79         920 :         return nullptr;
      80             : 
      81           0 :     MOZ_ASSERT_IF(is<JSFunction>(), as<JSFunction>().isInterpreted());
      82           0 :     return &global();
      83             : }
      84             : 
      85             : #endif /* vm_EnvironmentObject_inl_h */

Generated by: LCOV version 1.13