VirtualBox

Changeset 44891 in vbox for trunk/src/VBox/Storage/testcase


Ignore:
Timestamp:
Mar 1, 2013 6:35:05 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
84060
Message:

Storage/VDScript: Updates

Location:
trunk/src/VBox/Storage/testcase
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Storage/testcase/Makefile.kmk

    r43851 r44891  
    5555        VDIoBackendMem.cpp \
    5656        VDMemDisk.cpp \
    57         VDIoRnd.cpp
     57        VDIoRnd.cpp \
     58        VDScript.cpp \
     59        VDScriptAst.cpp \
     60        VDScriptChecker.cpp \
     61        VDScriptInterp.cpp
    5862  tstVDIo_LIBS = \
    5963        $(LIB_DDU) \
  • trunk/src/VBox/Storage/testcase/VDScript.h

    r44811 r44891  
    5252 * Script argument.
    5353 */
    54 typedef union VDSCRIPTARG
     54typedef struct VDSCRIPTARG
    5555{
    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    };
    6672} VDSCRIPTARG;
    6773/** Pointer to an argument. */
  • trunk/src/VBox/Storage/testcase/VDScriptAst.cpp

    r44855 r44891  
    1919#include <iprt/mem.h>
    2020#include <iprt/assert.h>
     21#include <iprt/string.h>
    2122
    2223#include <VBox/log.h>
     
    3132 * @param   pAstNode The expression node to free.
    3233 */
    33 static void vdScriptAStNodeExpressionPutOnFreeList(PRTLISTANCHOR pList, PVDSCRIPTASTCORE pAstNode)
     34static void vdScriptAstNodeExpressionPutOnFreeList(PRTLISTANCHOR pList, PVDSCRIPTASTCORE pAstNode)
    3435{
    3536    AssertMsgReturnVoid(pAstNode->enmClass == VDSCRIPTASTCLASS_EXPRESSION,
     
    4041    {
    4142        case VDSCRIPTEXPRTYPE_PRIMARY_NUMCONST:
     43            break;
    4244        case VDSCRIPTEXPRTYPE_PRIMARY_STRINGCONST:
     45            RTStrFree((char *)pExpr->pszStr);
     46            break;
    4347        case VDSCRIPTEXPRTYPE_PRIMARY_IDENTIFIER:
     48        {
     49            RTListAppend(pList, &pExpr->pIde->Core.ListNode);
     50            break;
     51        }
    4452        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        }
    4573        case VDSCRIPTEXPRTYPE_POSTFIX_INCREMENT:
    4674        case VDSCRIPTEXPRTYPE_POSTFIX_DECREMENT:
    47         case VDSCRIPTEXPRTYPE_POSTFIX_FNCALL:
    4875        case VDSCRIPTEXPRTYPE_UNARY_INCREMENT:
    4976        case VDSCRIPTEXPRTYPE_UNARY_DECREMENT:
     
    5279        case VDSCRIPTEXPRTYPE_UNARY_INVERT:
    5380        case VDSCRIPTEXPRTYPE_UNARY_NEGATE:
     81        {
     82            RTListAppend(pList, &pExpr->pExpr->Core.ListNode);
     83            break;
     84        }
    5485        case VDSCRIPTEXPRTYPE_MULTIPLICATION:
    5586        case VDSCRIPTEXPRTYPE_DIVISION:
     
    81112        case VDSCRIPTEXPRTYPE_ASSIGN_XOR:
    82113        case VDSCRIPTEXPRTYPE_ASSIGN_OR:
     114        {
     115            RTListAppend(pList, &pExpr->BinaryOp.pLeftExpr->Core.ListNode);
     116            RTListAppend(pList, &pExpr->BinaryOp.pRightExpr->Core.ListNode);
     117            break;
     118        }
    83119        case VDSCRIPTEXPRTYPE_INVALID:
    84120        default:
     
    242278            case VDSCRIPTASTCLASS_EXPRESSION:
    243279            {
    244                 vdScriptAStNodeExpressionPutOnFreeList(&ListFree, pAstNode);
     280                vdScriptAstNodeExpressionPutOnFreeList(&ListFree, pAstNode);
    245281                break;
    246282            }
  • trunk/src/VBox/Storage/testcase/VDScriptInternal.h

    r44842 r44891  
    5050
    5151/**
    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).
    5355 *
    5456 * @returns VBox status code.
  • trunk/src/VBox/Storage/testcase/VDScriptInterp.cpp

    r44842 r44891  
    1919#include <iprt/mem.h>
    2020#include <iprt/assert.h>
     21#include <iprt/string.h>
    2122
    2223#include <VBox/log.h>
     
    2627
    2728/**
    28  * Interpreter context
     29 * Block scope.
     30 */
     31typedef 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. */
     39typedef VDSCRIPTINTERPSCOPE *PVDSCRIPTINTERPSCOPE;
     40
     41/**
     42 * Function call.
     43 */
     44typedef 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. */
     54typedef VDSCRIPTINTERPFNCALL *PVDSCRIPTINTERPFNCALL;
     55
     56/**
     57 * Interpreter context.
    2958 */
    3059typedef struct VDSCRIPTINTERPCTX
    3160{
    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;
    3475} VDSCRIPTINTERPCTX;
    3576/** Pointer to an interpreter context. */
     
    4081 *
    4182 * @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.
    4287 */
    4388static int vdScriptInterpreterError(PVDSCRIPTCTXINT pThis, int rc, RT_SRC_POS_DECL, const char *pszFmt, ...)
Note: See TracChangeset for help on using the changeset viewer.

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