2013-04-09 08:28:16 +04:00
|
|
|
#ifndef FILECONTEXT_H_
|
|
|
|
#define FILECONTEXT_H_
|
|
|
|
|
|
|
|
#include "context.h"
|
2013-04-20 01:52:01 +04:00
|
|
|
#include "module.h"
|
2013-04-16 04:58:15 +04:00
|
|
|
#include <boost/unordered_map.hpp>
|
2013-04-09 08:28:16 +04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
This holds the context for a Module definition; keeps track of
|
|
|
|
global variables, submodules and functions defined inside a module.
|
|
|
|
|
2013-04-20 01:52:01 +04:00
|
|
|
NB! every .scad file defines a FileModule holding the contents of the file.
|
2013-04-09 08:28:16 +04:00
|
|
|
*/
|
|
|
|
class ModuleContext : public Context
|
|
|
|
{
|
|
|
|
public:
|
2013-04-24 17:17:25 +04:00
|
|
|
ModuleContext(const Context *parent = NULL, const EvalContext *evalctx = NULL);
|
2013-04-09 08:28:16 +04:00
|
|
|
virtual ~ModuleContext();
|
|
|
|
|
2013-04-24 17:17:25 +04:00
|
|
|
void initializeModule(const Module &m);
|
2013-04-09 08:28:16 +04:00
|
|
|
void registerBuiltin();
|
2013-04-24 17:17:25 +04:00
|
|
|
virtual Value evaluate_function(const std::string &name,
|
|
|
|
const EvalContext *evalctx) const;
|
|
|
|
virtual AbstractNode *instantiate_module(const ModuleInstantiation &inst,
|
|
|
|
const EvalContext *evalctx) const;
|
2013-04-09 08:28:16 +04:00
|
|
|
|
2013-04-24 17:17:25 +04:00
|
|
|
const AbstractModule *findLocalModule(const std::string &name) const;
|
|
|
|
const AbstractFunction *findLocalFunction(const std::string &name) const;
|
2013-04-09 08:28:16 +04:00
|
|
|
|
2013-04-24 17:17:25 +04:00
|
|
|
const LocalScope::FunctionContainer *functions_p;
|
|
|
|
const LocalScope::AbstractModuleContainer *modules_p;
|
2013-04-09 08:28:16 +04:00
|
|
|
|
|
|
|
// FIXME: Points to the eval context for the call to this module. Not sure where it belongs
|
|
|
|
const class EvalContext *evalctx;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2014-04-05 08:40:23 +04:00
|
|
|
virtual std::string dump(const class AbstractModule *mod, const ModuleInstantiation *inst);
|
2013-04-09 08:28:16 +04:00
|
|
|
#endif
|
2013-06-13 18:29:39 +04:00
|
|
|
private:
|
|
|
|
// Experimental code. See issue #399
|
|
|
|
// void evaluateAssignments(const AssignmentList &assignments);
|
2013-04-09 08:28:16 +04:00
|
|
|
};
|
|
|
|
|
2013-04-20 01:52:01 +04:00
|
|
|
class FileContext : public ModuleContext
|
|
|
|
{
|
|
|
|
public:
|
2013-04-24 17:17:25 +04:00
|
|
|
FileContext(const class FileModule &module, const Context *parent);
|
2013-04-20 01:52:01 +04:00
|
|
|
virtual ~FileContext() {}
|
2013-04-24 17:17:25 +04:00
|
|
|
virtual Value evaluate_function(const std::string &name, const EvalContext *evalctx) const;
|
|
|
|
virtual AbstractNode *instantiate_module(const ModuleInstantiation &inst,
|
|
|
|
const EvalContext *evalctx) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const FileModule::ModuleContainer &usedlibs;
|
2013-04-20 01:52:01 +04:00
|
|
|
};
|
|
|
|
|
2013-04-09 08:28:16 +04:00
|
|
|
#endif
|