From e043673ba70ce4482ac1bc23184c9b1423c8c14a Mon Sep 17 00:00:00 2001 From: Sygmei Date: Tue, 31 Jan 2017 12:09:58 +0100 Subject: [PATCH] Update 1.1.1 --- Kitanai.cpp | 2 +- Kitanai.hpp | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Kitanai.cpp b/Kitanai.cpp index fb24bee..62491f2 100644 --- a/Kitanai.cpp +++ b/Kitanai.cpp @@ -177,7 +177,7 @@ void Token::execute(Program* prg) { std::vector parametersExecution = parameters; doChainAdoption(); - if (getType() == TokenType::Condition) { + if (getType() == TokenType::Condition && prg->canExecute()) { parametersExecution[0].execute(prg); } else if (getType() == TokenType::Function && getValue() == "func") { diff --git a/Kitanai.hpp b/Kitanai.hpp index 55a3a35..5665375 100644 --- a/Kitanai.hpp +++ b/Kitanai.hpp @@ -145,7 +145,7 @@ namespace StdLib Token a = tokens[0]; Token b = tokens[1]; if (a.getType() == TokenType::Number && b.getType() == TokenType::Number) - return Token(TokenType::Number, std::to_string(std::stoi(a.getValue()) + std::stoi(b.getValue()))); + return Token(TokenType::Number, std::to_string(std::stoll(a.getValue()) + std::stoll(b.getValue()))); else { return Token(TokenType::String, a.getValue() + b.getValue()); } @@ -154,25 +154,25 @@ namespace StdLib Token a = tokens[0]; Token b = tokens[1]; if (a.getType() == TokenType::Number && b.getType() == TokenType::Number) - return Token(TokenType::Number, std::to_string(std::stoi(a.getValue()) - std::stoi(b.getValue()))); + return Token(TokenType::Number, std::to_string(std::stoll(a.getValue()) - std::stoll(b.getValue()))); } Token f_mul(const std::vector tokens) { Token a = tokens[0]; Token b = tokens[1]; if (a.getType() == TokenType::Number && b.getType() == TokenType::Number) - return Token(TokenType::Number, std::to_string((int)(std::stod(a.getValue()) * std::stod(b.getValue())))); + return Token(TokenType::Number, std::to_string((long long int)(std::stod(a.getValue()) * std::stod(b.getValue())))); } Token f_div(const std::vector tokens) { Token a = tokens[0]; Token b = tokens[1]; if (a.getType() == TokenType::Number && b.getType() == TokenType::Number) - return Token(TokenType::Number, std::to_string((int)std::stod(a.getValue()) / std::stod(b.getValue()))); + return Token(TokenType::Number, std::to_string((long long int)std::stod(a.getValue()) / std::stod(b.getValue()))); } Token f_mod(const std::vector tokens) { Token a = tokens[0]; Token b = tokens[1]; if (a.getType() == TokenType::Number && b.getType() == TokenType::Number) - return Token(TokenType::Number, std::to_string(std::stoi(a.getValue()) % std::stoi(b.getValue()))); + return Token(TokenType::Number, std::to_string(std::stoll(a.getValue()) % std::stoll(b.getValue()))); } Token f_not(const std::vector tokens) { Token a = tokens[0]; @@ -271,6 +271,10 @@ namespace StdLib std::uniform_real_distribution unif(0, 1); return Token(TokenType::Number, std::to_string(unif(rng))); } + Token f_time(const std::vector tokens) { + std::string retTime = std::to_string(std::chrono::system_clock::now().time_since_epoch() / std::chrono::milliseconds(1)); + return Token(TokenType::Number, retTime); + } Token f_split(const std::vector tokens) { Token saveTo = tokens[0]; Token string = tokens[1]; @@ -322,6 +326,7 @@ namespace StdLib f("string", f_string, 1), f("int", f_int, 1), f("random", f_random, 0), + f("time", f_time, 0), f("split", f_split, 3), };