as2js: /home/snapwebsites/snapcpp/contrib/as2js/lib/optimizer_tables.h Source File

as2js  0.1.14
AlexScript to JavaScript
optimizer_tables.h
Go to the documentation of this file.
1 #ifndef AS2JS_OPTIMIZER_TABLES_H
2 #define AS2JS_OPTIMIZER_TABLES_H
3 /* lib/optimizer_tables.h
4 
5 Copyright (c) 2005-2019 Made to Order Software Corp. All Rights Reserved
6 
8 
9 Permission is hereby granted, free of charge, to any
10 person obtaining a copy of this software and
11 associated documentation files (the "Software"), to
12 deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify,
14 merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom
16 the Software is furnished to do so, subject to the
17 following conditions:
18 
19 The above copyright notice and this permission notice
20 shall be included in all copies or substantial
21 portions of the Software.
22 
23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
24 ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
25 LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
26 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
27 EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
29 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
30 ARISING FROM, OUT OF OR IN CONNECTION WITH THE
31 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 SOFTWARE.
33 
34 */
35 
36 #include "as2js/lexer.h"
37 
63 namespace as2js
64 {
65 namespace optimizer_details
66 {
67 
68 
69 #define POINTER_AND_COUNT(name) name, sizeof(name) / sizeof(name[0])
70 #define NULL_POINTER_AND_COUNT() nullptr, 0
71 
72 
73 uint32_t const OPTIMIZATION_MATCH_FLAG_CHILDREN = 0x0001;
74 
75 
77 {
79  {
81  char const * f_string;
84  };
85 
86  uint8_t f_depth; // to build a tree
87  uint8_t f_match_flags; // zero by default
88 
91 
93 
94  Node::attribute_t const * f_attributes; // list of attributes, NODE_ATTR_max is used to separate each list
96 
97  Node::flag_t const * f_flags; // list of flags, NODE_FLAG_max is used to seperate each list
98  size_t f_flags_count;
99 };
100 
101 
103 {
129  //OPTIMIZATION_FUNCTION_SET_FLOAT,
139  //OPTIMIZATION_FUNCTION_TO_FLOAT64,
142  //OPTIMIZATION_FUNCTION_TO_STRING,
144 };
145 
146 
147 typedef uint16_t index_t;
148 
150 {
152  index_t f_indexes[6]; // number of indices used varies depending on the function
153 };
154 
155 
156 uint32_t const OPTIMIZATION_ENTRY_FLAG_UNSAFE_MATH = 0x0001;
157 uint32_t const OPTIMIZATION_ENTRY_FLAG_UNSAFE_OBJECT = 0x0002; // in most cases because the object may have its own operator(s)
158 
160 {
161  char const * f_name;
162  uint32_t f_flags;
163 
166 
169 };
170 
171 
173 {
176 };
177 
178 
180 {
183 };
184 
185 
186 
187 
188 bool optimize_tree(Node::pointer_t node);
189 bool match_tree(node_pointer_vector_t& node_array, Node::pointer_t node, optimization_match_t const *match, size_t match_size, uint8_t depth);
190 void apply_functions(node_pointer_vector_t& node_array, optimization_optimize_t const *optimize, size_t optimize_size);
191 
192 
193 }
194 // namespace optimizer_details
195 }
196 // namespace as2js
197 #endif
198 // #ifndef AS2JS_OPTIMIZER_TABLES_H
199 
200 // vim: ts=4 sw=4 et
double float64_type
Definition: float64.h:48
bool match_tree(node_pointer_vector_t &node_array, Node::pointer_t node, optimization_match_t const *match, size_t match_count, uint8_t depth)
Compare a node against an optimization tree.
optimization_literal_t const * f_with_value
optimization_optimize_t const * f_optimize
uint32_t const OPTIMIZATION_MATCH_FLAG_CHILDREN
bool optimize_tree(Node::pointer_t node)
Optimize a tree of nodes as much as possible.
std::vector< Node::pointer_t > node_pointer_vector_t
Definition: node.h:634
uint32_t const OPTIMIZATION_ENTRY_FLAG_UNSAFE_OBJECT
char const * f_name
uint32_t const OPTIMIZATION_ENTRY_FLAG_UNSAFE_MATH
size_t f_optimize_count
attribute_t
Definition: node.h:352
std::shared_ptr< Node > pointer_t
Definition: node.h:67
void apply_functions(node_pointer_vector_t &node_array, optimization_optimize_t const *optimize, size_t optimize_size)
Apply all the optimization functions.
uint32_t f_flags
The AlexScript to JavaScript namespace.
Definition: compiler.cpp:37
size_t f_match_count
int optimize(Node::pointer_t &node)
The as2js optimizer.
Definition: optimizer.cpp:153
optimization_match_t const * f_match
int64_t int64_type
Definition: int64.h:47

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