LCOV - app.info - js/src/vm/RegExpObject-inl.h

LCOV - code coverage report
| Current view: | directory - js/src/vm - RegExpObject-inl.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 45 | 45 | 100.0 %
| Date: | 2012-04-07 | Functions: | 14 | 14 | 100.0 %

           1                 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
           2                 :  * vim: set ts=8 sw=4 et tw=99 ft=cpp:
           3                 :  *
           4                 :  * ***** BEGIN LICENSE BLOCK *****
           5                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
           6                 :  *
           7                 :  * The contents of this file are subject to the Mozilla Public License Version
           8                 :  * 1.1 (the "License"); you may not use this file except in compliance with
           9                 :  * the License. You may obtain a copy of the License at
          10                 :  * http://www.mozilla.org/MPL/
          11                 :  *
          12                 :  * Software distributed under the License is distributed on an "AS IS" basis,
          13                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
          14                 :  * for the specific language governing rights and limitations under the
          15                 :  * License.
          16                 :  *
          17                 :  * The Original Code is Mozilla SpiderMonkey JavaScript code.
          18                 :  *
          19                 :  * The Initial Developer of the Original Code is
          20                 :  * the Mozilla Foundation.
          21                 :  * Portions created by the Initial Developer are Copyright (C) 2011
          22                 :  * the Initial Developer. All Rights Reserved.
          23                 :  *
          24                 :  * Contributor(s):
          25                 :  *  Chris Leary <cdleary@mozilla.com>
          26                 :  *
          27                 :  * Alternatively, the contents of this file may be used under the terms of
          28                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
          29                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          30                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          31                 :  * of those above. If you wish to allow use of your version of this file only
          32                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          33                 :  * use your version of this file under the terms of the MPL, indicate your
          34                 :  * decision by deleting the provisions above and replace them with the notice
          35                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          36                 :  * the provisions above, a recipient may use your version of this file under
          37                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          38                 :  *
          39                 :  * ***** END LICENSE BLOCK ***** */
          40                 :
          41                 : #ifndef RegExpObject_inl_h___
          42                 : #define RegExpObject_inl_h___
          43                 :
          44                 : #include "mozilla/Util.h"
          45                 :
          46                 : #include "RegExpObject.h"
          47                 : #include "RegExpStatics.h"
          48                 :
          49                 : #include "jsobjinlines.h"
          50                 : #include "jsstrinlines.h"
          51                 : #include "RegExpStatics-inl.h"
          52                 :
          53                 : inline js::RegExpObject &
          54         1913748 : JSObject::asRegExp()
          55                 : {
          56         1913748 :     JS_ASSERT(isRegExp());
          57         1913748 :     return *static_cast<js::RegExpObject *>(this);
          58                 : }
          59                 :
          60                 : namespace js {
          61                 :
          62                 : inline RegExpShared *
          63         1516670 : RegExpObject::maybeShared() const
          64                 : {
          65         1516670 :     return static_cast<RegExpShared *>(JSObject::getPrivate());
          66                 : }
          67                 :
          68                 : inline void
          69                 : RegExpObject::shared(RegExpGuard *g) const
          70                 : {
          71                 :     JS_ASSERT(maybeShared() != NULL);
          72                 :     g->init(*maybeShared());
          73                 : }
          74                 :
          75                 : inline bool
          76         1512272 : RegExpObject::getShared(JSContext *cx, RegExpGuard *g)
          77                 : {
          78         1512272 :     if (RegExpShared *shared = maybeShared()) {
          79         1507874 :         g->init(*shared);
          80         1507874 :         return true;
          81                 :     }
          82            4398 :     return createShared(cx, g);
          83                 : }
          84                 :
          85                 : inline void
          86          201069 : RegExpObject::setShared(JSContext *cx, RegExpShared &shared)
          87                 : {
          88          201069 :     shared.prepareForUse(cx);
          89          201069 :     JSObject::setPrivate(&shared);
          90          201069 : }
          91                 :
          92                 : inline void
          93                 : RegExpObject::setLastIndex(const Value &v)
          94                 : {
          95                 :     setSlot(LAST_INDEX_SLOT, v);
          96                 : }
          97                 :
          98                 : inline void
          99           33345 : RegExpObject::setLastIndex(double d)
         100                 : {
         101           33345 :     setSlot(LAST_INDEX_SLOT, NumberValue(d));
         102           33345 : }
         103                 :
         104                 : inline void
         105          214049 : RegExpObject::zeroLastIndex()
         106                 : {
         107          214049 :     setSlot(LAST_INDEX_SLOT, Int32Value(0));
         108          214049 : }
         109                 :
         110                 : inline void
         111          203213 : RegExpObject::setSource(JSAtom *source)
         112                 : {
         113          203213 :     setSlot(SOURCE_SLOT, StringValue(source));
         114          203213 : }
         115                 :
         116                 : inline void
         117          203213 : RegExpObject::setIgnoreCase(bool enabled)
         118                 : {
         119          203213 :     setSlot(IGNORE_CASE_FLAG_SLOT, BooleanValue(enabled));
         120          203213 : }
         121                 :
         122                 : inline void
         123          203213 : RegExpObject::setGlobal(bool enabled)
         124                 : {
         125          203213 :     setSlot(GLOBAL_FLAG_SLOT, BooleanValue(enabled));
         126          203213 : }
         127                 :
         128                 : inline void
         129          203213 : RegExpObject::setMultiline(bool enabled)
         130                 : {
         131          203213 :     setSlot(MULTILINE_FLAG_SLOT, BooleanValue(enabled));
         132          203213 : }
         133                 :
         134                 : inline void
         135          203213 : RegExpObject::setSticky(bool enabled)
         136                 : {
         137          203213 :     setSlot(STICKY_FLAG_SLOT, BooleanValue(enabled));
         138          203213 : }
         139                 :
         140                 : /* This function should be deleted once bad Android platforms phase out. See bug 604774. */
         141                 : inline bool
         142           24064 : detail::RegExpCode::isJITRuntimeEnabled(JSContext *cx)
         143                 : {
         144                 : #if defined(ANDROID) && defined(JS_METHODJIT)
         145                 :     return cx->methodJitEnabled;
         146                 : #else
         147           24064 :     return true;
         148                 : #endif
         149                 : }
         150                 :
         151                 : inline bool
         152          361594 : RegExpToShared(JSContext *cx, JSObject &obj, RegExpGuard *g)
         153                 : {
         154          361594 :     JS_ASSERT(ObjectClassIs(obj, ESClass_RegExp, cx));
         155          361594 :     if (obj.isRegExp())
         156          361540 :         return obj.asRegExp().getShared(cx, g);
         157              54 :     return Proxy::regexp_toShared(cx, &obj, g);
         158                 : }
         159                 :
         160                 : inline void
         161          201069 : RegExpShared::prepareForUse(JSContext *cx)
         162                 : {
         163          201069 :     gcNumberWhenUsed = cx->runtime->gcNumber;
         164          201069 : }
         165                 :
         166                 : } /* namespace js */
         167                 :
         168                 : #endif

Generated by: LCOV version 1.7