00001 /*define for src/common/stack.hpp*/ 00002 #ifndef _CORE_COMMON_STACK_HPP 00003 #define _CORE_COMMON_STACK_HPP 00004 00045 class stack_t 00046 { 00047 public: 00048 uint32 *stack; /*the stack buffer*/ 00049 uint32 volatile stack_ptr; /*how many elements have been already pushed*/ 00050 uint32 volatile max_elems; /*the size allocated for the buffer in longwords*/ 00051 00052 // stack_t(); /*do not init*/ 00053 // /*-*/stack_t(uint32 min_elems); /*init with for min_elems elems*/ 00054 // stack_t(char *buffer, uint32 elems); /*init with a buffer and it's size*/ 00055 void nw(char *buffer, uint32 elems); /*new stack with a buffer and it's size*/ 00056 // /*-*/~stack_t(); /*done. dispose all memory*/ 00057 00058 void inval(); /*discard all data and leave it undisposed*/ 00059 /*-*/void verify(); /*checks if one more element would fit on the stack*/ 00060 00061 uint32 expandable; 00062 void setExpandable(); 00063 00066 uint32 push(uint32 data); /*push a longword. returns position in stack*/ 00067 uint32 pop(); /*pop a longword. returns value*/ 00068 uint32 pop_value(uint32 val); /*find if _val is on the stack, then pop it. return DEF_ERROR if not found or position in stack of the element (0- the most bottom element)*/ 00069 uint32 push_top(uint32 val); /*adds the value to the bottom of the stack*/ 00070 uint32 find(uint32 val); /*find position of _val or return -1 when not found*/ 00071 00073 uint32 lgth(); /*returns the element count on stack*/ 00074 }; 00075 00076 #endif