summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/Context.h
blob: 92187f043e7182653df943f8262d4aa77a77f1c1 (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
44
45
46
/*
 * 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_ */