summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/Context.h
blob: 53e78889fc8297714e779fc2adb9d22e9b814b06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
 * Context.h
 *
 *  Created on: Dec 30, 2012
 *      Author: att
 */

#ifndef CONTEXT_H_
#define CONTEXT_H_
#include "Utils/to_string.h"

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

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


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

	std::map<std::string, PointerToNativeFunction> registered_functions;

	void register_function(std::string name, PointerToNativeFunction f);

	SenchaObject execute_native_function(std::string name, std::vector<ASTExpression *> arguments);

	//Overload it to use contexts

	typedef std::map<std::string, ObjectIndex> ExecutionContext;
	ExecutionContext interpreter_context;

	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_ */