tor-browser

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

Script-inl.h (1866B)


      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 debugger_Script_inl_h
      8 #define debugger_Script_inl_h
      9 
     10 #include "debugger/Script.h"  // for DebuggerScript
     11 
     12 #include "mozilla/Assertions.h"  // for AssertionConditionType, MOZ_ASSERT
     13 #include "mozilla/Variant.h"     // for AsVariant
     14 
     15 #include "jstypes.h"            // for JS_PUBLIC_API
     16 #include "debugger/Debugger.h"  // for DebuggerScriptReferent
     17 #include "gc/Cell.h"            // for Cell
     18 #include "vm/JSScript.h"        // for BaseScript, JSScript
     19 #include "vm/NativeObject.h"    // for NativeObject
     20 #include "wasm/WasmJS.h"        // for WasmInstanceObject
     21 
     22 #include "debugger/Debugger-inl.h"  // for Debugger::fromJSObject
     23 
     24 class JS_PUBLIC_API JSObject;
     25 
     26 inline js::Debugger* js::DebuggerScript::owner() const {
     27  JSObject* dbgobj = &getReservedSlot(OWNER_SLOT).toObject();
     28  return Debugger::fromJSObject(dbgobj);
     29 }
     30 
     31 js::gc::Cell* js::DebuggerScript::getReferentCell() const {
     32  return maybePtrFromReservedSlot<gc::Cell>(SCRIPT_SLOT);
     33 }
     34 
     35 js::DebuggerScriptReferent js::DebuggerScript::getReferent() const {
     36  if (gc::Cell* cell = getReferentCell()) {
     37    if (cell->is<BaseScript>()) {
     38      return mozilla::AsVariant(cell->as<BaseScript>());
     39    }
     40    MOZ_ASSERT(cell->is<JSObject>());
     41    return mozilla::AsVariant(
     42        &static_cast<NativeObject*>(cell)->as<WasmInstanceObject>());
     43  }
     44  return mozilla::AsVariant(static_cast<BaseScript*>(nullptr));
     45 }
     46 
     47 js::BaseScript* js::DebuggerScript::getReferentScript() const {
     48  gc::Cell* cell = getReferentCell();
     49  return cell->as<BaseScript>();
     50 }
     51 
     52 #endif /* debugger_Script_inl_h */