diff options
-rw-r--r-- | functions.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/functions.cpp b/functions.cpp index bd718f8..792e2cc 100644 --- a/functions.cpp +++ b/functions.cpp @@ -436,12 +436,28 @@ unordered_map<string,function<void(vector<Stackitem>&,unordered_map<string,Stack S.pop_back(); }}, //leaves the array on the stack, obviously + {"arrpushf",[](vector<Stackitem> &S,unordered_map<string,Stackitem> &variables){ + BUILTIN_GUARD_STACKSIZE("arrpushf",2) + Stackitem &arrref=S[S.size()-2]; + if(arrref.type!=SIT_ARR) + throw string("Top of stack is not an array in builtin 'arrpushf'"); + arrref.arrval.insert(arrref.arrval.begin(),move(S.back())); + S.pop_back(); + }}, + //leaves the array on the stack, obviously {"arrpop",[](vector<Stackitem> &S,unordered_map<string,Stackitem> &variables){ BUILTIN_GUARD_STACKSIZE("arrpop",1) if(S.back().type!=SIT_ARR) throw string("Top of stack is not an array in builtin 'arrpop'"); S.back().arrval.pop_back(); }}, + //leaves the array on the stack, obviously + {"arrpopf",[](vector<Stackitem> &S,unordered_map<string,Stackitem> &variables){ + BUILTIN_GUARD_STACKSIZE("arrpopf",1) + if(S.back().type!=SIT_ARR) + throw string("Top of stack is not an array in builtin 'arrpopf'"); + S.back().arrval.erase(S.back().arrval.begin()); + }}, {"rand",[](vector<Stackitem> &S,unordered_map<string,Stackitem> &variables){ BUILTIN_GUARD_STACKSIZE("rand",0) assert(RAND_MAX==0x7fffffff); @@ -474,6 +490,10 @@ unordered_map<string,function<void(vector<Stackitem>&,unordered_map<string,Stack } cerr<<endl; }}, + {"error",[](vector<Stackitem> &S,unordered_map<string,Stackitem> &variables){ + BUILTIN_GUARD_STACKSIZE("error",0) + exit(1); //STUB IMPLEMENTATION + }}, {"exit",[](vector<Stackitem> &S,unordered_map<string,Stackitem> &variables){ BUILTIN_GUARD_STACKSIZE("exit",0) exit(0); |