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-06-02 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         3408577 : JSObject::asRegExp()
      55                 : {
      56         3408577 :     JS_ASSERT(isRegExp());
      57         3408577 :     return *static_cast<js::RegExpObject *>(this);
      58                 : }
      59                 : 
      60                 : namespace js {
      61                 : 
      62                 : inline RegExpShared *
      63         2281835 : RegExpObject::maybeShared() const
      64                 : {
      65         2281835 :     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         2241999 : RegExpObject::getShared(JSContext *cx, RegExpGuard *g)
      77                 : {
      78         2241999 :     if (RegExpShared *shared = maybeShared()) {
      79         2202163 :         g->init(*shared);
      80         2202163 :         return true;
      81                 :     }
      82           39836 :     return createShared(cx, g);
      83                 : }
      84                 : 
      85                 : inline void
      86          591000 : RegExpObject::setShared(JSContext *cx, RegExpShared &shared)
      87                 : {
      88          591000 :     shared.prepareForUse(cx);
      89          591000 :     JSObject::setPrivate(&shared);
      90          591000 : }
      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          610100 : RegExpObject::zeroLastIndex()
     106                 : {
     107          610100 :     setSlot(LAST_INDEX_SLOT, Int32Value(0));
     108          610100 : }
     109                 : 
     110                 : inline void
     111          599264 : RegExpObject::setSource(JSAtom *source)
     112                 : {
     113          599264 :     setSlot(SOURCE_SLOT, StringValue(source));
     114          599264 : }
     115                 : 
     116                 : inline void
     117          599264 : RegExpObject::setIgnoreCase(bool enabled)
     118                 : {
     119          599264 :     setSlot(IGNORE_CASE_FLAG_SLOT, BooleanValue(enabled));
     120          599264 : }
     121                 : 
     122                 : inline void
     123          599264 : RegExpObject::setGlobal(bool enabled)
     124                 : {
     125          599264 :     setSlot(GLOBAL_FLAG_SLOT, BooleanValue(enabled));
     126          599264 : }
     127                 : 
     128                 : inline void
     129          599264 : RegExpObject::setMultiline(bool enabled)
     130                 : {
     131          599264 :     setSlot(MULTILINE_FLAG_SLOT, BooleanValue(enabled));
     132          599264 : }
     133                 : 
     134                 : inline void
     135          599264 : RegExpObject::setSticky(bool enabled)
     136                 : {
     137          599264 :     setSlot(STICKY_FLAG_SLOT, BooleanValue(enabled));
     138          599264 : }
     139                 : 
     140                 : /* This function should be deleted once bad Android platforms phase out. See bug 604774. */
     141                 : inline bool
     142           58244 : detail::RegExpCode::isJITRuntimeEnabled(JSContext *cx)
     143                 : {
     144                 : #if defined(ANDROID) && defined(JS_METHODJIT)
     145                 :     return cx->methodJitEnabled;
     146                 : #else
     147           58244 :     return true;
     148                 : #endif
     149                 : }
     150                 : 
     151                 : inline bool
     152          543983 : RegExpToShared(JSContext *cx, JSObject &obj, RegExpGuard *g)
     153                 : {
     154          543983 :     JS_ASSERT(ObjectClassIs(obj, ESClass_RegExp, cx));
     155          543983 :     if (obj.isRegExp())
     156          543929 :         return obj.asRegExp().getShared(cx, g);
     157              54 :     return Proxy::regexp_toShared(cx, &obj, g);
     158                 : }
     159                 : 
     160                 : inline void
     161          591000 : RegExpShared::prepareForUse(JSContext *cx)
     162                 : {
     163          591000 :     gcNumberWhenUsed = cx->runtime->gcNumber;
     164          591000 : }
     165                 : 
     166                 : } /* namespace js */
     167                 : 
     168                 : #endif

Generated by: LCOV version 1.7