LCOV - app.info - js/src/frontend/ParseNode-inl.h

LCOV - code coverage report
| Current view: | directory - js/src/frontend - ParseNode-inl.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 95 | 12 | 12.6 %
| Date: | 2012-04-07 | Functions: | 11 | 2 | 18.2 %

           1                 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
           2                 :  * vim: set ts=8 sw=4 et tw=99:
           3                 :  * ***** BEGIN LICENSE BLOCK *****
           4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
           5                 :  *
           6                 :  * The contents of this file are subject to the Mozilla Public License Version
           7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
           8                 :  * the License. You may obtain a copy of the License at
           9                 :  * http://www.mozilla.org/MPL/
          10                 :  *
          11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
          12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
          13                 :  * for the specific language governing rights and limitations under the
          14                 :  * License.
          15                 :  *
          16                 :  * The Original Code is Mozilla Communicator client code, released
          17                 :  * March 31, 1998.
          18                 :  *
          19                 :  * The Initial Developer of the Original Code is
          20                 :  * Netscape Communications Corporation.
          21                 :  * Portions created by the Initial Developer are Copyright (C) 1998-2011
          22                 :  * the Initial Developer. All Rights Reserved.
          23                 :  *
          24                 :  * Contributor(s):
          25                 :  *
          26                 :  * Alternatively, the contents of this file may be used under the terms of
          27                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
          28                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          29                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          30                 :  * of those above. If you wish to allow use of your version of this file only
          31                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          32                 :  * use your version of this file under the terms of the MPL, indicate your
          33                 :  * decision by deleting the provisions above and replace them with the notice
          34                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          35                 :  * the provisions above, a recipient may use your version of this file under
          36                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          37                 :  *
          38                 :  * ***** END LICENSE BLOCK ***** */
          39                 :
          40                 : #ifndef ParseNode_inl_h__
          41                 : #define ParseNode_inl_h__
          42                 :
          43                 : #include "frontend/ParseNode.h"
          44                 : #include "frontend/BytecodeEmitter.h"
          45                 : #include "frontend/TokenStream.h"
          46                 :
          47                 : namespace js {
          48                 :
          49                 : inline bool
          50           83113 : ParseNode::isConstant()
          51                 : {
          52           83113 :     switch (pn_type) {
          53                 :       case PNK_NUMBER:
          54                 :       case PNK_STRING:
          55                 :       case PNK_NULL:
          56                 :       case PNK_FALSE:
          57                 :       case PNK_TRUE:
          58           44943 :         return true;
          59                 :       case PNK_RB:
          60                 :       case PNK_RC:
          61            9054 :         return isOp(JSOP_NEWINIT) && !(pn_xflags & PNX_NONCONST);
          62                 :       default:
          63           29116 :         return false;
          64                 :     }
          65                 : }
          66                 :
          67                 : #ifdef DEBUG
          68                 : inline void
          69               0 : IndentNewLine(int indent)
          70                 : {
          71               0 :     fputc('\n', stderr);
          72               0 :     for (int i = 0; i < indent; ++i)
          73               0 :         fputc(' ', stderr);
          74               0 : }
          75                 :
          76                 : inline void
          77               0 : ParseNode::dump(int indent)
          78                 : {
          79               0 :     switch (pn_arity) {
          80                 :       case PN_NULLARY:
          81               0 :         ((NullaryNode *) this)->dump();
          82               0 :         break;
          83                 :       case PN_UNARY:
          84               0 :         ((UnaryNode *) this)->dump(indent);
          85               0 :         break;
          86                 :       case PN_BINARY:
          87               0 :         ((BinaryNode *) this)->dump(indent);
          88               0 :         break;
          89                 :       case PN_TERNARY:
          90               0 :         ((TernaryNode *) this)->dump(indent);
          91               0 :         break;
          92                 :       case PN_FUNC:
          93               0 :         ((FunctionNode *) this)->dump(indent);
          94               0 :         break;
          95                 :       case PN_LIST:
          96               0 :         ((ListNode *) this)->dump(indent);
          97               0 :         break;
          98                 :       case PN_NAME:
          99               0 :         ((NameNode *) this)->dump(indent);
         100               0 :         break;
         101                 :       default:
         102               0 :         fprintf(stderr, "?");
         103               0 :         break;
         104                 :     }
         105               0 : }
         106                 :
         107                 : inline void
         108               0 : NullaryNode::dump()
         109                 : {
         110               0 :     fprintf(stderr, "(%s)", js_CodeName[getOp()]);
         111               0 : }
         112                 :
         113                 : inline void
         114               0 : UnaryNode::dump(int indent)
         115                 : {
         116               0 :     const char *name = js_CodeName[getOp()];
         117               0 :     fprintf(stderr, "(%s ", name);
         118               0 :     indent += strlen(name) + 2;
         119               0 :     DumpParseTree(pn_kid, indent);
         120               0 :     fprintf(stderr, ")");
         121               0 : }
         122                 :
         123                 : inline void
         124               0 : BinaryNode::dump(int indent)
         125                 : {
         126               0 :     const char *name = js_CodeName[getOp()];
         127               0 :     fprintf(stderr, "(%s ", name);
         128               0 :     indent += strlen(name) + 2;
         129               0 :     DumpParseTree(pn_left, indent);
         130               0 :     IndentNewLine(indent);
         131               0 :     DumpParseTree(pn_right, indent);
         132               0 :     fprintf(stderr, ")");
         133               0 : }
         134                 :
         135                 : inline void
         136               0 : TernaryNode::dump(int indent)
         137                 : {
         138               0 :     const char *name = js_CodeName[getOp()];
         139               0 :     fprintf(stderr, "(%s ", name);
         140               0 :     indent += strlen(name) + 2;
         141               0 :     DumpParseTree(pn_kid1, indent);
         142               0 :     IndentNewLine(indent);
         143               0 :     DumpParseTree(pn_kid2, indent);
         144               0 :     IndentNewLine(indent);
         145               0 :     DumpParseTree(pn_kid3, indent);
         146               0 :     fprintf(stderr, ")");
         147               0 : }
         148                 :
         149                 : inline void
         150               0 : FunctionNode::dump(int indent)
         151                 : {
         152               0 :     const char *name = js_CodeName[getOp()];
         153               0 :     fprintf(stderr, "(%s ", name);
         154               0 :     indent += strlen(name) + 2;
         155               0 :     DumpParseTree(pn_body, indent);
         156               0 :     fprintf(stderr, ")");
         157               0 : }
         158                 :
         159                 : inline void
         160               0 : ListNode::dump(int indent)
         161                 : {
         162               0 :     const char *name = js_CodeName[getOp()];
         163               0 :     fprintf(stderr, "(%s ", name);
         164               0 :     if (pn_head != NULL) {
         165               0 :         indent += strlen(name) + 2;
         166               0 :         DumpParseTree(pn_head, indent);
         167               0 :         ParseNode *pn = pn_head->pn_next;
         168               0 :         while (pn != NULL) {
         169               0 :             IndentNewLine(indent);
         170               0 :             DumpParseTree(pn, indent);
         171               0 :             pn = pn->pn_next;
         172                 :         }
         173                 :     }
         174               0 :     fprintf(stderr, ")");
         175               0 : }
         176                 :
         177                 : inline void
         178               0 : NameNode::dump(int indent)
         179                 : {
         180               0 :     const char *name = js_CodeName[getOp()];
         181               0 :     if (isUsed())
         182               0 :         fprintf(stderr, "(%s)", name);
         183                 :     else {
         184               0 :         fprintf(stderr, "(%s ", name);
         185               0 :         indent += strlen(name) + 2;
         186               0 :         DumpParseTree(expr(), indent);
         187               0 :         fprintf(stderr, ")");
         188                 :     }
         189               0 : }
         190                 : #endif
         191                 :
         192                 : inline void
         193         3556624 : NameNode::initCommon(TreeContext *tc)
         194                 : {
         195         3556624 :     pn_expr = NULL;
         196         3556624 :     pn_cookie.makeFree();
         197         3556624 :     pn_dflags = (!tc->topStmt || tc->topStmt->type == STMT_BLOCK)
         198                 :                 ? PND_BLOCKCHILD
         199         3556624 :                 : 0;
         200         3556624 :     pn_blockid = tc->blockid();
         201         3556624 : }
         202                 :
         203                 : } /* namespace js */
         204                 :
         205                 : #endif /* ParseNode_inl_h__ */

Generated by: LCOV version 1.7