Add module annotations.
This commit is contained in:
parent
3a358d4da7
commit
6dfddf41da
3 changed files with 22 additions and 0 deletions
|
|
@ -174,6 +174,13 @@ Module::~Module()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Module::add_annotations(AnnotationList *annotations)
|
||||||
|
{
|
||||||
|
for (AnnotationList::iterator it = annotations->begin();it != annotations->end();it++) {
|
||||||
|
this->annotations.insert(std::pair<const std::string, Annotation *>((*it).get_name(), &(*it)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AbstractNode *Module::instantiate(const Context *ctx, const ModuleInstantiation *inst, EvalContext *evalctx) const
|
AbstractNode *Module::instantiate(const Context *ctx, const ModuleInstantiation *inst, EvalContext *evalctx) const
|
||||||
{
|
{
|
||||||
if (StackCheck::inst()->check()) {
|
if (StackCheck::inst()->check()) {
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,8 @@ public:
|
||||||
Module(const Feature& feature) : AbstractModule(feature) { }
|
Module(const Feature& feature) : AbstractModule(feature) { }
|
||||||
virtual ~Module();
|
virtual ~Module();
|
||||||
|
|
||||||
|
virtual void add_annotations(AnnotationList *annotations);
|
||||||
|
|
||||||
virtual AbstractNode *instantiate(const Context *ctx, const ModuleInstantiation *inst, EvalContext *evalctx = NULL) const;
|
virtual AbstractNode *instantiate(const Context *ctx, const ModuleInstantiation *inst, EvalContext *evalctx = NULL) const;
|
||||||
virtual std::string dump(const std::string &indent, const std::string &name) const;
|
virtual std::string dump(const std::string &indent, const std::string &name) const;
|
||||||
static const std::string& stack_element(int n) { return module_stack[n]; };
|
static const std::string& stack_element(int n) { return module_stack[n]; };
|
||||||
|
|
@ -90,6 +92,9 @@ public:
|
||||||
|
|
||||||
LocalScope scope;
|
LocalScope scope;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
AnnotationMap annotations;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::deque<std::string> module_stack;
|
static std::deque<std::string> module_stack;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
10
src/parser.y
10
src/parser.y
|
|
@ -195,6 +195,16 @@ statement:
|
||||||
free($2);
|
free($2);
|
||||||
delete $4;
|
delete $4;
|
||||||
}
|
}
|
||||||
|
| annotations TOK_MODULE TOK_ID '(' arguments_decl optional_commas ')'
|
||||||
|
{
|
||||||
|
Module *newmodule = new Module();
|
||||||
|
newmodule->definition_arguments = *$5;
|
||||||
|
newmodule->add_annotations($1);
|
||||||
|
scope_stack.top()->modules[$3] = newmodule;
|
||||||
|
scope_stack.push(&newmodule->scope);
|
||||||
|
free($3);
|
||||||
|
delete $5;
|
||||||
|
}
|
||||||
statement
|
statement
|
||||||
{
|
{
|
||||||
scope_stack.pop();
|
scope_stack.pop();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue