V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
natives-common.cc
1 // Copyright 2015 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 // The common functionality when building with internal or external natives.
6 
7 #include "src/heap/heap.h"
8 #include "src/objects-inl.h"
9 #include "src/snapshot/natives.h"
10 
11 namespace v8 {
12 namespace internal {
13 
14 NativesExternalStringResource::NativesExternalStringResource(NativeType type,
15  int index)
16  : type_(type), index_(index) {
17  Vector<const char> source;
18  DCHECK_LE(0, index);
19  switch (type_) {
20  case CORE:
21  DCHECK(index < Natives::GetBuiltinsCount());
22  source = Natives::GetScriptSource(index);
23  break;
24  case EXTRAS:
25  DCHECK(index < ExtraNatives::GetBuiltinsCount());
26  source = ExtraNatives::GetScriptSource(index);
27  break;
28  case EXPERIMENTAL_EXTRAS:
29  DCHECK(index < ExperimentalExtraNatives::GetBuiltinsCount());
30  source = ExperimentalExtraNatives::GetScriptSource(index);
31  break;
32  default:
33  UNREACHABLE();
34  }
35  data_ = source.start();
36  length_ = source.length();
37 }
38 
39 } // namespace internal
40 } // namespace v8
Definition: libplatform.h:13