Ejemplo n.º 1
0
/*******************************************************************
                    v m C h e c k S t a c k
** Check the parameter stack for underflow or overflow.
** size controls the type of check: if size is zero,
** the function checks the stack state for underflow and overflow.
** If size > 0, checks to see that the stack has room to push
** that many cells. If less than zero, checks to see that the
** stack has room to pop that many cells. If any test fails,
** the function throws (via vmThrow) a VM_ERREXIT exception.
*******************************************************************/
void ficlStackCheck(ficlStack *stack, int popCells, int pushCells)
#if FICL_ROBUST >= 1
{
    int nFree = stack->size - STKDEPTH(stack);

    if (popCells > STKDEPTH(stack))
    {
        ficlVmThrowError(stack->vm, "Error: %s stack underflow", stack->name);
    }

    if (nFree < pushCells - popCells)
    {
        ficlVmThrowError(stack->vm, "Error: %s stack overflow", stack->name);
    }

    return;
}
Ejemplo n.º 2
0
void vmCheckFStack(FICL_VM *pVM, int popCells, int pushCells)
{
    FICL_STACK *fStack = pVM->fStack;
    int nFree = fStack->base + fStack->nCells - fStack->sp;

    if (popCells > STKDEPTH(fStack))
    {
        vmThrowErr(pVM, "Error: float stack underflow");
    }

    if (nFree < pushCells - popCells)
    {
        vmThrowErr(pVM, "Error: float stack overflow");
    }
}
Ejemplo n.º 3
0
/*******************************************************************
                    v m C h e c k S t a c k
** Check the parameter stack for underflow or overflow.
** nCells controls the type of check: if nCells is zero,
** the function checks the stack state for underflow and overflow.
** If nCells > 0, checks to see that the stack has room to push
** that many cells. If less than zero, checks to see that the
** stack has room to pop that many cells. If any test fails,
** the function throws (via vmThrow) a VM_ERREXIT exception.
*******************************************************************/
void vmCheckStack(FICL_VM *pVM, int popCells, int pushCells)
{
    FICL_STACK *pStack = pVM->pStack;
    int nFree = pStack->base + pStack->nCells - pStack->sp;

    if (popCells > STKDEPTH(pStack))
    {
        vmThrowErr(pVM, "Error: stack underflow");
    }

    if (nFree < pushCells - popCells)
    {
        vmThrowErr(pVM, "Error: stack overflow");
    }

    return;
}
Ejemplo n.º 4
0
int stackDepth(FICL_STACK *pStack)
{
    return STKDEPTH(pStack);
}