1// Copyright 2011 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_SNAPSHOT_NATIVES_H_
6#define V8_SNAPSHOT_NATIVES_H_
7
8#include "src/objects.h"
9#include "src/vector.h"
10
11namespace v8 { class StartupData; }  // Forward declaration.
12
13namespace v8 {
14namespace internal {
15
16enum NativeType {
17  CORE,
18  EXPERIMENTAL,
19  EXTRAS,
20  EXPERIMENTAL_EXTRAS,
21  D8,
22  TEST
23};
24
25// Extra handling for V8_EXPORT_PRIVATE in combination with USING_V8_SHARED
26// since definition of methods of classes marked as dllimport is not allowed.
27template <NativeType type>
28#ifdef USING_V8_SHARED
29class NativesCollection {
30#else
31class V8_EXPORT_PRIVATE NativesCollection {
32#endif  // USING_V8_SHARED
33
34 public:
35  // The following methods are implemented in js2c-generated code:
36
37  // Number of built-in scripts.
38  static int GetBuiltinsCount();
39  // Number of debugger implementation scripts.
40  static int GetDebuggerCount();
41
42  // These are used to access built-in scripts.  The debugger implementation
43  // scripts have an index in the interval [0, GetDebuggerCount()).  The
44  // non-debugger scripts have an index in the interval [GetDebuggerCount(),
45  // GetNativesCount()).
46  static int GetIndex(const char* name);
47  static Vector<const char> GetScriptSource(int index);
48  static Vector<const char> GetScriptName(int index);
49  static Vector<const char> GetScriptsSource();
50
51  // The following methods are implemented in natives-common.cc:
52
53  static FixedArray* GetSourceCache(Heap* heap);
54};
55
56typedef NativesCollection<CORE> Natives;
57typedef NativesCollection<EXPERIMENTAL> ExperimentalNatives;
58typedef NativesCollection<EXTRAS> ExtraNatives;
59typedef NativesCollection<EXPERIMENTAL_EXTRAS> ExperimentalExtraNatives;
60
61
62#ifdef V8_USE_EXTERNAL_STARTUP_DATA
63// Used for reading the natives at runtime. Implementation in natives-empty.cc
64void SetNativesFromFile(StartupData* natives_blob);
65void ReadNatives();
66void DisposeNatives();
67#endif
68
69}  // namespace internal
70}  // namespace v8
71
72#endif  // V8_SNAPSHOT_NATIVES_H_
73