Home | History | Annotate | Download | only in extensions
      1 // Copyright 2013 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 #include "src/extensions/trigger-failure-extension.h"
      6 
      7 #include "src/base/logging.h"
      8 #include "src/checks.h"
      9 
     10 namespace v8 {
     11 namespace internal {
     12 
     13 
     14 const char* const TriggerFailureExtension::kSource =
     15     "native function triggerCheckFalse();"
     16     "native function triggerAssertFalse();"
     17     "native function triggerSlowAssertFalse();";
     18 
     19 
     20 v8::Local<v8::FunctionTemplate>
     21 TriggerFailureExtension::GetNativeFunctionTemplate(v8::Isolate* isolate,
     22                                                    v8::Local<v8::String> str) {
     23   if (strcmp(*v8::String::Utf8Value(str), "triggerCheckFalse") == 0) {
     24     return v8::FunctionTemplate::New(
     25         isolate,
     26         TriggerFailureExtension::TriggerCheckFalse);
     27   } else if (strcmp(*v8::String::Utf8Value(str), "triggerAssertFalse") == 0) {
     28     return v8::FunctionTemplate::New(
     29         isolate,
     30         TriggerFailureExtension::TriggerAssertFalse);
     31   } else {
     32     CHECK_EQ(0, strcmp(*v8::String::Utf8Value(str), "triggerSlowAssertFalse"));
     33     return v8::FunctionTemplate::New(
     34         isolate,
     35         TriggerFailureExtension::TriggerSlowAssertFalse);
     36   }
     37 }
     38 
     39 
     40 void TriggerFailureExtension::TriggerCheckFalse(
     41     const v8::FunctionCallbackInfo<v8::Value>& args) {
     42   CHECK(false);
     43 }
     44 
     45 
     46 void TriggerFailureExtension::TriggerAssertFalse(
     47     const v8::FunctionCallbackInfo<v8::Value>& args) {
     48   DCHECK(false);
     49 }
     50 
     51 
     52 void TriggerFailureExtension::TriggerSlowAssertFalse(
     53     const v8::FunctionCallbackInfo<v8::Value>& args) {
     54   SLOW_DCHECK(false);
     55 }
     56 
     57 }  // namespace internal
     58 }  // namespace v8
     59