Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 1 | // Copyright 2011 the V8 project authors. All rights reserved. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 4 | |
| 5 | #ifndef V8_NATIVES_H_ |
| 6 | #define V8_NATIVES_H_ |
| 7 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 8 | #include "src/vector.h" |
| 9 | |
| 10 | namespace v8 { class StartupData; } // Forward declaration. |
| 11 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 12 | namespace v8 { |
| 13 | namespace internal { |
| 14 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 15 | enum NativeType { |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 16 | CORE, EXPERIMENTAL, D8, TEST |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 17 | }; |
| 18 | |
| 19 | template <NativeType type> |
| 20 | class NativesCollection { |
| 21 | public: |
| 22 | // Number of built-in scripts. |
| 23 | static int GetBuiltinsCount(); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 24 | // Number of debugger implementation scripts. |
| 25 | static int GetDebuggerCount(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 26 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 27 | // 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 Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 31 | static int GetIndex(const char* name); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 32 | static Vector<const char> GetScriptSource(int index); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 33 | static Vector<const char> GetScriptName(int index); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 34 | static Vector<const char> GetScriptsSource(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | typedef NativesCollection<CORE> Natives; |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 38 | typedef NativesCollection<EXPERIMENTAL> ExperimentalNatives; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 39 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 40 | #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
| 41 | // Used for reading the natives at runtime. Implementation in natives-empty.cc |
| 42 | void SetNativesFromFile(StartupData* natives_blob); |
| 43 | #endif |
| 44 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 45 | } } // namespace v8::internal |
| 46 | |
| 47 | #endif // V8_NATIVES_H_ |