aboutsummaryrefslogtreecommitdiffstats
path: root/src/runtime.cpp
diff options
context:
space:
mode:
authorjantuomi <jans.tuomi@gmail.com>2016-09-01 15:02:21 +0300
committerjantuomi <jans.tuomi@gmail.com>2016-09-01 15:02:21 +0300
commit8b02cc65072b8c6b189b104926ff5a3767e3722b (patch)
tree593c64bc0db40bcef053d8355db77257656158ff /src/runtime.cpp
parent2f4c8ad33b64a8ca3145f4e6b6bd85cf89cf1006 (diff)
Add splicemaster
Diffstat (limited to 'src/runtime.cpp')
-rw-r--r--src/runtime.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/runtime.cpp b/src/runtime.cpp
index 7519ea9..d4c9154 100644
--- a/src/runtime.cpp
+++ b/src/runtime.cpp
@@ -22,6 +22,9 @@ void Runtime::runCommand(const Token& token) {
else if (lexeme == "O") {
doPrintAscii();
}
+ else if (lexeme == ":") {
+ doSplice();
+ }
}
void Runtime::run(std::vector<Token>& tokens) {
@@ -52,3 +55,11 @@ void Runtime::doSum() {
m_values.push_back(sum);
}
+
+void Runtime::doSplice() {
+ int count = m_values.back();
+ m_values.pop_back();
+
+ std::vector<int> spliced(m_values.begin(), m_values.begin() + count);
+ m_values = spliced;
+}