Changeset 44891 in vbox for trunk/src/VBox/Storage/testcase
- Timestamp:
- Mar 1, 2013 6:35:05 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 84060
- Location:
- trunk/src/VBox/Storage/testcase
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/testcase/Makefile.kmk
r43851 r44891 55 55 VDIoBackendMem.cpp \ 56 56 VDMemDisk.cpp \ 57 VDIoRnd.cpp 57 VDIoRnd.cpp \ 58 VDScript.cpp \ 59 VDScriptAst.cpp \ 60 VDScriptChecker.cpp \ 61 VDScriptInterp.cpp 58 62 tstVDIo_LIBS = \ 59 63 $(LIB_DDU) \ -
trunk/src/VBox/Storage/testcase/VDScript.h
r44811 r44891 52 52 * Script argument. 53 53 */ 54 typedef unionVDSCRIPTARG54 typedef struct VDSCRIPTARG 55 55 { 56 uint8_t u8; 57 int8_t i8; 58 uint16_t u16; 59 int16_t i16; 60 uint32_t u32; 61 int32_t i32; 62 uint64_t u64; 63 int64_t i64; 64 const char *psz; 65 bool f; 56 /** Type of the argument. */ 57 VDSCRIPTTYPE enmType; 58 /** Value */ 59 union 60 { 61 uint8_t u8; 62 int8_t i8; 63 uint16_t u16; 64 int16_t i16; 65 uint32_t u32; 66 int32_t i32; 67 uint64_t u64; 68 int64_t i64; 69 const char *psz; 70 bool f; 71 }; 66 72 } VDSCRIPTARG; 67 73 /** Pointer to an argument. */ -
trunk/src/VBox/Storage/testcase/VDScriptAst.cpp
r44855 r44891 19 19 #include <iprt/mem.h> 20 20 #include <iprt/assert.h> 21 #include <iprt/string.h> 21 22 22 23 #include <VBox/log.h> … … 31 32 * @param pAstNode The expression node to free. 32 33 */ 33 static void vdScriptA StNodeExpressionPutOnFreeList(PRTLISTANCHOR pList, PVDSCRIPTASTCORE pAstNode)34 static void vdScriptAstNodeExpressionPutOnFreeList(PRTLISTANCHOR pList, PVDSCRIPTASTCORE pAstNode) 34 35 { 35 36 AssertMsgReturnVoid(pAstNode->enmClass == VDSCRIPTASTCLASS_EXPRESSION, … … 40 41 { 41 42 case VDSCRIPTEXPRTYPE_PRIMARY_NUMCONST: 43 break; 42 44 case VDSCRIPTEXPRTYPE_PRIMARY_STRINGCONST: 45 RTStrFree((char *)pExpr->pszStr); 46 break; 43 47 case VDSCRIPTEXPRTYPE_PRIMARY_IDENTIFIER: 48 { 49 RTListAppend(pList, &pExpr->pIde->Core.ListNode); 50 break; 51 } 44 52 case VDSCRIPTEXPRTYPE_ASSIGNMENT_LIST: 53 { 54 while (!RTListIsEmpty(&pExpr->ListExpr)) 55 { 56 PVDSCRIPTASTCORE pNode = RTListGetFirst(&pExpr->ListExpr, VDSCRIPTASTCORE, ListNode); 57 RTListNodeRemove(&pNode->ListNode); 58 RTListAppend(pList, &pNode->ListNode); 59 } 60 break; 61 } 62 case VDSCRIPTEXPRTYPE_POSTFIX_FNCALL: 63 { 64 RTListAppend(pList, &pExpr->FnCall.pFnIde->Core.ListNode); 65 while (!RTListIsEmpty(&pExpr->FnCall.ListArgs)) 66 { 67 PVDSCRIPTASTCORE pNode = RTListGetFirst(&pExpr->FnCall.ListArgs, VDSCRIPTASTCORE, ListNode); 68 RTListNodeRemove(&pNode->ListNode); 69 RTListAppend(pList, &pNode->ListNode); 70 } 71 break; 72 } 45 73 case VDSCRIPTEXPRTYPE_POSTFIX_INCREMENT: 46 74 case VDSCRIPTEXPRTYPE_POSTFIX_DECREMENT: 47 case VDSCRIPTEXPRTYPE_POSTFIX_FNCALL:48 75 case VDSCRIPTEXPRTYPE_UNARY_INCREMENT: 49 76 case VDSCRIPTEXPRTYPE_UNARY_DECREMENT: … … 52 79 case VDSCRIPTEXPRTYPE_UNARY_INVERT: 53 80 case VDSCRIPTEXPRTYPE_UNARY_NEGATE: 81 { 82 RTListAppend(pList, &pExpr->pExpr->Core.ListNode); 83 break; 84 } 54 85 case VDSCRIPTEXPRTYPE_MULTIPLICATION: 55 86 case VDSCRIPTEXPRTYPE_DIVISION: … … 81 112 case VDSCRIPTEXPRTYPE_ASSIGN_XOR: 82 113 case VDSCRIPTEXPRTYPE_ASSIGN_OR: 114 { 115 RTListAppend(pList, &pExpr->BinaryOp.pLeftExpr->Core.ListNode); 116 RTListAppend(pList, &pExpr->BinaryOp.pRightExpr->Core.ListNode); 117 break; 118 } 83 119 case VDSCRIPTEXPRTYPE_INVALID: 84 120 default: … … 242 278 case VDSCRIPTASTCLASS_EXPRESSION: 243 279 { 244 vdScriptA StNodeExpressionPutOnFreeList(&ListFree, pAstNode);280 vdScriptAstNodeExpressionPutOnFreeList(&ListFree, pAstNode); 245 281 break; 246 282 } -
trunk/src/VBox/Storage/testcase/VDScriptInternal.h
r44842 r44891 50 50 51 51 /** 52 * Interprete a given function AST. 52 * Interprete a given function AST. The executed functions 53 * must be type correct, otherwise the behavior is undefined 54 * (Will assert in debug builds). 53 55 * 54 56 * @returns VBox status code. -
trunk/src/VBox/Storage/testcase/VDScriptInterp.cpp
r44842 r44891 19 19 #include <iprt/mem.h> 20 20 #include <iprt/assert.h> 21 #include <iprt/string.h> 21 22 22 23 #include <VBox/log.h> … … 26 27 27 28 /** 28 * Interpreter context 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. 29 58 */ 30 59 typedef struct VDSCRIPTINTERPCTX 31 60 { 32 /** List of currently accessible variables and their value. */ 33 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; 34 75 } VDSCRIPTINTERPCTX; 35 76 /** Pointer to an interpreter context. */ … … 40 81 * 41 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. 42 87 */ 43 88 static int vdScriptInterpreterError(PVDSCRIPTCTXINT pThis, int rc, RT_SRC_POS_DECL, const char *pszFmt, ...)
Note:
See TracChangeset
for help on using the changeset viewer.