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 */
90  DYN_ARRAY
91 };
92 
93 typedef 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 
113 tree_cell *
114 alloc_expr_cell (int, int, tree_cell *, tree_cell *);
115 tree_cell *
116 alloc_RE_cell (int, int, tree_cell *, char *, int *);
117 tree_cell *
118 alloc_typed_cell (int);
119 int
120 nasl_is_leaf (const tree_cell *);
121 char *
122 get_line_nb (const tree_cell *);
123 tree_cell *
124 dup_cell (const tree_cell *);
125 void
126 nasl_dump_tree (const tree_cell *);
127 void
128 ref_cell (tree_cell *);
129 void
131 const char *
132 nasl_type_name (int);
133 int
134 cell_type (const tree_cell *);
135 
136 char *
137 dump_cell_val (const tree_cell *);
138 
139 #endif
NODE_LOCAL
@ NODE_LOCAL
Definition: nasl_tree.h:32
EXPR_AND
@ EXPR_AND
Definition: nasl_tree.h:45
deref_cell
void deref_cell(tree_cell *)
Definition: nasl_tree.c:181
EXPR_BIT_XOR
@ EXPR_BIT_XOR
Definition: nasl_tree.h:59
CONST_DATA
@ CONST_DATA
Definition: nasl_tree.h:82
nasl_type_name
const char * nasl_type_name(int)
Definition: nasl_tree.c:346
alloc_typed_cell
tree_cell * alloc_typed_cell(int)
Definition: nasl_tree.c:28
NODE_MINUS_EQ
@ NODE_MINUS_EQ
Definition: nasl_tree.h:36
NODE_WHILE
@ NODE_WHILE
Definition: nasl_tree.h:17
NODE_DECL
@ NODE_DECL
Definition: nasl_tree.h:23
NODE_RETURN
@ NODE_RETURN
Definition: nasl_tree.h:25
TC::str_val
char * str_val
Definition: nasl_tree.h:103
NODE_GLOBAL
@ NODE_GLOBAL
Definition: nasl_tree.h:33
TC::name
char * name
Definition: nasl_tree.h:97
NODE_AFF
@ NODE_AFF
Definition: nasl_tree.h:30
NODE_DIV_EQ
@ NODE_DIV_EQ
Definition: nasl_tree.h:38
NODE_L_SHIFT_EQ
@ NODE_L_SHIFT_EQ
Definition: nasl_tree.h:41
EXPR_R_USHIFT
@ EXPR_R_USHIFT
Definition: nasl_tree.h:65
CONST_STR
@ CONST_STR
Definition: nasl_tree.h:80
dup_cell
tree_cell * dup_cell(const tree_cell *)
Definition: nasl_tree.c:75
NODE_REPEAT_UNTIL
@ NODE_REPEAT_UNTIL
Definition: nasl_tree.h:19
nasl_dump_tree
void nasl_dump_tree(const tree_cell *)
Definition: nasl_tree.c:366
NODE_ARRAY_EL
@ NODE_ARRAY_EL
Definition: nasl_tree.h:29
TC::x
union TC::@5 x
DYN_ARRAY
@ DYN_ARRAY
Definition: nasl_tree.h:90
get_line_nb
char * get_line_nb(const tree_cell *)
Definition: nasl_tree.c:379
nasl_is_leaf
int nasl_is_leaf(const tree_cell *)
Definition: nasl_tree.c:389
EXPR_BIT_NOT
@ EXPR_BIT_NOT
Definition: nasl_tree.h:60
dump_cell_val
char * dump_cell_val(const tree_cell *)
Definition: nasl_tree.c:234
NODE_FUN_DEF
@ NODE_FUN_DEF
Definition: nasl_tree.h:21
EXPR_U_MINUS
@ EXPR_U_MINUS
Definition: nasl_tree.h:51
NODE_R_SHIFT_EQ
@ NODE_R_SHIFT_EQ
Definition: nasl_tree.h:42
EXPR_MODULO
@ EXPR_MODULO
Definition: nasl_tree.h:54
NODE_FUN_CALL
@ NODE_FUN_CALL
Definition: nasl_tree.h:22
COMP_LE
@ COMP_LE
Definition: nasl_tree.h:73
ARRAY_ELEM
@ ARRAY_ELEM
Definition: nasl_tree.h:85
NODE_FOREACH
@ NODE_FOREACH
Definition: nasl_tree.h:18
EXPR_DECR
@ EXPR_DECR
Definition: nasl_tree.h:62
NODE_VAR
@ NODE_VAR
Definition: nasl_tree.h:31
TC::size
int size
Definition: nasl_tree.h:99
EXPR_PLUS
@ EXPR_PLUS
Definition: nasl_tree.h:49
NODE_INSTR_L
@ NODE_INSTR_L
Definition: nasl_tree.h:15
TC::include_order
int include_order
Definition: nasl_tree.h:100
alloc_expr_cell
tree_cell * alloc_expr_cell(int, int, tree_cell *, tree_cell *)
Definition: nasl_tree.c:63
cell_type
int cell_type(const tree_cell *)
Definition: nasl_tree.c:407
TC::line_nb
short line_nb
Definition: nasl_tree.h:96
NODE_REPEATED
@ NODE_REPEATED
Definition: nasl_tree.h:20
EXPR_R_SHIFT
@ EXPR_R_SHIFT
Definition: nasl_tree.h:64
EXPR_NOT
@ EXPR_NOT
Definition: nasl_tree.h:47
EXPR_DIV
@ EXPR_DIV
Definition: nasl_tree.h:53
TC::ref_val
void * ref_val
Definition: nasl_tree.h:105
TC::ref_count
short ref_count
Definition: nasl_tree.h:98
COMP_RE_NOMATCH
@ COMP_RE_NOMATCH
Definition: nasl_tree.h:70
CONST_REGEX
@ CONST_REGEX
Definition: nasl_tree.h:83
EXPR_L_SHIFT
@ EXPR_L_SHIFT
Definition: nasl_tree.h:63
EXPR_BIT_AND
@ EXPR_BIT_AND
Definition: nasl_tree.h:57
TC
Definition: nasl_tree.h:94
COMP_MATCH
@ COMP_MATCH
Definition: nasl_tree.h:67
TC::type
short type
Definition: nasl_tree.h:95
TC::link
struct TC * link[4]
Definition: nasl_tree.h:107
NODE_R_USHIFT_EQ
@ NODE_R_USHIFT_EQ
Definition: nasl_tree.h:43
tree_cell
struct TC tree_cell
COMP_GE
@ COMP_GE
Definition: nasl_tree.h:77
NODE_MULT_EQ
@ NODE_MULT_EQ
Definition: nasl_tree.h:37
EXPR_MINUS
@ EXPR_MINUS
Definition: nasl_tree.h:50
REF_VAR
@ REF_VAR
Definition: nasl_tree.h:88
EXPR_INCR
@ EXPR_INCR
Definition: nasl_tree.h:61
CONST_INT
@ CONST_INT
Definition: nasl_tree.h:79
COMP_LT
@ COMP_LT
Definition: nasl_tree.h:72
NODE_IF_ELSE
@ NODE_IF_ELSE
Definition: nasl_tree.h:14
COMP_NE
@ COMP_NE
Definition: nasl_tree.h:75
EXPR_OR
@ EXPR_OR
Definition: nasl_tree.h:46
NODE_CONTINUE
@ NODE_CONTINUE
Definition: nasl_tree.h:27
NODE_FOR
@ NODE_FOR
Definition: nasl_tree.h:16
COMP_RE_MATCH
@ COMP_RE_MATCH
Definition: nasl_tree.h:69
NODE_MODULO_EQ
@ NODE_MODULO_EQ
Definition: nasl_tree.h:39
node_type
node_type
Definition: nasl_tree.h:12
REF_ARRAY
@ REF_ARRAY
Definition: nasl_tree.h:89
NODE_BREAK
@ NODE_BREAK
Definition: nasl_tree.h:26
NODE_PLUS_EQ
@ NODE_PLUS_EQ
Definition: nasl_tree.h:35
ref_cell
void ref_cell(tree_cell *)
Definition: nasl_tree.c:167
COMP_NOMATCH
@ COMP_NOMATCH
Definition: nasl_tree.h:68
NODE_EMPTY
@ NODE_EMPTY
Definition: nasl_tree.h:13
NODE_ARG
@ NODE_ARG
Definition: nasl_tree.h:24
EXPR_EXPO
@ EXPR_EXPO
Definition: nasl_tree.h:55
EXPR_BIT_OR
@ EXPR_BIT_OR
Definition: nasl_tree.h:58
alloc_RE_cell
tree_cell * alloc_RE_cell(int, int, tree_cell *, char *, int *)
Definition: nasl_tree.c:36
EXPR_MULT
@ EXPR_MULT
Definition: nasl_tree.h:52
COMP_EQ
@ COMP_EQ
Definition: nasl_tree.h:74
TC::i_val
long int i_val
Definition: nasl_tree.h:104
COMP_GT
@ COMP_GT
Definition: nasl_tree.h:76