Commit ffc17a50 authored by Sarah Spall's avatar Sarah Spall Committed by Vikram Narayanan
Browse files

generate tag values for rpc's, including function pointers

parent 6390c4c5
......@@ -8,6 +8,7 @@ Rpc::Rpc(ReturnVariable *return_value, const char* name, std::vector<Parameter*
this->parameters_ = parameters;
this->symbol_table_ = new SymbolTable();
this->current_scope_ = current_scope;
this->tag_ = 0;
for(std::vector<Parameter*>::iterator it = parameters.begin(); it != parameters.end(); it ++)
{
......@@ -17,6 +18,16 @@ Rpc::Rpc(ReturnVariable *return_value, const char* name, std::vector<Parameter*
construct_marshal_parameters();
}
unsigned int Rpc::tag()
{
return this->tag_;
}
void Rpc::set_tag(unsigned int t)
{
this->tag_ = t;
}
void Rpc::construct_marshal_parameters()
{
std::vector<Variable*> marshal_parameters;
......@@ -243,6 +254,15 @@ void Module::create_trampoline_structs()
}
}
void Module::generate_function_tags(Project *p)
{
for(std::vector<Rpc*>::iterator it = this->rpc_definitions_.begin(); it != this->rpc_definitions_.end(); it ++) {
Rpc *r = *it;
r->set_tag(p->get_next_tag());
}
}
const char* Module::identifier()
{
return this->module_name_;
......@@ -253,6 +273,7 @@ Project::Project(LexicalScope *scope, std::vector<Module*> modules, std::vector<
this->project_scope_ = scope;
this->project_modules_ = modules;
this->project_includes_ = includes;
this->last_tag_ = 0;
}
void Project::prepare_marshal()
......@@ -293,14 +314,29 @@ void Project::create_trampoline_structs()
}
}
void Project::generate_function_tags()
{
for(std::vector<Module*>::iterator it = this->project_modules_.begin(); it != this->project_modules_.end(); it ++) {
Module *m = *it;
m->generate_function_tags(this);
}
}
std::vector<Module*> Project::modules()
{
return this->project_modules_;
}
unsigned int Project::get_next_tag()
{
this->last_tag_ += 1;
return this->last_tag_;
}
Include::Include(bool relative, const char *path)
{
this->relative_ = relative;
this->path_ = path;
}
......@@ -23,6 +23,7 @@ class Type;
class Parameter;
class Rpc;
class ProjectionType;
class Project;
enum PrimType {pt_char_t, pt_short_t, pt_int_t, pt_long_t, pt_longlong_t, pt_capability_t};
enum type_k {};
......@@ -460,12 +461,11 @@ class ProjectionType : public Type // complex type
class Rpc : public Base
{
const char* enum_name_;
unsigned int tag_;
SymbolTable *symbol_table_;
ReturnVariable *explicit_return_;
LexicalScope *current_scope_;
/* -------------- */
const char* name_;
std::vector<Parameter* > parameters_;
bool function_pointer_defined_;
......@@ -473,6 +473,8 @@ class Rpc : public Base
std::vector<Variable*> construct_projection_parameters(ProjectionType *pt, bool alloc);
public:
Rpc(ReturnVariable *return_var, const char* name, std::vector<Parameter* > parameters, LexicalScope *current_scope);
unsigned int tag();
void set_tag(unsigned int t);
std::vector<Variable*> marshal_parameters;
void set_function_pointer_defined(bool b);
bool function_pointer_defined();
......@@ -504,6 +506,7 @@ class Module : public Base
void resolve_types();
void function_pointer_to_rpc();
void create_trampoline_structs();
void generate_function_tags(Project *p);
const char* identifier();
};
......@@ -520,6 +523,7 @@ class Project : public Base
LexicalScope *project_scope_;
std::vector<Module*> project_modules_;
std::vector<Include*> project_includes_;
unsigned int last_tag_;
public:
Project(LexicalScope *scope, std::vector<Module*> modules, std::vector<Include*> includes);
......@@ -527,7 +531,9 @@ class Project : public Base
void resolve_types();
void function_pointer_to_rpc();
void create_trampoline_structs();
void generate_function_tags();
std::vector<Module*> modules();
unsigned int get_next_tag();
};
class TypeNameVisitor // generates CCSTTypeName for each type.
......
......@@ -63,6 +63,7 @@ int main(int argc, char ** argv)
{
tree->create_trampoline_structs();
tree->function_pointer_to_rpc();
tree->generate_function_tags();
tree->resolve_types();
tree->prepare_marshal();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment