OpenVAS Scanner 22.7.9
nasl_tree.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Greenbone AG
2 * SPDX-FileCopyrightText: 2002-2003 Michel Arboi
3 * SPDX-FileCopyrightText: 2002-2003 Renaud Deraison
4 *
5 * SPDX-License-Identifier: GPL-2.0-only
6 */
7
8#ifndef NASL_NASL_TREE_H
9#define NASL_NASL_TREE_H
10
12{
14 NODE_IF_ELSE, /* [0] = cond, [1] = if_block, [2] = else_block */
15 NODE_INSTR_L, /* Block. [0] = first instr, [1] = tail */
16 NODE_FOR, /* [0] = start expr, [1] = cond, [2] = end_expr, [3] = block */
17 NODE_WHILE, /* [0] = cond, [1] = block */
20 NODE_REPEATED, /* [0] = func call, [1] = repeat nb */
21 NODE_FUN_DEF, /* [0] = argdecl, [1] = block */
22 NODE_FUN_CALL, /* [0] = script_infos */
23 NODE_DECL, /* [0] = next arg in list */
24 NODE_ARG, /* val = name can be NULL, [0] = val, [1] = next arg */
25 NODE_RETURN, /* ret val */
28
29 NODE_ARRAY_EL, /* val = array name, [0] = index */
30 NODE_AFF, /* [0] = lvalue, [1] = rvalue */
31 NODE_VAR, /* val = variable name */
32 NODE_LOCAL, /* [0] = argdecl */
34
40
44
48
56
66
71
78
80 CONST_STR, /* "impure" string */
81
82 CONST_DATA, /* binary data / "pure" string */
83 CONST_REGEX, /* Compiled regex */
84
85 ARRAY_ELEM, /* val = char index or NULL if integer,
86 * [0] = value, [1] = next element */
87 /* For exec only */
91};
92
93typedef struct TC
94{
95 short type;
96 short line_nb;
97 char *name;
98 short ref_count; /* Cell is freed when count reaches zero */
99 int size;
101 union
102 {
103 char *str_val;
104 long int i_val;
105 void *ref_val; /* internal reference */
106 } x;
107 struct TC *link[4];
109
110#define FAKE_CELL ((void *) 1)
111#define EXIT_CELL ((void *) 2)
112
113tree_cell *
114alloc_expr_cell (int, int, tree_cell *, tree_cell *);
115tree_cell *
116alloc_RE_cell (int, int, tree_cell *, char *, int *);
117tree_cell *
118alloc_typed_cell (int);
119int
120nasl_is_leaf (const tree_cell *);
121char *
122get_line_nb (const tree_cell *);
123tree_cell *
124dup_cell (const tree_cell *);
125void
126nasl_dump_tree (const tree_cell *);
127void
129void
131const char *
132nasl_type_name (int);
133int
134cell_type (const tree_cell *);
135
136char *
137dump_cell_val (const tree_cell *);
138
139#endif
int nasl_is_leaf(const tree_cell *)
Definition: nasl_tree.c:389
const char * nasl_type_name(int)
Definition: nasl_tree.c:346
int cell_type(const tree_cell *)
Definition: nasl_tree.c:407
tree_cell * alloc_expr_cell(int, int, tree_cell *, tree_cell *)
Definition: nasl_tree.c:63
tree_cell * dup_cell(const tree_cell *)
Definition: nasl_tree.c:75
char * get_line_nb(const tree_cell *)
Definition: nasl_tree.c:379
node_type
Definition: nasl_tree.h:12
@ NODE_FOR
Definition: nasl_tree.h:16
@ NODE_ARRAY_EL
Definition: nasl_tree.h:29
@ NODE_L_SHIFT_EQ
Definition: nasl_tree.h:41
@ NODE_PLUS_EQ
Definition: nasl_tree.h:35
@ NODE_FUN_CALL
Definition: nasl_tree.h:22
@ COMP_LE
Definition: nasl_tree.h:73
@ NODE_R_SHIFT_EQ
Definition: nasl_tree.h:42
@ COMP_GT
Definition: nasl_tree.h:76
@ NODE_LOCAL
Definition: nasl_tree.h:32
@ CONST_DATA
Definition: nasl_tree.h:82
@ NODE_AFF
Definition: nasl_tree.h:30
@ EXPR_MODULO
Definition: nasl_tree.h:54
@ COMP_RE_MATCH
Definition: nasl_tree.h:69
@ NODE_MULT_EQ
Definition: nasl_tree.h:37
@ COMP_NE
Definition: nasl_tree.h:75
@ NODE_VAR
Definition: nasl_tree.h:31
@ NODE_R_USHIFT_EQ
Definition: nasl_tree.h:43
@ NODE_ARG
Definition: nasl_tree.h:24
@ NODE_CONTINUE
Definition: nasl_tree.h:27
@ COMP_EQ
Definition: nasl_tree.h:74
@ EXPR_MULT
Definition: nasl_tree.h:52
@ NODE_FUN_DEF
Definition: nasl_tree.h:21
@ COMP_GE
Definition: nasl_tree.h:77
@ ARRAY_ELEM
Definition: nasl_tree.h:85
@ NODE_REPEAT_UNTIL
Definition: nasl_tree.h:19
@ NODE_REPEATED
Definition: nasl_tree.h:20
@ REF_VAR
Definition: nasl_tree.h:88
@ DYN_ARRAY
Definition: nasl_tree.h:90
@ CONST_REGEX
Definition: nasl_tree.h:83
@ EXPR_BIT_NOT
Definition: nasl_tree.h:60
@ EXPR_R_SHIFT
Definition: nasl_tree.h:64
@ EXPR_DIV
Definition: nasl_tree.h:53
@ COMP_RE_NOMATCH
Definition: nasl_tree.h:70
@ NODE_RETURN
Definition: nasl_tree.h:25
@ NODE_EMPTY
Definition: nasl_tree.h:13
@ EXPR_BIT_XOR
Definition: nasl_tree.h:59
@ NODE_FOREACH
Definition: nasl_tree.h:18
@ NODE_IF_ELSE
Definition: nasl_tree.h:14
@ NODE_DIV_EQ
Definition: nasl_tree.h:38
@ NODE_MINUS_EQ
Definition: nasl_tree.h:36
@ COMP_NOMATCH
Definition: nasl_tree.h:68
@ COMP_MATCH
Definition: nasl_tree.h:67
@ EXPR_NOT
Definition: nasl_tree.h:47
@ EXPR_PLUS
Definition: nasl_tree.h:49
@ EXPR_L_SHIFT
Definition: nasl_tree.h:63
@ NODE_DECL
Definition: nasl_tree.h:23
@ CONST_STR
Definition: nasl_tree.h:80
@ EXPR_BIT_AND
Definition: nasl_tree.h:57
@ EXPR_EXPO
Definition: nasl_tree.h:55
@ EXPR_INCR
Definition: nasl_tree.h:61
@ NODE_INSTR_L
Definition: nasl_tree.h:15
@ EXPR_BIT_OR
Definition: nasl_tree.h:58
@ EXPR_U_MINUS
Definition: nasl_tree.h:51
@ COMP_LT
Definition: nasl_tree.h:72
@ EXPR_OR
Definition: nasl_tree.h:46
@ NODE_BREAK
Definition: nasl_tree.h:26
@ EXPR_DECR
Definition: nasl_tree.h:62
@ EXPR_R_USHIFT
Definition: nasl_tree.h:65
@ NODE_GLOBAL
Definition: nasl_tree.h:33
@ CONST_INT
Definition: nasl_tree.h:79
@ NODE_WHILE
Definition: nasl_tree.h:17
@ REF_ARRAY
Definition: nasl_tree.h:89
@ EXPR_MINUS
Definition: nasl_tree.h:50
@ NODE_MODULO_EQ
Definition: nasl_tree.h:39
@ EXPR_AND
Definition: nasl_tree.h:45
struct TC tree_cell
tree_cell * alloc_RE_cell(int, int, tree_cell *, char *, int *)
Definition: nasl_tree.c:36
void deref_cell(tree_cell *)
Definition: nasl_tree.c:181
void ref_cell(tree_cell *)
Definition: nasl_tree.c:167
void nasl_dump_tree(const tree_cell *)
Definition: nasl_tree.c:366
char * dump_cell_val(const tree_cell *)
Definition: nasl_tree.c:234
tree_cell * alloc_typed_cell(int)
Definition: nasl_tree.c:28
Definition: nasl_tree.h:94
union TC::@5 x
struct TC * link[4]
Definition: nasl_tree.h:107
short ref_count
Definition: nasl_tree.h:98
int size
Definition: nasl_tree.h:99
int include_order
Definition: nasl_tree.h:100
long int i_val
Definition: nasl_tree.h:104
char * name
Definition: nasl_tree.h:97
short line_nb
Definition: nasl_tree.h:96
char * str_val
Definition: nasl_tree.h:103
void * ref_val
Definition: nasl_tree.h:105
short type
Definition: nasl_tree.h:95