// joycub V2 - an interpeter for the programming language Joy
// (c) 2004-2006 Sergey Zubkov 
// program.cc -
static char RCSID[] ="$Id: stack.cc,v 1.4 2006/02/27 18:44:01 cubbi Exp $";

#include "program.h"
#include "object.h"
#include "bool.h"
#include "int.h"
#include "op.h"
#include "float.h"
#include "char.h"
#include "string.h"
#include "set.h"
#include "list.h"
#include "symtab.h"
#include "exceptions.h"

JC_Stack::JC_Stack() { } // allow empty stacks

JC_Stack::JC_Stack(JC_list& jl) : JC_list(jl) { }

JC_Stack::~JC_Stack() { }

void JC_Stack::pop_back(void) { contents.pop_back(); }
JC_objref* JC_Stack::pop(void) {
	JC_objref* result = contents.back();
	contents.pop_back();
	return result;
}

JC_objref* JC_Stack::back(void) const { return contents.back(); }

void JC_Stack::stack_dump(void) const { debug_print(); }

void JC_Stack::assert_depth(int i, const string key) const {
    if(size()<i)
        throw underflow_error("Stack underflow for operator "+key);
}

