LCOV - code coverage report
Current view: directory - content/xslt/src/xpath - txBooleanExpr.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 29 0 0.0 %
Date: 2012-06-02 Functions: 6 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is TransforMiiX XSLT processor code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * The MITRE Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1999
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Keith Visco <kvisco@ziplink.net> (Original Author)
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : 
      40                 : /**
      41                 :  * Represents a BooleanExpr, a binary expression that
      42                 :  * performs a boolean operation between its lvalue and rvalue.
      43                 : **/
      44                 : 
      45                 : #include "txExpr.h"
      46                 : #include "txIXPathContext.h"
      47                 : 
      48                 : /**
      49                 :  * Evaluates this Expr based on the given context node and processor state
      50                 :  * @param context the context node for evaluation of this Expr
      51                 :  * @param ps the ContextState containing the stack information needed
      52                 :  * for evaluation
      53                 :  * @return the result of the evaluation
      54                 : **/
      55                 : nsresult
      56               0 : BooleanExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
      57                 : {
      58               0 :     *aResult = nsnull;
      59                 : 
      60                 :     bool lval;
      61               0 :     nsresult rv = leftExpr->evaluateToBool(aContext, lval);
      62               0 :     NS_ENSURE_SUCCESS(rv, rv);
      63                 :     
      64                 :     // check for early decision
      65               0 :     if (op == OR && lval) {
      66               0 :         aContext->recycler()->getBoolResult(true, aResult);
      67                 :         
      68               0 :         return NS_OK;
      69                 :     }
      70               0 :     if (op == AND && !lval) {
      71               0 :         aContext->recycler()->getBoolResult(false, aResult);
      72                 : 
      73               0 :         return NS_OK;
      74                 :     }
      75                 : 
      76                 :     bool rval;
      77               0 :     rv = rightExpr->evaluateToBool(aContext, rval);
      78               0 :     NS_ENSURE_SUCCESS(rv, rv);
      79                 : 
      80                 :     // just use rval, since we already checked lval
      81               0 :     aContext->recycler()->getBoolResult(rval, aResult);
      82                 : 
      83               0 :     return NS_OK;
      84                 : } //-- evaluate
      85                 : 
      86               0 : TX_IMPL_EXPR_STUBS_2(BooleanExpr, BOOLEAN_RESULT, leftExpr, rightExpr)
      87                 : 
      88                 : bool
      89               0 : BooleanExpr::isSensitiveTo(ContextSensitivity aContext)
      90                 : {
      91               0 :     return leftExpr->isSensitiveTo(aContext) ||
      92               0 :            rightExpr->isSensitiveTo(aContext);
      93                 : }
      94                 : 
      95                 : #ifdef TX_TO_STRING
      96                 : void
      97               0 : BooleanExpr::toString(nsAString& str)
      98                 : {
      99               0 :     if ( leftExpr ) leftExpr->toString(str);
     100               0 :     else str.AppendLiteral("null");
     101                 : 
     102               0 :     switch ( op ) {
     103                 :         case OR:
     104               0 :             str.AppendLiteral(" or ");
     105               0 :             break;
     106                 :         default:
     107               0 :             str.AppendLiteral(" and ");
     108               0 :             break;
     109                 :     }
     110               0 :     if ( rightExpr ) rightExpr->toString(str);
     111               0 :     else str.AppendLiteral("null");
     112                 : 
     113               0 : }
     114                 : #endif

Generated by: LCOV version 1.7