stack.c revision afc2ba1deb75b323afde536f2dd18bcafdaa308d
/*
* s t a c k . c
* Forth Inspired Command Language
* Author: John Sadler (john_sadler@alum.mit.edu)
* Created: 16 Oct 1997
* $Id: stack.c,v 1.11 2010/08/12 13:57:22 asau Exp $
*/
/*
* Copyright (c) 1997-2001 John Sadler (john_sadler@alum.mit.edu)
* All rights reserved.
*
* Get the latest Ficl release at http://ficl.sourceforge.net
*
* I am interested in hearing from anyone who uses Ficl. If you have
* a problem, a success story, a defect, an enhancement request, or
* if you would like to contribute to the Ficl release, please
* contact me by email at the address above.
*
* L I C E N S E and D I S C L A I M E R
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "ficl.h"
/*
* N O T E: Stack convention:
*
* THIS CHANGED IN FICL 4.0!
*
* top points to the *current* top data value
* push: increment top, store value at top
* pop: fetch value at top, decrement top
* Stack grows from low to high memory
*/
/*
* 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
{
#if FICL_ROBUST >= 1
#else /* FICL_ROBUST >= 1 */
#endif /* FICL_ROBUST >= 1 */
}
/*
* s t a c k C r e a t e
*/
{
return (stack);
}
/*
* s t a c k D e l e t e
*/
void
{
if (stack)
}
/*
* s t a c k D e p t h
*/
int
{
}
/*
* s t a c k D r o p
*/
void
{
}
/*
* s t a c k F e t c h
*/
{
}
void
{
}
/*
* s t a c k G e t T o p
*/
{
}
#if FICL_WANT_LOCALS
/*
* s t a c k L i n k
* Link a frame using the stack's frame pointer. Allot space for
* size cells in the frame
* 1) Push frame
* 2) frame = top
* 3) top += size
*/
void
{
}
/*
* s t a c k U n l i n k
* Unink a stack frame previously created by stackLink
* 1) top = frame
* 2) frame = pop()
*/
void
{
}
#endif /* FICL_WANT_LOCALS */
/*
* s t a c k P i c k
*/
void
{
}
/*
* s t a c k P o p
*/
{
}
void *
{
}
{
}
{
}
{
return (ret);
}
{
return (ret);
}
#if (FICL_WANT_FLOAT)
{
}
#endif
/*
* s t a c k P u s h
*/
void
{
}
void
{
ficlCell c;
c.p = ptr;
}
void
{
ficlCell c;
c.i = i;
}
void
{
ficlCell c;
c.u = u;
}
void
{
}
void
{
}
#if (FICL_WANT_FLOAT)
void
{
ficlCell c;
c.f = f;
}
#endif
/*
* s t a c k R e s e t
*/
void
{
}
/*
* s t a c k R o l l
* Roll nth stack entry to the top (counting from zero), if n is
* >= 0. Drop other entries as needed to fill the hole.
* If n < 0, roll top-of-stack to nth entry, pushing others
* upward as needed to fill the hole.
*/
void
{
ficlCell c;
if (n == 0)
return;
else if (n > 0) {
c = *cell;
for (; n > 0; --n, cell++) {
}
*cell = c;
} else {
c = *cell;
for (; n < 0; ++n, cell--) {
}
*cell = c;
}
}
/*
* s t a c k S e t T o p
*/
void
{
}
void
{
int i;
int depth;
FICL_STACK_CHECK(stack, 0, 0);
for (i = 0; i < depth; i++) {
break;
}
}