as2js: /home/snapwebsites/snapcpp/contrib/as2js/lib/node_flag.cpp Source File

as2js  0.1.14
AlexScript to JavaScript
node_flag.cpp
Go to the documentation of this file.
1 /* lib/node_flag.cpp
2 
3 Copyright (c) 2005-2019 Made to Order Software Corp. All Rights Reserved
4 
6 
7 Permission is hereby granted, free of charge, to any
8 person obtaining a copy of this software and
9 associated documentation files (the "Software"), to
10 deal in the Software without restriction, including
11 without limitation the rights to use, copy, modify,
12 merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom
14 the Software is furnished to do so, subject to the
15 following conditions:
16 
17 The above copyright notice and this permission notice
18 shall be included in all copies or substantial
19 portions of the Software.
20 
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
22 ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
23 LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
24 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
25 EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
27 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
28 ARISING FROM, OUT OF OR IN CONNECTION WITH THE
29 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 SOFTWARE.
31 
32 */
33 
34 #include "as2js/node.h"
35 
36 #include "as2js/exceptions.h"
37 
38 
67 namespace as2js
68 {
69 
70 
71 
72 /**********************************************************************/
73 /**********************************************************************/
74 /*** NODE FLAG ******************************************************/
75 /**********************************************************************/
76 /**********************************************************************/
77 
78 
101 bool Node::get_flag(flag_t f) const
102 {
103  verify_flag(f);
104  return f_flags[static_cast<size_t>(f)];
105 }
106 
107 
122 void Node::set_flag(flag_t f, bool v)
123 {
124  verify_flag(f);
125  f_flags[static_cast<size_t>(f)] = v;
126 }
127 
128 
151 {
152  switch(f)
153  {
156  {
157  return;
158  }
159  break;
160 
163  {
164  return;
165  }
166  break;
167 
171  {
172  return;
173  }
174  break;
175 
179  if(f_type == node_t::NODE_FOR)
180  {
181  return;
182  }
183  break;
184 
193  {
194  return;
195  }
196  break;
197 
204  {
205  return;
206  }
207  break;
208 
211  {
212  return;
213  }
214  break;
215 
219  {
220  return;
221  }
222  break;
223 
226  {
227  return;
228  }
229  break;
230 
231  case flag_t::NODE_PARAM_FLAG_CATCH: // a parameter defined in a catch()
236  case flag_t::NODE_PARAM_FLAG_PARAMREF: // referenced from another parameter
237  case flag_t::NODE_PARAM_FLAG_REFERENCED: // referenced from a parameter or a variable
242  {
243  return;
244  }
245  break;
246 
247  case flag_t::NODE_SWITCH_FLAG_DEFAULT: // we found a 'default:' label in that switch
249  {
250  return;
251  }
252  break;
253 
254  case flag_t::NODE_TYPE_FLAG_MODULO: // type ... as mod ...;
256  {
257  return;
258  }
259  break;
260 
266  case flag_t::NODE_VARIABLE_FLAG_ENUM: // there is a NODE_SET and it somehow needs to be copied
267  case flag_t::NODE_VARIABLE_FLAG_COMPILED: // Expression() was called on the NODE_SET
268  case flag_t::NODE_VARIABLE_FLAG_INUSE: // this variable was referenced
269  case flag_t::NODE_VARIABLE_FLAG_ATTRS: // currently being read for attributes (to avoid loops)
270  case flag_t::NODE_VARIABLE_FLAG_DEFINED: // was already parsed
271  case flag_t::NODE_VARIABLE_FLAG_DEFINING: // currently defining, can't read
272  case flag_t::NODE_VARIABLE_FLAG_TOADD: // to be added in the directive list
275  {
276  return;
277  }
278  break;
279 
281  break;
282 
283  // default: -- do not define so the compiler can tell us if
284  // an enumeration is missing in this case
285  }
286 
287  // since we do not use 'default' completely invalid values are not caught
288  // in the switch...
289  throw exception_internal_error("node_flag.cpp: Node::verify_flag(): flag (" + std::to_string(static_cast<int>(f))
290  + ") / type missmatch (" + std::to_string(static_cast<int>(static_cast<node_t>(f_type))) + ")");
291 }
292 
293 
310 {
311  return f_flags == s;
312 }
313 
314 
315 }
316 // namespace as2js
317 
318 // vim: ts=4 sw=4 et
void set_flag(flag_t f, bool v)
Set a flag.
Definition: node_flag.cpp:122
node_t f_type
Definition: node.h:594
flag_set_t f_flags
Definition: node.h:596
void verify_flag(flag_t f) const
Verify that f corresponds to the node type.
Definition: node_flag.cpp:150
std::bitset< static_cast< size_t >flag_t::NODE_FLAG_max)> flag_set_t
Definition: node.h:345
bool compare_all_flags(flag_set_t const &s) const
Compare a set of flags with the current flags of this node.
Definition: node_flag.cpp:309
The AlexScript to JavaScript namespace.
Definition: compiler.cpp:37
bool get_flag(flag_t f) const
Get the current status of a flag.
Definition: node_flag.cpp:101

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.

Syndicate content

Snap! Websites
An Open Source CMS System in C++

Contact Us Directly