VirtualBox

source: vbox/trunk/src/VBox/Storage/testcase/VDScriptAst.h@ 44811

最後變更 在這個檔案從44811是 44811,由 vboxsync 提交於 12 年 前

Storage/testcase: Start new scripting engine for enhanced testing capabilities (better testing of the reworked async I/O code), wip

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 8.5 KB
 
1/** @file
2 *
3 * VBox HDD container test utility - scripting engine, AST related structures.
4 */
5
6/*
7 * Copyright (C) 2013 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.alldomusa.eu.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17#ifndef _VDScriptAst_h__
18#define _VDScriptAst_h__
19
20#include <iprt/list.h>
21
22/**
23 * AST node classes.
24 */
25typedef enum VDSCRIPTASTCLASS
26{
27 /** Invalid. */
28 VDSCRIPTASTCLASS_INVALID = 0,
29 /** Function node. */
30 VDSCRIPTASTCLASS_FUNCTION,
31 /** Function argument. */
32 VDSCRIPTASTCLASS_FUNCTIONARG,
33 /** Identifier node. */
34 VDSCRIPTASTCLASS_IDENTIFIER,
35 /** Declaration node. */
36 VDSCRIPTASTCLASS_DECLARATION,
37 /** Statement node. */
38 VDSCRIPTASTCLASS_STATEMENT,
39 /** Expression node. */
40 VDSCRIPTASTCLASS_EXPRESSION,
41 /** @todo: Add if ... else, loops, ... */
42 /** 32bit blowup. */
43 VDSCRIPTASTCLASS_32BIT_HACK = 0x7fffffff
44} VDSCRIPTASTCLASS;
45/** Pointer to an AST node class. */
46typedef VDSCRIPTASTCLASS *PVDSCRIPTASTCLASS;
47
48/**
49 * Core AST structure.
50 */
51typedef struct VDSCRIPTASTCORE
52{
53 /** The node class, used for verification. */
54 VDSCRIPTASTCLASS enmClass;
55 /** List which might be used. */
56 RTLISTNODE ListNode;
57} VDSCRIPTASTCORE;
58/** Pointer to an AST core structure. */
59typedef VDSCRIPTASTCORE *PVDSCRIPTASTCORE;
60
61/** Pointer to an statement node - forward declaration. */
62typedef struct VDSCRIPTASTSTMT *PVDSCRIPTASTSTMT;
63
64/**
65 * AST identifier node.
66 */
67typedef struct VDSCRIPTASTIDE
68{
69 /** Core structure. */
70 VDSCRIPTASTCORE Core;
71 /** Number of characters in the identifier, excluding the zero terminator. */
72 unsigned cchIde;
73 /** Identifier, variable size. */
74 char aszIde[1];
75} VDSCRIPTASTIDE;
76/** Pointer to an identifer node. */
77typedef VDSCRIPTASTIDE *PVDSCRIPTASTIDE;
78
79/**
80 * AST declaration node.
81 */
82typedef struct VDSCRIPTASTDECL
83{
84 /** Core structure. */
85 VDSCRIPTASTCORE Core;
86 /** @todo */
87} VDSCRIPTASTDECL;
88/** Pointer to an declaration node. */
89typedef VDSCRIPTASTDECL *PVDSCRIPTASTDECL;
90
91/**
92 * AST expression node.
93 */
94typedef struct VDSCRIPTASTEXPR
95{
96 /** Core structure. */
97 VDSCRIPTASTCORE Core;
98 /** @todo */
99 unsigned uDummy;
100} VDSCRIPTASTEXPR;
101/** Pointer to an expression node. */
102typedef VDSCRIPTASTEXPR *PVDSCRIPTASTEXPR;
103
104/**
105 * AST if node.
106 */
107typedef struct VDSCRIPTASTIF
108{
109 /** Conditional expression. */
110 PVDSCRIPTASTEXPR pCond;
111 /** The true branch */
112 PVDSCRIPTASTSTMT pTrueStmt;
113 /** The else branch, can be NULL if no else branch. */
114 PVDSCRIPTASTSTMT pElseStmt;
115} VDSCRIPTASTIF;
116/** Pointer to an expression node. */
117typedef VDSCRIPTASTIF *PVDSCRIPTASTIF;
118
119/**
120 * AST switch node.
121 */
122typedef struct VDSCRIPTASTSWITCH
123{
124 /** Conditional expression. */
125 PVDSCRIPTASTEXPR pCond;
126 /** The statement to follow. */
127 PVDSCRIPTASTSTMT pStmt;
128} VDSCRIPTASTSWITCH;
129/** Pointer to an expression node. */
130typedef VDSCRIPTASTSWITCH *PVDSCRIPTASTSWITCH;
131
132/**
133 * AST while or do ... while node.
134 */
135typedef struct VDSCRIPTASTWHILE
136{
137 /** Flag whether this is a do while loop. */
138 bool fDoWhile;
139 /** Conditional expression. */
140 PVDSCRIPTASTEXPR pCond;
141 /** The statement to follow. */
142 PVDSCRIPTASTSTMT pStmt;
143} VDSCRIPTASTWHILE;
144/** Pointer to an expression node. */
145typedef VDSCRIPTASTWHILE *PVDSCRIPTASTWHILE;
146
147/**
148 * AST for node.
149 */
150typedef struct VDSCRIPTASTFOR
151{
152 /** Initializer expression. */
153 PVDSCRIPTASTEXPR pExprStart;
154 /** The exit condition. */
155 PVDSCRIPTASTEXPR pExprCond;
156 /** The third expression (normally used to increase/decrease loop variable). */
157 PVDSCRIPTASTEXPR pExpr3;
158 /** The for loop body. */
159 PVDSCRIPTASTSTMT pStmt;
160} VDSCRIPTASTFOR;
161/** Pointer to an expression node. */
162typedef VDSCRIPTASTFOR *PVDSCRIPTASTFOR;
163
164/**
165 * Statement types.
166 */
167typedef enum VDSCRIPTSTMTTYPE
168{
169 /** Invalid. */
170 VDSCRIPTSTMTTYPE_INVALID = 0,
171 /** Labeled statement. */
172 VDSCRIPTSTMTTYPE_LABELED,
173 /** Compound statement. */
174 VDSCRIPTSTMTTYPE_COMPOUND,
175 /** Expression statement. */
176 VDSCRIPTSTMTTYPE_EXPRESSION,
177 /** if statement. */
178 VDSCRIPTSTMTTYPE_IF,
179 /** switch statement. */
180 VDSCRIPTSTMTTYPE_SWITCH,
181 /** while statement. */
182 VDSCRIPTSTMTTYPE_WHILE,
183 /** for statement. */
184 VDSCRIPTSTMTTYPE_FOR,
185 /** continue statement. */
186 VDSCRIPTSTMTTYPE_CONTINUE,
187 /** break statement. */
188 VDSCRIPTSTMTTYPE_BREAK,
189 /** return statement. */
190 VDSCRIPTSTMTTYPE_RETURN,
191 /** case statement. */
192 VDSCRIPTSTMTTYPE_CASE,
193 /** default statement. */
194 VDSCRIPTSTMTTYPE_DEFAULT,
195 /** 32bit hack. */
196 VDSCRIPTSTMTTYPE_32BIT_HACK = 0x7fffffff
197} VDSCRIPTSTMTTYPE;
198/** Pointer to a statement type. */
199typedef VDSCRIPTSTMTTYPE *PVDSCRIPTSTMTTYPE;
200
201/**
202 * AST statement node.
203 */
204typedef struct VDSCRIPTASTSTMT
205{
206 /** Core structure. */
207 VDSCRIPTASTCORE Core;
208 /** Statement type */
209 VDSCRIPTSTMTTYPE enmStmtType;
210 /** Statement type dependent data. */
211 union
212 {
213 /** Labeled statement (case, default). */
214 struct
215 {
216 /** Conditional expression, if NULL this is a statement for "default" */
217 PVDSCRIPTASTEXPR pCondExpr;
218 /** Statement to execute. */
219 PVDSCRIPTASTSTMT pExec;
220 } Labeled;
221 /** Compound statement. */
222 struct
223 {
224 /** List of declarations - VDSCRIPTASTDECL. */
225 RTLISTANCHOR ListDecls;
226 /** List of statements - VDSCRIPTASTSTMT. */
227 RTLISTANCHOR ListStmts;
228 } Compound;
229 /** case statement. */
230 struct
231 {
232 /** Pointer to the expression. */
233 PVDSCRIPTASTEXPR pExpr;
234 /** Pointer to the statement. */
235 PVDSCRIPTASTSTMT pStmt;
236 } Case;
237 /** "if" statement. */
238 VDSCRIPTASTIF If;
239 /** "switch" statement. */
240 VDSCRIPTASTSWITCH Switch;
241 /** "while" or "do ... while" loop. */
242 VDSCRIPTASTWHILE While;
243 /** "for" loop. */
244 VDSCRIPTASTFOR For;
245 /** Pointer to another statement. */
246 PVDSCRIPTASTSTMT pStmt;
247 /** Expression statement. */
248 PVDSCRIPTASTEXPR pExpr;
249 };
250} VDSCRIPTASTSTMT;
251
252/**
253 * AST node for one function argument.
254 */
255typedef struct VDSCRIPTASTFNARG
256{
257 /** Core structure. */
258 VDSCRIPTASTCORE Core;
259 /** Identifier describing the type of the argument. */
260 PVDSCRIPTASTIDE pType;
261 /** The name of the argument. */
262 PVDSCRIPTASTIDE pArgIde;
263} VDSCRIPTASTFNARG;
264/** Pointer to a AST function argument node. */
265typedef VDSCRIPTASTFNARG *PVDSCRIPTASTFNARG;
266
267/**
268 * AST node describing a function.
269 */
270typedef struct VDSCRIPTASTFN
271{
272 /** Core structure. */
273 VDSCRIPTASTCORE Core;
274 /** Identifier describing the return type. */
275 PVDSCRIPTASTIDE pRetType;
276 /** Name of the function. */
277 PVDSCRIPTASTIDE pFnIde;
278 /** Number of arguments in the list. */
279 unsigned cArgs;
280 /** Argument list - VDSCRIPTASTFNARG. */
281 RTLISTANCHOR ListArgs;
282 /** Compound statement node. */
283 PVDSCRIPTASTSTMT pCompoundStmts;
284} VDSCRIPTASTFN;
285/** Pointer to a function AST node. */
286typedef VDSCRIPTASTFN *PVDSCRIPTASTFN;
287
288/**
289 * Free the given AST node and all subsequent nodes pointed to
290 * by the given node.
291 *
292 * @returns nothing.
293 * @param pAstNode The AST node to free.
294 */
295DECLHIDDEN(void) vdScriptAstNodeFree(PVDSCRIPTASTCORE pAstNode);
296
297/**
298 * Allocate a non variable in size AST node of the given class.
299 *
300 * @returns Pointer to the allocated node.
301 * NULL if out of memory.
302 * @param enmClass The class of the AST node.
303 */
304DECLHIDDEN(PVDSCRIPTASTCORE) vdScriptAstNodeAlloc(VDSCRIPTASTCLASS enmClass);
305
306/**
307 * Allocate a IDE node which can hold the given number of characters.
308 *
309 * @returns Pointer to the allocated node.
310 * NULL if out of memory.
311 * @param cchIde Number of characters which can be stored in the node.
312 */
313DECLHIDDEN(PVDSCRIPTASTIDE) vdScriptAstNodeIdeAlloc(unsigned cchIde);
314
315#endif /* _VDScriptAst_h__ */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette