Index: src/d8.cc |
diff --git a/src/d8.cc b/src/d8.cc |
index 28ebfc05b9839327fb596ac491514e1b341fe1a9..39d09d42194f1c25142fdf70e45abc5ca8319997 100644 |
--- a/src/d8.cc |
+++ b/src/d8.cc |
@@ -1393,6 +1393,15 @@ Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) { |
String::NewFromUtf8(isolate, "readbuffer", NewStringType::kNormal) |
.ToLocalChecked(), |
FunctionTemplate::New(isolate, ReadBuffer)); |
+ Local<FunctionTemplate> experimental = |
+ FunctionTemplate::New(isolate, ExperimentalDoubleAdder); |
+ experimental->Set(isolate, "native_variant", |
+ External::New(isolate, reinterpret_cast<void*>( |
+ ExperimentalNativeDoubleAdder))); |
+ global_template->Set(String::NewFromUtf8(isolate, "experimentalDoubleAdder", |
+ NewStringType::kNormal) |
+ .ToLocalChecked(), |
+ experimental); |
global_template->Set( |
String::NewFromUtf8(isolate, "readline", NewStringType::kNormal) |
.ToLocalChecked(), |
@@ -1725,6 +1734,18 @@ void Shell::ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>& args) { |
args.GetReturnValue().Set(buffer); |
} |
+void Shell::ExperimentalDoubleAdder( |
+ const v8::FunctionCallbackInfo<v8::Value>& args) { |
+ DCHECK(sizeof(char) == sizeof(uint8_t)); // NOLINT |
+ Local<Number> a = Local<Number>::Cast(args[0]); |
+ Local<Number> b = Local<Number>::Cast(args[1]); |
+ Local<Number> ret = Number::New(args.GetIsolate(), a->Value() + b->Value()); |
+ args.GetReturnValue().Set(ret); |
+} |
+ |
+double Shell::ExperimentalNativeDoubleAdder(double a, double b) { |
+ return a + b; |
+} |
// Reads a file into a v8 string. |
Local<String> Shell::ReadFile(Isolate* isolate, const char* name) { |