[Scummvm-cvs-logs] SF.net SVN: scummvm:[51802] tools/branches/gsoc2010-decompiler/decompiler/ stack.h
pidgeot at users.sourceforge.net
pidgeot at users.sourceforge.net
Fri Aug 6 23:01:17 CEST 2010
Revision: 51802
http://scummvm.svn.sourceforge.net/scummvm/?rev=51802&view=rev
Author: pidgeot
Date: 2010-08-06 21:01:17 +0000 (Fri, 06 Aug 2010)
Log Message:
-----------
DECOMPILER: Allow peeking further down the stack.
Required for Kyra code generation.
Modified Paths:
--------------
tools/branches/gsoc2010-decompiler/decompiler/stack.h
Modified: tools/branches/gsoc2010-decompiler/decompiler/stack.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/stack.h 2010-08-06 20:58:33 UTC (rev 51801)
+++ tools/branches/gsoc2010-decompiler/decompiler/stack.h 2010-08-06 21:01:17 UTC (rev 51802)
@@ -46,7 +46,7 @@
*
* @param item The item to push.
*/
- void push(const T &item) { _stack.push_back(item); }
+ void push(const T &item) { _stack.push_front(item); }
/**
* Pop an item from the stack and return it.
@@ -54,8 +54,8 @@
* @return The value popped from the stack.
*/
T pop() {
- T retval = _stack.back();
- _stack.pop_back();
+ T retval = _stack.front();
+ _stack.pop_front();
return retval;
}
@@ -64,14 +64,30 @@
*
* @return The topmost item on the stack.
*/
- T &peek() { return _stack.back(); }
+ T &peek() { return _stack.front(); }
/**
* Return the topmost item on the stack without removing it.
*
* @return The topmost item on the stack.
*/
- const T &peek() const { return _stack.back(); }
+ const T &peek() const { return _stack.front(); }
+
+ /**
+ * Return the item on the specificed stack position without removing it.
+ *
+ * @param pos The number of items to skip on the stack.
+ * @return The desired item from the stack.
+ */
+ T &peekPos(size_t pos) { return _stack.at(pos); }
+
+ /**
+ * Return the item on the specificed stack position without removing it.
+ *
+ * @param pos The number of items to skip on the stack.
+ * @return The desired item from the stack.
+ */
+ const T &peekPos(size_t pos) const { return _stack.at(pos); }
};
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list