From ba869e07df4824a13b5b90f18aa5be8a0f3cc9c3 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Tue, 26 May 2015 09:53:09 +0200 Subject: Start scripting (fuck commit) --- script.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 script.h (limited to 'script.h') diff --git a/script.h b/script.h new file mode 100644 index 0000000..05427ca --- /dev/null +++ b/script.h @@ -0,0 +1,60 @@ +#pragma once + +#include "enginedata.h" +#include "query.h" +#include +#include +#include + +struct Script; +struct Query; + + +enum ExprNodeType { + EFN_ADD=0, EFN_SUBTRACT, EFN_MULTIPLY, EFN_DIVIDE, EFN_MODULO, + EFN_EQUAL, EFN_UNEQUAL, + EFN_LESS, EFN_GREATER, EFN_LESSEQUAL, EFN_GREATEREQUAL, + EFN_AND, EFN_OR, + EFN_NOT, //1 arg + EFN_MAX, EFN_MIN, + + EFN_NUMBER, EFN_VARIABLE, //0 arg + EFN_INVALID //invalid +}; + +bool validateExprNodeType(ExprNodeType); + +struct Expression { + ExprNodeType type; + vector args; + int evaluate(unordered_map&); +}; + + +enum ScriptLineType { + SLT_QUERYSTUB, + SLT_IF, + SLT_WHILE, + SLT_ASSIGNMENT +}; + +struct ScriptLine { + ScriptLineType type; + string *querystub=NULL; + string *destvar=NULL; + Expression *expr=NULL; + Script *block=NULL; + + ~ScriptLine(void); + vector execute(map&,unordered_map&); +}; + +struct Script { + vector lines; + + vector execute(map&); + vector execute(map&,unordered_map&); +}; + +//just hands over pointer, CALLING FUNCTION TAKES OWNERSHIP +Query* resolveQueryStub(const string &stub,map&,unordered_map&); -- cgit v1.2.3-70-g09d2