blob: 7ce7213edf9623d44f6e86c226013d09aaf0b91a [file] [log] [blame]
Ben Murdoch257744e2011-11-30 15:57:28 +00001// Copyright 2011 the V8 project authors. All rights reserved.
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Steve Blocka7e24c12009-10-30 11:49:00 +00004
5#ifndef V8_NATIVES_H_
6#define V8_NATIVES_H_
7
Ben Murdochb8a8cc12014-11-26 15:28:44 +00008#include "src/vector.h"
9
10namespace v8 { class StartupData; } // Forward declaration.
11
Steve Blocka7e24c12009-10-30 11:49:00 +000012namespace v8 {
13namespace internal {
14
Steve Blocka7e24c12009-10-30 11:49:00 +000015enum NativeType {
Ben Murdoch3fb3ca82011-12-02 17:19:32 +000016 CORE, EXPERIMENTAL, D8, TEST
Steve Blocka7e24c12009-10-30 11:49:00 +000017};
18
19template <NativeType type>
20class NativesCollection {
21 public:
22 // Number of built-in scripts.
23 static int GetBuiltinsCount();
Andrei Popescu31002712010-02-23 13:46:05 +000024 // Number of debugger implementation scripts.
25 static int GetDebuggerCount();
Steve Blocka7e24c12009-10-30 11:49:00 +000026
Andrei Popescu31002712010-02-23 13:46:05 +000027 // These are used to access built-in scripts. The debugger implementation
28 // scripts have an index in the interval [0, GetDebuggerCount()). The
29 // non-debugger scripts have an index in the interval [GetDebuggerCount(),
30 // GetNativesCount()).
Steve Blocka7e24c12009-10-30 11:49:00 +000031 static int GetIndex(const char* name);
Emily Bernierd0a1eb72015-03-24 16:35:39 -040032 static Vector<const char> GetScriptSource(int index);
Steve Blocka7e24c12009-10-30 11:49:00 +000033 static Vector<const char> GetScriptName(int index);
Emily Bernierd0a1eb72015-03-24 16:35:39 -040034 static Vector<const char> GetScriptsSource();
Steve Blocka7e24c12009-10-30 11:49:00 +000035};
36
37typedef NativesCollection<CORE> Natives;
Ben Murdoch257744e2011-11-30 15:57:28 +000038typedef NativesCollection<EXPERIMENTAL> ExperimentalNatives;
Steve Blocka7e24c12009-10-30 11:49:00 +000039
Ben Murdochb8a8cc12014-11-26 15:28:44 +000040#ifdef V8_USE_EXTERNAL_STARTUP_DATA
41// Used for reading the natives at runtime. Implementation in natives-empty.cc
42void SetNativesFromFile(StartupData* natives_blob);
43#endif
44
Steve Blocka7e24c12009-10-30 11:49:00 +000045} } // namespace v8::internal
46
47#endif // V8_NATIVES_H_