/* * Context.h * * Created on: Dec 30, 2012 * Author: att */ #ifndef CONTEXT_H_ #define CONTEXT_H_ #include #include #include "Utils/to_string.h" #include "Elements/SenchaObject.h" #include "Elements/SenchaFunction.h" #include "AST/ASTExpression.h" /** * Context is object used to store variables for some execution context. * It's most useful in function calls. Every function has to have its own execution contexts, * for its variables. Arguments are passed to functions by predefining them in new Context, assigned to * function. */ class Context { public: Context(std::string name); std::string name; typedef SenchaObject (*PointerToNativeFunction)(std::vector); void register_function(std::string name, PointerToNativeFunction f); void register_function(std::string name, SenchaFunction * f); SenchaObject execute_native_function(std::string name, std::vector arguments); std::string debug() ; void add(std::string name, SenchaObject object); void set(std::string name, SenchaObject object); SenchaObject get(std::string name); bool contains_function(std::string name); bool contains_sfunction(std::string name); bool contains_nfunction(std::string name); std::map registered_functions; std::map registered_sfunctions; virtual ~Context(); private: unsigned int index; std::map object_store; }; #endif /* CONTEXT_H_ */