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

as2js  0.1.14
AlexScript to JavaScript
node_param.cpp
Go to the documentation of this file.
1 /* lib/node_param.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 
50 namespace as2js
51 {
52 
53 
54 /**********************************************************************/
55 /**********************************************************************/
56 /*** NODE PARAM *****************************************************/
57 /**********************************************************************/
58 /**********************************************************************/
59 
60 
81 void Node::set_param_size(size_t size)
82 {
84  {
85  throw exception_internal_error("INTERNAL ERROR: set_param_size() called with a node other than a NODE_PARAM_MATCH.");
86  }
87  if(f_param_depth.size() != 0)
88  {
89  throw exception_internal_error("INTERNAL ERROR: set_param_size() called twice.");
90  }
91  if(size == 0)
92  {
93  throw exception_internal_error("INTERNAL ERROR: set_param_size() was called with a size of zero.");
94  }
95  f_param_depth.resize(size);
96  f_param_index.resize(size);
97 }
98 
99 
109 size_t Node::get_param_size() const
110 {
111  return f_param_depth.size();
112 }
113 
114 
141 {
142  return f_param_depth.at(j);
143 }
144 
145 
166 void Node::set_param_depth(size_t j, depth_t depth)
167 {
168  if(j >= f_param_depth.size())
169  {
170  throw std::out_of_range("set_param_depth() called with an index out of range");
171  }
172  f_param_depth[j] = depth;
173 }
174 
175 
216 size_t Node::get_param_index(size_t idx) const
217 {
218  return f_param_index.at(idx);
219 }
220 
221 
241 void Node::set_param_index(size_t idx, size_t j)
242 {
243  if(idx >= f_param_index.size()
244  || j >= f_param_index.size())
245  {
246  throw std::out_of_range("set_param_index() called with an index out of range");
247  }
248  f_param_index[idx] = j;
249 }
250 
251 
252 
253 }
254 // namespace as2js
255 
256 // vim: ts=4 sw=4 et
void set_param_depth(size_t j, depth_t depth)
Set the depth of a parameter.
Definition: node_param.cpp:166
param_index_t f_param_index
Definition: node.h:614
depth_t get_param_depth(size_t j) const
Get the depth at the specified index.
Definition: node_param.cpp:140
param_depth_t f_param_depth
Definition: node.h:613
size_t get_param_index(size_t idx) const
Get the index of the parameter.
Definition: node_param.cpp:216
node_t f_type
Definition: node.h:594
ssize_t depth_t
Definition: node.h:74
size_t get_param_size() const
Return the size of the parameter index and depth vectors.
Definition: node_param.cpp:109
void set_param_size(size_t size)
Define the size of the parameter index and depth vectors.
Definition: node_param.cpp:81
void set_param_index(size_t idx, size_t j)
Set the parameter index.
Definition: node_param.cpp:241
The AlexScript to JavaScript namespace.
Definition: compiler.cpp:37

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