/*
 * Context.h
 *
 *  Created on: Dec 30, 2012
 *      Author: att
 */

#ifndef CONTEXT_H_
#define CONTEXT_H_
#include <map>
#include <string>
#include "Utils/to_string.h"
#include "Elements/SenchaObject.h"
#include "Elements/SenchaFunction.h"
#include "AST/ASTExpression.h"




class Context {
public:
	Context(std::string name);
	unsigned int index;

	std::string name;
	std::map<std::string, SenchaObject> object_store;
	unsigned int add_to_store(SenchaObject & object);
	SenchaObject get_from_store(unsigned int index);

	typedef SenchaObject (*PointerToNativeFunction)(std::vector<ASTExpression *>);

	std::map<std::string, PointerToNativeFunction> registered_functions;
	std::map<std::string, SenchaFunction *> registered_sfunctions;

	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<ASTExpression *> arguments);

	std::string debug() ;
	void add(std::string name, SenchaObject object);
	void set(std::string name, SenchaObject object);
	SenchaObject get(std::string name);
	virtual ~Context();
};

#endif /* CONTEXT_H_ */
