LCOV - code coverage report
Current view: top level - src/objects - js-regexp-inl.h (source / functions) Hit Total Coverage
Test: app.info Lines: 15 16 93.8 %
Date: 2017-10-20 Functions: 8 9 88.9 %

          Line data    Source code
       1             : // Copyright 2017 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             : #ifndef V8_OBJECTS_JS_REGEXP_INL_H_
       6             : #define V8_OBJECTS_JS_REGEXP_INL_H_
       7             : 
       8             : #include "src/objects/js-regexp.h"
       9             : 
      10             : #include "src/objects/string.h"
      11             : 
      12             : // Has to be the last include (doesn't have include guards):
      13             : #include "src/objects/object-macros.h"
      14             : 
      15             : namespace v8 {
      16             : namespace internal {
      17             : 
      18    11504161 : TYPE_CHECKER(JSRegExp, JS_REGEXP_TYPE)
      19             : 
      20             : CAST_ACCESSOR(JSRegExp)
      21             : 
      22    10243792 : ACCESSORS(JSRegExp, data, Object, kDataOffset)
      23     2579843 : ACCESSORS(JSRegExp, flags, Object, kFlagsOffset)
      24     2579883 : ACCESSORS(JSRegExp, source, Object, kSourceOffset)
      25       12271 : ACCESSORS(JSRegExp, last_index, Object, kLastIndexOffset)
      26             : 
      27     2340330 : JSRegExp::Type JSRegExp::TypeTag() {
      28             :   Object* data = this->data();
      29     2340330 :   if (data->IsUndefined(GetIsolate())) return JSRegExp::NOT_COMPILED;
      30             :   Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex));
      31     2340330 :   return static_cast<JSRegExp::Type>(smi->value());
      32             : }
      33             : 
      34      257588 : int JSRegExp::CaptureCount() {
      35      257588 :   switch (TypeTag()) {
      36             :     case ATOM:
      37             :       return 0;
      38             :     case IRREGEXP:
      39       18016 :       return Smi::ToInt(DataAt(kIrregexpCaptureCountIndex));
      40             :     default:
      41           0 :       UNREACHABLE();
      42             :   }
      43             : }
      44             : 
      45      104667 : JSRegExp::Flags JSRegExp::GetFlags() {
      46             :   DCHECK(this->data()->IsFixedArray());
      47             :   Object* data = this->data();
      48             :   Smi* smi = Smi::cast(FixedArray::cast(data)->get(kFlagsIndex));
      49      104667 :   return Flags(smi->value());
      50             : }
      51             : 
      52             : String* JSRegExp::Pattern() {
      53             :   DCHECK(this->data()->IsFixedArray());
      54             :   Object* data = this->data();
      55             :   String* pattern = String::cast(FixedArray::cast(data)->get(kSourceIndex));
      56             :   return pattern;
      57             : }
      58             : 
      59         113 : Object* JSRegExp::CaptureNameMap() {
      60             :   DCHECK(this->data()->IsFixedArray());
      61             :   DCHECK_EQ(TypeTag(), IRREGEXP);
      62             :   Object* value = DataAt(kIrregexpCaptureNameMapIndex);
      63             :   DCHECK_NE(value, Smi::FromInt(JSRegExp::kUninitializedValue));
      64         113 :   return value;
      65             : }
      66             : 
      67             : Object* JSRegExp::DataAt(int index) {
      68             :   DCHECK(TypeTag() != NOT_COMPILED);
      69             :   return FixedArray::cast(data())->get(index);
      70             : }
      71             : 
      72             : void JSRegExp::SetDataAt(int index, Object* value) {
      73             :   DCHECK(TypeTag() != NOT_COMPILED);
      74             :   DCHECK_GE(index,
      75             :             kDataIndex);  // Only implementation data can be set this way.
      76             :   FixedArray::cast(data())->set(index, value);
      77             : }
      78             : 
      79             : }  // namespace internal
      80             : }  // namespace v8
      81             : 
      82             : #include "src/objects/object-macros-undef.h"
      83             : 
      84             : #endif  // V8_OBJECTS_JS_REGEXP_INL_H_

Generated by: LCOV version 1.10