VDScriptAst.cpp revision 8bce22f6f04047918df71d70b614262e1d08dc61
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync * VBox HDD container test utility - scripting engine AST node related functions.
15aa5bd4323e2951c8b51648033af4104b2ba8f9vboxsync * Copyright (C) 2013 Oracle Corporation
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync * available from http://www.virtualbox.org. This file is free software;
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync * you can redistribute it and/or modify it under the terms of the GNU
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync * General Public License (GPL) as published by the Free Software
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync * Put all child nodes of the given expression AST node onto the given to free list.
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync * @returns nothing.
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync * @param pList The free list to append everything to.
15aa5bd4323e2951c8b51648033af4104b2ba8f9vboxsync * @param pAstNode The expression node to free.
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsyncstatic void vdScriptAStNodeExpressionPutOnFreeList(PRTLISTANCHOR pList, PVDSCRIPTASTCORE pAstNode)
15aa5bd4323e2951c8b51648033af4104b2ba8f9vboxsync AssertMsgReturnVoid(pAstNode->enmClass == VDSCRIPTASTCLASS_EXPRESSION,
15aa5bd4323e2951c8b51648033af4104b2ba8f9vboxsync ("Given AST node is not a statement\n"));
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync PVDSCRIPTASTEXPR pExpr = (PVDSCRIPTASTEXPR)pAstNode;
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync AssertMsgFailedReturnVoid(("Invalid AST node expression type %d\n",
99dfe084aaa87733b2e26f5f9a86054d0461ff60vboxsync * Free a given statement AST node and put everything on the given to free list.
99dfe084aaa87733b2e26f5f9a86054d0461ff60vboxsync * @returns nothing.
99dfe084aaa87733b2e26f5f9a86054d0461ff60vboxsync * @param pList The free list to append everything to.
99dfe084aaa87733b2e26f5f9a86054d0461ff60vboxsync * @param pAstNode The statement node to free.
99dfe084aaa87733b2e26f5f9a86054d0461ff60vboxsyncstatic void vdScriptAstNodeStatmentPutOnFreeList(PRTLISTANCHOR pList, PVDSCRIPTASTCORE pAstNode)
99dfe084aaa87733b2e26f5f9a86054d0461ff60vboxsync AssertMsgReturnVoid(pAstNode->enmClass == VDSCRIPTASTCLASS_STATEMENT,
99dfe084aaa87733b2e26f5f9a86054d0461ff60vboxsync ("Given AST node is not a statement\n"));
99dfe084aaa87733b2e26f5f9a86054d0461ff60vboxsync PVDSCRIPTASTSTMT pStmt = (PVDSCRIPTASTSTMT)pAstNode;
99dfe084aaa87733b2e26f5f9a86054d0461ff60vboxsync /* Put all declarations on the to free list. */
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync PVDSCRIPTASTCORE pNode = RTListGetFirst(&pStmt->Compound.ListDecls, VDSCRIPTASTCORE, ListNode);
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync /* Put all statements on the to free list. */
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync PVDSCRIPTASTCORE pNode = RTListGetFirst(&pStmt->Compound.ListDecls, VDSCRIPTASTCORE, ListNode);
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync RTListAppend(pList, &pStmt->If.pCond->Core.ListNode);
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync RTListAppend(pList, &pStmt->If.pTrueStmt->Core.ListNode);
c5245f029ba21b3152e4ba59394838bb5c09126bvboxsync RTListAppend(pList, &pStmt->If.pElseStmt->Core.ListNode);
c5245f029ba21b3152e4ba59394838bb5c09126bvboxsync RTListAppend(pList, &pStmt->Switch.pCond->Core.ListNode);
c5245f029ba21b3152e4ba59394838bb5c09126bvboxsync RTListAppend(pList, &pStmt->Switch.pStmt->Core.ListNode);
c5245f029ba21b3152e4ba59394838bb5c09126bvboxsync RTListAppend(pList, &pStmt->While.pCond->Core.ListNode);
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync RTListAppend(pList, &pStmt->While.pStmt->Core.ListNode);
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync RTListAppend(pList, &pStmt->For.pExprStart->Core.ListNode);
c5245f029ba21b3152e4ba59394838bb5c09126bvboxsync RTListAppend(pList, &pStmt->For.pExprCond->Core.ListNode);
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync RTListAppend(pList, &pStmt->For.pExpr3->Core.ListNode);
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync RTListAppend(pList, &pStmt->For.pStmt->Core.ListNode);
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync RTListAppend(pList, &pStmt->Case.pExpr->Core.ListNode);
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync RTListAppend(pList, &pStmt->Case.pStmt->Core.ListNode);
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync RTListAppend(pList, &pStmt->Case.pStmt->Core.ListNode);
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync AssertMsgFailedReturnVoid(("Invalid AST node statement type %d\n",
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsyncDECLHIDDEN(void) vdScriptAstNodeFree(PVDSCRIPTASTCORE pAstNode)
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync * The node is not allowed to be part of a list because we need it
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync * for the nodes to free list.
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync pAstNode = RTListGetFirst(&ListFree, VDSCRIPTASTCORE, ListNode);
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync RTListAppend(&ListFree, &pFn->pRetType->Core.ListNode);
39c2e57acd25ad706e24d3eed2cba74905506db0vboxsync RTListAppend(&ListFree, &pFn->pFnIde->Core.ListNode);
case VDSCRIPTASTCLASS_INVALID:
switch (enmClass)
case VDSCRIPTASTCLASS_INVALID:
if (pAstNode)
return pAstNode;
PVDSCRIPTASTIDE pAstNode = (PVDSCRIPTASTIDE)RTMemAllocZ(RT_OFFSETOF(VDSCRIPTASTIDE, aszIde[cchIde + 1]));
if (pAstNode)
return pAstNode;