2008-09-30 Maciej Stachowiak <mjs@apple.com>
[WebKit.git] / JavaScriptCore / kjs / NodeInfo.h
1 /*
2  *  Copyright (C) 2007 Apple Inc. All rights reserved.
3  *
4  *  This library is free software; you can redistribute it and/or
5  *  modify it under the terms of the GNU Lesser General Public
6  *  License as published by the Free Software Foundation; either
7  *  version 2 of the License, or (at your option) any later version.
8  *
9  *  This library is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  *  Lesser General Public License for more details.
13  *
14  *  You should have received a copy of the GNU Lesser General Public
15  *  License along with this library; if not, write to the Free Software
16  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17  *
18  */
19
20 #ifndef NodeInfo_h
21 #define NodeInfo_h
22
23 #include "nodes.h"
24 #include "Parser.h"
25
26 namespace JSC {
27
28     typedef unsigned int FeatureInfo;
29
30     const FeatureInfo NoFeatures = 0;
31     const FeatureInfo EvalFeature = 1 << 0;
32     const FeatureInfo ClosureFeature = 1 << 1;
33     const FeatureInfo AssignFeature = 1 << 2;
34     const FeatureInfo ArgumentsFeature = 1 << 3;
35     const FeatureInfo WithFeature = 1 << 4;
36     const FeatureInfo CatchFeature = 1 << 5;
37     const FeatureInfo ThisFeature = 1 << 6;
38     const FeatureInfo AllFeatures = EvalFeature | ClosureFeature | AssignFeature | ArgumentsFeature | WithFeature | CatchFeature | ThisFeature;
39
40     template <typename T> struct NodeFeatureInfo {
41         T m_node;
42         FeatureInfo m_featureInfo;
43         int m_numConstants;
44     };
45
46     typedef NodeFeatureInfo<FuncDeclNode*> FuncDeclNodeInfo;    
47     typedef NodeFeatureInfo<FuncExprNode*> FuncExprNodeInfo;
48     typedef NodeFeatureInfo<ExpressionNode*> ExpressionNodeInfo;
49     typedef NodeFeatureInfo<ArgumentsNode*> ArgumentsNodeInfo;
50     typedef NodeFeatureInfo<ConstDeclNode*> ConstDeclNodeInfo;
51     typedef NodeFeatureInfo<PropertyNode*> PropertyNodeInfo;
52     typedef NodeFeatureInfo<PropertyList> PropertyListInfo;
53     typedef NodeFeatureInfo<ElementList> ElementListInfo;
54     typedef NodeFeatureInfo<ArgumentList> ArgumentListInfo;
55     
56     template <typename T> struct NodeDeclarationInfo {
57         T m_node;
58         ParserRefCountedData<DeclarationStacks::VarStack>* m_varDeclarations;
59         ParserRefCountedData<DeclarationStacks::FunctionStack>* m_funcDeclarations;
60         FeatureInfo m_featureInfo;
61         int m_numConstants;
62     };
63     
64     typedef NodeDeclarationInfo<StatementNode*> StatementNodeInfo;
65     typedef NodeDeclarationInfo<CaseBlockNode*> CaseBlockNodeInfo;
66     typedef NodeDeclarationInfo<CaseClauseNode*> CaseClauseNodeInfo;
67     typedef NodeDeclarationInfo<SourceElements*> SourceElementsInfo;
68     typedef NodeDeclarationInfo<ClauseList> ClauseListInfo;
69     typedef NodeDeclarationInfo<ExpressionNode*> VarDeclListInfo;
70     typedef NodeDeclarationInfo<ConstDeclList> ConstDeclListInfo;
71     typedef NodeDeclarationInfo<ParameterList> ParameterListInfo;
72
73 } // namespace JSC
74
75 #endif // NodeInfo_h