Commit f1c4147b authored by Sarah Spall's avatar Sarah Spall Committed by Vikram Narayanan

function to write static variables, for new module scope stuff

parent c453a2ce
......@@ -83,3 +83,18 @@ std::vector<Parameter*> Rpc::parameters()
return parameters_;
}
Module::Module(std::vector<Rpc*> rpc_definitions, std::vector<GlobalVariable*> globals)
{
this->rpc_definitions_ = rpc_definitions;
this->globals_ = globals;
}
std::vector<Rpc*> Module::rpc_definitions()
{
return this->rpc_definitions_;
}
std::vector<GlobalVariable*> Module::globals()
{
return this->globals_;
}
......@@ -9,8 +9,34 @@ CCSTFile* generate_client_header(File* f)
}
CCSTFile* generate_client_source(File* f)
CCSTDeclaration* declare_static_variable(Variable *gv)
{
std::vector<CCSTDecSpecifier*> specifier;
specifier.push_back(new CCSTStoClassSpecifier(static_t));
std::vector<CCSTDecSpecifier*> type_for_global = type(gv->type());
specifier.insert(specifier.end(), type_for_global.begin(), type_for_global.end());
std::vector<CCSTInitDeclarator*> declarators;
declarators.push_back(new CCSTDeclarator( create_pointer( count_nested_pointer(gv->type())),
new CCSTDirectDecId(gv->identifier())));
return new CCSTDeclaration(specifier, declarators);
}
CCSTFile* generate_client_source(Module* f)
{
std::vector<CCSTExDeclaration*> definitions;
// declare globals
for(std::vector<GlobalVariable*>::iterator it = f->globals().begin(); it != f->globals().end(); it ++) {
GlobalVariable *gv = (GlobalVariable*) *it;
definitions.push_back(declare_static_variable(gv));
}
// create initialization function
std::vector<CCSTExDeclaration*> definitions;
for(std::vector<Rpc*>::iterator it = f->rpc_defs().begin(); it != f->rpc_defs().end(); it ++) {
Rpc *r = (Rpc*) *it;
......
......@@ -89,10 +89,12 @@ class Variable : public Base
class GlobalVariable : public Variable
{
Type *type_;
const char *id_;
public:
GlobalVariable(Type *type, const char *id);
virtual Type* type() = 0;
virtual const char* identifier() = 0;
virtual Type* type();
virtual const char* identifier();
};
class Parameter : public Variable
......@@ -213,12 +215,17 @@ class ProjectionField : public Variable //?
{
bool in_;
bool out_;
bool alloc_;
bool alloc_callee_;
bool alloc_caller_;
bool alloc_callee_caller_;
Type* field_type_;
const char* field_name_;
Variable *accessor_; //
public:
ProjectionField(bool in, bool out, bool alloc, bool bind, Type* field_type, const char* field_name);
ProjectionField(Type* field_type, const char* field_name);
~ProjectionField();
// virtual Marshal_type* accept(MarshalVisitor *worker, Registers *data);
virtual Type* type();
......@@ -226,8 +233,19 @@ class ProjectionField : public Variable //?
virtual const char* identifier();
virtual void set_accessor(Variable *v);
virtual Variable* accessor();
void set_in(bool b);
void set_out(bool b);
void set_alloc(bool b);
void set_alloc_caller(bool b);
void set_alloc_callee(bool b);
void set_alloc_callee_caller(bool b);
bool in();
bool out();
bool alloc();
bool alloc_caller():
bool alloc_callee();
bool alloc_callee_caller();
};
class ProjectionType : public Type // complex type
......@@ -322,6 +340,7 @@ class Module : public Base
public:
Module(std::vector<Rpc*> rpc_definitions, std::vector<GlobalVariable*> globals);
std::vector<Rpc*> rpc_definitions();
std::vector<GlobalVariable*> globals();
};
class Project : public Base
......
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