blob: d9965c5d51c20aa1d176d322fd8b5f3c0929b340 (
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
47
|
#ifndef FILECONTEXT_H_
#define FILECONTEXT_H_
#include "context.h"
#include "module.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 a FileModule 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 *instantiate_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;
const FileModule::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;
};
class FileContext : public ModuleContext
{
public:
FileContext(const class FileModule &module, const Context *parent = NULL, const EvalContext *evalctx = NULL);
virtual ~FileContext() {}
};
#endif
|