2007-01-15 12:09:25 -08:00
|
|
|
/*
|
|
|
|
This file is part of Warzone 2100.
|
|
|
|
Copyright (C) 1999-2004 Eidos Interactive
|
2011-02-25 09:45:27 -08:00
|
|
|
Copyright (C) 2005-2011 Warzone 2100 Project
|
2007-01-15 12:09:25 -08:00
|
|
|
|
|
|
|
Warzone 2100 is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Warzone 2100 is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Warzone 2100; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2007-06-28 10:47:08 -07:00
|
|
|
/*
|
|
|
|
* Stack.h
|
|
|
|
*
|
|
|
|
* Interface to the stack system
|
|
|
|
*/
|
|
|
|
#ifndef _stack_h
|
|
|
|
#define _stack_h
|
|
|
|
|
2010-04-13 15:58:37 -07:00
|
|
|
#include "interpreter.h"
|
|
|
|
|
2006-08-25 13:38:27 -07:00
|
|
|
//String support
|
|
|
|
//-----------------------------
|
|
|
|
#define MAXSTRLEN 255 //Max len of a single string
|
2008-04-14 13:12:27 -07:00
|
|
|
#define MAXSTACKLEN 8000
|
2006-08-25 13:38:27 -07:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
/* Initialise the stack */
|
2011-03-12 17:32:15 -08:00
|
|
|
extern bool stackInitialise(void);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
/* Shutdown the stack */
|
|
|
|
extern void stackShutDown(void);
|
|
|
|
|
|
|
|
/* Push a value onto the stack */
|
2011-03-12 17:32:15 -08:00
|
|
|
extern bool stackPush(INTERP_VAL *psVal);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
/* Pop a value off the stack */
|
2011-03-12 17:32:15 -08:00
|
|
|
extern bool stackPop(INTERP_VAL *psVal);
|
2008-03-27 11:38:25 -07:00
|
|
|
|
|
|
|
/* Return pointer to the top value without poping it */
|
2011-03-12 17:32:15 -08:00
|
|
|
extern bool stackPeekTop(INTERP_VAL **ppsVal);
|
2006-12-26 08:39:07 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
/* Pop a value off the stack, checking that the type matches what is passed in */
|
2011-03-12 17:32:15 -08:00
|
|
|
extern bool stackPopType(INTERP_VAL *psVal);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
/* Look at a value on the stack without removing it.
|
|
|
|
* index is how far down the stack to look.
|
|
|
|
* Index 0 is the top entry on the stack.
|
|
|
|
*/
|
2011-03-12 17:32:15 -08:00
|
|
|
extern bool stackPeek(INTERP_VAL *psVal, UDWORD index);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
/* Print the top value on the stack */
|
|
|
|
extern void stackPrintTop(void);
|
|
|
|
|
|
|
|
/* Check if the stack is empty */
|
2011-03-12 17:32:15 -08:00
|
|
|
extern bool stackEmpty(void);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
/* Do binary operations on the top of the stack
|
|
|
|
* This effectively pops two values and pushes the result
|
|
|
|
*/
|
2011-03-12 17:32:15 -08:00
|
|
|
extern bool stackBinaryOp(OPCODE opcode);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
/* Perform a unary operation on the top of the stack
|
|
|
|
* This effectively pops a value and pushes the result
|
|
|
|
*/
|
2011-03-12 17:32:15 -08:00
|
|
|
extern bool stackUnaryOp(OPCODE opcode);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2006-11-16 06:30:29 -08:00
|
|
|
/* casts top of the stack to some other data type */
|
2011-03-12 17:32:15 -08:00
|
|
|
extern bool stackCastTop(INTERP_TYPE neededType);
|
2006-11-16 06:30:29 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
/* Reset the stack to an empty state */
|
|
|
|
extern void stackReset(void);
|
|
|
|
|
|
|
|
#endif
|