1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox HDD container test utility - scripting engine, interpreter.
|
---|
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.virtualbox.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 | #define LOGGROUP LOGGROUP_DEFAULT
|
---|
18 | #include <iprt/list.h>
|
---|
19 | #include <iprt/mem.h>
|
---|
20 | #include <iprt/assert.h>
|
---|
21 | #include <iprt/string.h>
|
---|
22 |
|
---|
23 | #include <VBox/log.h>
|
---|
24 |
|
---|
25 | #include "VDScriptAst.h"
|
---|
26 | #include "VDScriptInternal.h"
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Block scope.
|
---|
30 | */
|
---|
31 | typedef struct VDSCRIPTINTERPSCOPE
|
---|
32 | {
|
---|
33 | /** Pointer to the enclosing scope if available. */
|
---|
34 | struct VDSCRIPTINTERPSCOPE *pParent;
|
---|
35 | /** String space of accessible variables. */
|
---|
36 | RTSTRSPACE hStrSpaceVar;
|
---|
37 | } VDSCRIPTINTERPSCOPE;
|
---|
38 | /** Pointer to a scope block. */
|
---|
39 | typedef VDSCRIPTINTERPSCOPE *PVDSCRIPTINTERPSCOPE;
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * Function call.
|
---|
43 | */
|
---|
44 | typedef struct VDSCRIPTINTERPFNCALL
|
---|
45 | {
|
---|
46 | /** Pointer to the caller of this function. */
|
---|
47 | struct VDSCRIPTINTERPFNCALL *pCaller;
|
---|
48 | /** Root scope of this function. */
|
---|
49 | VDSCRIPTINTERPSCOPE ScopeRoot;
|
---|
50 | /** Current scope in this function. */
|
---|
51 | PVDSCRIPTINTERPSCOPE pScopeCurr;
|
---|
52 | } VDSCRIPTINTERPFNCALL;
|
---|
53 | /** Pointer to a function call. */
|
---|
54 | typedef VDSCRIPTINTERPFNCALL *PVDSCRIPTINTERPFNCALL;
|
---|
55 |
|
---|
56 | /**
|
---|
57 | * Interpreter context.
|
---|
58 | */
|
---|
59 | typedef struct VDSCRIPTINTERPCTX
|
---|
60 | {
|
---|
61 | /** Current function call entry. */
|
---|
62 | PVDSCRIPTINTERPFNCALL pFnCallCurr;
|
---|
63 | /** Stack of calculated values. */
|
---|
64 | PVDSCRIPTARG pStackVal;
|
---|
65 | /** Number of values on the stack. */
|
---|
66 | unsigned cValuesOnStack;
|
---|
67 | /** Maximum number of values the stack can hold currently. */
|
---|
68 | unsigned cValuesOnStackMax;
|
---|
69 | /** Stack of executed AST nodes. */
|
---|
70 | PVDSCRIPTASTCORE *ppStackAstCompute;
|
---|
71 | /** Number of AST nodes on the stack. */
|
---|
72 | unsigned cAstNodesOnStack;
|
---|
73 | /** Maximum number of AST nodes the stack can hold. */
|
---|
74 | unsigned cAstNodesOnStackMax;
|
---|
75 | } VDSCRIPTINTERPCTX;
|
---|
76 | /** Pointer to an interpreter context. */
|
---|
77 | typedef VDSCRIPTINTERPCTX *PVDSCRIPTINTERPCTX;
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * Record an error while interpreting.
|
---|
81 | *
|
---|
82 | * @returns VBox status code passed.
|
---|
83 | * @param pThis The script context.
|
---|
84 | * @param rc The status code to record.
|
---|
85 | * @param RT_SRC_POS Position in the source code.
|
---|
86 | * @param pszFmt Format string.
|
---|
87 | */
|
---|
88 | static int vdScriptInterpreterError(PVDSCRIPTCTXINT pThis, int rc, RT_SRC_POS_DECL, const char *pszFmt, ...)
|
---|
89 | {
|
---|
90 | return rc;
|
---|
91 | }
|
---|
92 |
|
---|
93 | DECLHIDDEN(int) vdScriptCtxInterprete(PVDSCRIPTCTXINT pThis, PVDSCRIPTASTFN pAstFn,
|
---|
94 | PVDSCRIPTARG paArgs, unsigned cArgs,
|
---|
95 | PVDSCRIPTARG pRet)
|
---|
96 | {
|
---|
97 | return VERR_NOT_IMPLEMENTED;
|
---|
98 | }
|
---|