aboutsummaryrefslogtreecommitdiffstats
path: root/src/runtime.cpp
diff options
context:
space:
mode:
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;
+}