summaryrefslogtreecommitdiff
path: root/src/modcontext.h
blob: 5fce88f6f460109cfcf0dee0ef47b608b5c3e7b1 (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
#ifndef FILECONTEXT_H_
#define FILECONTEXT_H_

#include "context.h"
#include <boost/unordered_map.hpp>

/*!
	This holds the context for a Module definition; keeps track of
	global variables, submodules and functions defined inside a module.

	NB! every .scad file defines an implicit unnamed module holding the contents of the file.
*/
class ModuleContext : public Context
{
public:
	ModuleContext(const class Module *module = NULL, const Context *parent = NULL, const EvalContext *evalctx = NULL);
	virtual ~ModuleContext();

	void setModule(const Module &module, const EvalContext *evalctx = NULL);
	void registerBuiltin();

	virtual Value evaluate_function(const std::string &name, const EvalContext *evalctx) const;
	virtual AbstractNode *evaluate_module(const ModuleInstantiation &inst, const EvalContext *evalctx) const;

	const boost::unordered_map<std::string, class AbstractFunction*> *functions_p;
	const boost::unordered_map<std::string, class AbstractModule*> *modules_p;
	typedef boost::unordered_map<std::string, class Module*> ModuleContainer;
	const ModuleContainer *usedlibs_p;

  // FIXME: Points to the eval context for the call to this module. Not sure where it belongs
	const class EvalContext *evalctx;

#ifdef DEBUG
	virtual void dump(const class AbstractModule *mod, const ModuleInstantiation *inst);
#endif

	mutable boost::unordered_map<std::string, int> recursioncount;
};

#endif
contact: Jan Huwald // Impressum