chromium/v8/include/v8-value.h

// Copyright 2021 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 INCLUDE_V8_VALUE_H_
#define INCLUDE_V8_VALUE_H_

#include "v8-data.h"          // NOLINT(build/include_directory)
#include "v8-internal.h"      // NOLINT(build/include_directory)
#include "v8-local-handle.h"  // NOLINT(build/include_directory)
#include "v8-maybe.h"         // NOLINT(build/include_directory)
#include "v8config.h"         // NOLINT(build/include_directory)

/**
 * The v8 JavaScript engine.
 */
namespace v8 {

class Primitive;
class Numeric;
class BigInt;
class Int32;
class Integer;
class Number;
class Object;
class String;
class Uint32;

/**
 * The superclass of all JavaScript values and objects.
 */
class V8_EXPORT Value : public Data {};

/**
 * Can be used to avoid repeated expensive type checks for groups of objects
 * that are expected to be similar (e.g. when Blink converts a bunch of
 * JavaScript objects to "ScriptWrappable" after a "HasInstance" check) by
 * making use of V8-internal "hidden classes". An object that has passed the
 * full check can be remembered via {Update}; further objects can be queried
 * using {Matches}.
 * Note that the answer will be conservative/"best-effort": when {Matches}
 * returns true, then the {candidate} can be relied upon to have the same
 * shape/constructor/prototype/etc. as the {baseline}. Otherwise, no reliable
 * statement can be made (the objects might still have indistinguishable shapes
 * for all intents and purposes, but this mechanism, being optimized for speed,
 * couldn't determine that quickly).
 */
class V8_EXPORT TypecheckWitness {};

template <>
V8_INLINE Value* Value::Cast(Data* value) {}

bool Value::IsUndefined() const {}

bool Value::QuickIsUndefined() const {}

bool Value::IsNull() const {}

bool Value::QuickIsNull() const {}

bool Value::IsNullOrUndefined() const {}

bool Value::QuickIsNullOrUndefined() const {}

bool Value::IsTrue() const {}

#if V8_STATIC_ROOTS_BOOL
bool Value::QuickIsTrue() const {
  using A = internal::Address;
  using I = internal::Internals;
  A obj = internal::ValueHelper::ValueAsAddress(this);
  return I::is_identical(obj, I::StaticReadOnlyRoot::kTrueValue);
}
#endif  // V8_STATIC_ROOTS_BOOL

bool Value::IsFalse() const {}

#if V8_STATIC_ROOTS_BOOL
bool Value::QuickIsFalse() const {
  using A = internal::Address;
  using I = internal::Internals;
  A obj = internal::ValueHelper::ValueAsAddress(this);
  return I::is_identical(obj, I::StaticReadOnlyRoot::kFalseValue);
}
#endif  // V8_STATIC_ROOTS_BOOL

bool Value::IsString() const {}

bool Value::QuickIsString() const {}

bool TypecheckWitness::Matches(Local<Value> candidate) const {}

}  // namespace v8

#endif  // INCLUDE_V8_VALUE_H_