OpenVAS Scanner  7.0.1~git
nasl_tree.h
Go to the documentation of this file.
1 /* Based on work Copyright (C) 2002 - 2003 Michel Arboi and Renaud Deraison
2  *
3  * SPDX-License-Identifier: GPL-2.0-only
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * version 2 as published by the Free Software Foundation.
8  *
9  * This program 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
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef NASLTREE_H_INCLUDED
20 #define NASLTREE_H_INCLUDED
21 
23 {
25  NODE_IF_ELSE, /* [0] = cond, [1] = if_block, [2] = else_block */
26  NODE_INSTR_L, /* Block. [0] = first instr, [1] = tail */
27  NODE_FOR, /* [0] = start expr, [1] = cond, [2] = end_expr, [3] = block */
28  NODE_WHILE, /* [0] = cond, [1] = block */
31  NODE_REPEATED, /* [0] = func call, [1] = repeat nb */
32  NODE_FUN_DEF, /* [0] = argdecl, [1] = block */
33  NODE_FUN_CALL, /* [0] = script_infos */
34  NODE_DECL, /* [0] = next arg in list */
35  NODE_ARG, /* val = name can be NULL, [0] = val, [1] = next arg */
36  NODE_RETURN, /* ret val */
39 
40  NODE_ARRAY_EL, /* val = array name, [0] = index */
41  NODE_AFF, /* [0] = lvalue, [1] = rvalue */
42  NODE_VAR, /* val = variable name */
43  NODE_LOCAL, /* [0] = argdecl */
45 
51 
55 
59 
67 
77 
82 
89 
91  CONST_STR, /* "impure" string */
92 
93  CONST_DATA, /* binary data / "pure" string */
94  CONST_REGEX, /* Compiled regex */
95 
96  ARRAY_ELEM, /* val = char index or NULL if integer,
97  * [0] = value, [1] = next element */
98  /* For exec only */
102 };
103 
104 typedef struct TC
105 {
106  short type;
107  short line_nb;
108  short ref_count; /* Cell is freed when count reaches zero */
109  int size;
110  union
111  {
112  char *str_val;
113  long int i_val;
114  void *ref_val; /* internal reference */
115  } x;
116  struct TC *link[4];
117 } tree_cell;
118 
119 #define FAKE_CELL ((void *) 1)
120 #define EXIT_CELL ((void *) 2)
121 
122 tree_cell *
123 alloc_expr_cell (int, int, tree_cell *, tree_cell *);
124 tree_cell *
125 alloc_RE_cell (int, int, tree_cell *, char *);
126 tree_cell *
127 alloc_typed_cell (int);
128 int
129 nasl_is_leaf (const tree_cell *);
130 char *
131 get_line_nb (const tree_cell *);
132 tree_cell *
133 dup_cell (const tree_cell *);
134 void
135 nasl_dump_tree (const tree_cell *);
136 void
137 ref_cell (tree_cell *);
138 void
140 const char *
141 nasl_type_name (int);
142 int
143 cell_type (const tree_cell *);
144 
145 char *
146 dump_cell_val (const tree_cell *);
147 
148 #endif
NODE_LOCAL
@ NODE_LOCAL
Definition: nasl_tree.h:43
EXPR_AND
@ EXPR_AND
Definition: nasl_tree.h:56
deref_cell
void deref_cell(tree_cell *)
Definition: nasl_tree.c:192
EXPR_BIT_XOR
@ EXPR_BIT_XOR
Definition: nasl_tree.h:70
CONST_DATA
@ CONST_DATA
Definition: nasl_tree.h:93
nasl_type_name
const char * nasl_type_name(int)
Definition: nasl_tree.c:357
alloc_typed_cell
tree_cell * alloc_typed_cell(int)
Definition: nasl_tree.c:40
NODE_MINUS_EQ
@ NODE_MINUS_EQ
Definition: nasl_tree.h:47
NODE_WHILE
@ NODE_WHILE
Definition: nasl_tree.h:28
NODE_DECL
@ NODE_DECL
Definition: nasl_tree.h:34
NODE_RETURN
@ NODE_RETURN
Definition: nasl_tree.h:36
TC::str_val
char * str_val
Definition: nasl_tree.h:112
NODE_GLOBAL
@ NODE_GLOBAL
Definition: nasl_tree.h:44
NODE_AFF
@ NODE_AFF
Definition: nasl_tree.h:41
NODE_DIV_EQ
@ NODE_DIV_EQ
Definition: nasl_tree.h:49
NODE_L_SHIFT_EQ
@ NODE_L_SHIFT_EQ
Definition: nasl_tree.h:52
EXPR_R_USHIFT
@ EXPR_R_USHIFT
Definition: nasl_tree.h:76
CONST_STR
@ CONST_STR
Definition: nasl_tree.h:91
dup_cell
tree_cell * dup_cell(const tree_cell *)
Definition: nasl_tree.c:86
NODE_REPEAT_UNTIL
@ NODE_REPEAT_UNTIL
Definition: nasl_tree.h:30
nasl_dump_tree
void nasl_dump_tree(const tree_cell *)
Definition: nasl_tree.c:377
NODE_ARRAY_EL
@ NODE_ARRAY_EL
Definition: nasl_tree.h:40
DYN_ARRAY
@ DYN_ARRAY
Definition: nasl_tree.h:101
get_line_nb
char * get_line_nb(const tree_cell *)
Definition: nasl_tree.c:390
nasl_is_leaf
int nasl_is_leaf(const tree_cell *)
Definition: nasl_tree.c:400
TC::x
union TC::@2 x
EXPR_BIT_NOT
@ EXPR_BIT_NOT
Definition: nasl_tree.h:71
dump_cell_val
char * dump_cell_val(const tree_cell *)
Definition: nasl_tree.c:245
NODE_FUN_DEF
@ NODE_FUN_DEF
Definition: nasl_tree.h:32
EXPR_U_MINUS
@ EXPR_U_MINUS
Definition: nasl_tree.h:62
NODE_R_SHIFT_EQ
@ NODE_R_SHIFT_EQ
Definition: nasl_tree.h:53
EXPR_MODULO
@ EXPR_MODULO
Definition: nasl_tree.h:65
NODE_FUN_CALL
@ NODE_FUN_CALL
Definition: nasl_tree.h:33
COMP_LE
@ COMP_LE
Definition: nasl_tree.h:84
ARRAY_ELEM
@ ARRAY_ELEM
Definition: nasl_tree.h:96
NODE_FOREACH
@ NODE_FOREACH
Definition: nasl_tree.h:29
EXPR_DECR
@ EXPR_DECR
Definition: nasl_tree.h:73
NODE_VAR
@ NODE_VAR
Definition: nasl_tree.h:42
TC::size
int size
Definition: nasl_tree.h:109
EXPR_PLUS
@ EXPR_PLUS
Definition: nasl_tree.h:60
NODE_INSTR_L
@ NODE_INSTR_L
Definition: nasl_tree.h:26
alloc_expr_cell
tree_cell * alloc_expr_cell(int, int, tree_cell *, tree_cell *)
Definition: nasl_tree.c:74
cell_type
int cell_type(const tree_cell *)
Definition: nasl_tree.c:418
TC::line_nb
short line_nb
Definition: nasl_tree.h:107
NODE_REPEATED
@ NODE_REPEATED
Definition: nasl_tree.h:31
EXPR_R_SHIFT
@ EXPR_R_SHIFT
Definition: nasl_tree.h:75
EXPR_NOT
@ EXPR_NOT
Definition: nasl_tree.h:58
EXPR_DIV
@ EXPR_DIV
Definition: nasl_tree.h:64
TC::ref_val
void * ref_val
Definition: nasl_tree.h:114
TC::ref_count
short ref_count
Definition: nasl_tree.h:108
COMP_RE_NOMATCH
@ COMP_RE_NOMATCH
Definition: nasl_tree.h:81
CONST_REGEX
@ CONST_REGEX
Definition: nasl_tree.h:94
EXPR_L_SHIFT
@ EXPR_L_SHIFT
Definition: nasl_tree.h:74
EXPR_BIT_AND
@ EXPR_BIT_AND
Definition: nasl_tree.h:68
TC
Definition: nasl_tree.h:104
COMP_MATCH
@ COMP_MATCH
Definition: nasl_tree.h:78
TC::type
short type
Definition: nasl_tree.h:106
TC::link
struct TC * link[4]
Definition: nasl_tree.h:116
NODE_R_USHIFT_EQ
@ NODE_R_USHIFT_EQ
Definition: nasl_tree.h:54
tree_cell
struct TC tree_cell
COMP_GE
@ COMP_GE
Definition: nasl_tree.h:88
NODE_MULT_EQ
@ NODE_MULT_EQ
Definition: nasl_tree.h:48
EXPR_MINUS
@ EXPR_MINUS
Definition: nasl_tree.h:61
REF_VAR
@ REF_VAR
Definition: nasl_tree.h:99
EXPR_INCR
@ EXPR_INCR
Definition: nasl_tree.h:72
CONST_INT
@ CONST_INT
Definition: nasl_tree.h:90
COMP_LT
@ COMP_LT
Definition: nasl_tree.h:83
NODE_IF_ELSE
@ NODE_IF_ELSE
Definition: nasl_tree.h:25
COMP_NE
@ COMP_NE
Definition: nasl_tree.h:86
alloc_RE_cell
tree_cell * alloc_RE_cell(int, int, tree_cell *, char *)
Definition: nasl_tree.c:48
EXPR_OR
@ EXPR_OR
Definition: nasl_tree.h:57
NODE_CONTINUE
@ NODE_CONTINUE
Definition: nasl_tree.h:38
NODE_FOR
@ NODE_FOR
Definition: nasl_tree.h:27
COMP_RE_MATCH
@ COMP_RE_MATCH
Definition: nasl_tree.h:80
NODE_MODULO_EQ
@ NODE_MODULO_EQ
Definition: nasl_tree.h:50
node_type
node_type
Definition: nasl_tree.h:22
REF_ARRAY
@ REF_ARRAY
Definition: nasl_tree.h:100
NODE_BREAK
@ NODE_BREAK
Definition: nasl_tree.h:37
NODE_PLUS_EQ
@ NODE_PLUS_EQ
Definition: nasl_tree.h:46
ref_cell
void ref_cell(tree_cell *)
Definition: nasl_tree.c:178
COMP_NOMATCH
@ COMP_NOMATCH
Definition: nasl_tree.h:79
NODE_EMPTY
@ NODE_EMPTY
Definition: nasl_tree.h:24
NODE_ARG
@ NODE_ARG
Definition: nasl_tree.h:35
EXPR_EXPO
@ EXPR_EXPO
Definition: nasl_tree.h:66
EXPR_BIT_OR
@ EXPR_BIT_OR
Definition: nasl_tree.h:69
EXPR_MULT
@ EXPR_MULT
Definition: nasl_tree.h:63
COMP_EQ
@ COMP_EQ
Definition: nasl_tree.h:85
TC::i_val
long int i_val
Definition: nasl_tree.h:113
COMP_GT
@ COMP_GT
Definition: nasl_tree.h:87