Commit 5147626a authored by Sarah Spall's avatar Sarah Spall Committed by Vikram Narayanan

reverting for moment

parent 730fd7d4
......@@ -10,51 +10,30 @@ CCSTFile* generate_client_header(File* f)
}
CCSTFile* generate_client_source(File* f)
{
{
std::vector<CCSTExDeclaration*> definitions;
for(std::vector<Rpc*>::iterator it = f->rpc_defs().begin(); it != f->rpc_defs().end(); it ++) {
Rpc *r = (Rpc*) *it;
definitions.push_back(create_function_definition(create_function_declaration(r)
, create_caller_body(r)));
}
CCSTFile *c_file = new CCSTFile(definitions);
return c_file;
return new CCSTFile(definitions);
}
CCSTCompoundStatement* create_caller_body(Rpc *r)
{
std::vector<CCSTDeclaration*> declarations;
std::vector<CCSTStatement*> statements;
std::vector<Parameter*> params = r->parameters();
for(std::vector<Parameter*>::iterator it = params.begin(); it != params.end(); it ++) {
Parameter *p = (Parameter*) *it;
statements.push_back(marshal_parameter(p));
}
std::vector<CCSTStatement*> statements = marshal_parameters(r->parameters());
// implicit returns
std::vector<Marshal_type*> implicit_ret_info = r->implicit_ret_marshal_info();
for(std::vector<Marshal_type*>::iterator it = implicit_ret_info.begin(); it != implicit_ret_info.end(); it ++)
{
Marshal_type *mt = *it;
UnmarshalTypeVisitor *visitor = new UnmarshalTypeVisitor();
statements.push_back(mt->accept(visitor));
}
std::vector<CCSTStatement*> uirs = unmarshal_implicit_return(r->implicit_ret_marshal_info());
statements.insert(statements.end(), uirs.begin(), uirs.end());
if(r->explicit_return_type()->num() != 5) { // not void
Marshal_type *ret_info = r->explicit_ret_marshal_info();
CCSTPointer *p = 0x0;
if(r->explicit_return_type()->num() == 3) {
p = new CCSTPointer();
}
std::vector<CCSTDecSpecifier*> ret_type = type(r->explicit_return_type());
UnmarshalTypeVisitor *visitor = new UnmarshalTypeVisitor();
ret_info->accept(visitor);
statements.push_back(new CCSTReturn(adfads));
}
else {
statements.push_back(new CCSTReturn());
......@@ -63,3 +42,48 @@ CCSTCompoundStatement* create_caller_body(Rpc *r)
return new CCSTCompoundstatement(declarations, statements);
}
std::vector<CCSTStatement*> marshal_parameters(std::vector<Parameter*> params)
{
std::vector<CCSTStatement*> statements;
for(std::vector<Parameter*>::iterator it = params.begin(); it != params.end(); it ++) {
Parameter *p = (Parameter*) *it;
statements.push_back(marshal_parameter(p));
}
return statements;
}
std::vector<CCSTStatement*> unmarshal_implicit_return(std::vector<Parameter*> implicit_returns)
{
std::vector<CCSTStatement*> statements;
for(std::vector<Parameter*>::iterator it = implicit_returns.begin(); it != implicit_returns.end(); it ++) {
Parameter *p = *it;
UnmarshalTypeVisitor *visitor = new UnmarshalTypeVisitor();
statements.push_back(mt->accept(visitor));
}
return statements;
}
CCSTStatement* unmarshal_explicit_return(Marshal_type* return_info)
{
CCSTPointer *p = 0x0;
if(r->explicit_return_type()->num() == 3) {
p = new CCSTPointer();
}
std::vector<CCSTDecSpecifier*> ret_type = type(r->explicit_return_type());
UnmarshalTypeVisitor *visitor = new UnmarshalTypeVisitor();
std::vector<CCSTDeclaration*> d; std::vector<CCSTStatement*> s;
s.push_back(ret_info->accept(visitor));
s.push_back( new CCSTReturn(new CCSTPrimaryExprId("internal_ret")));
}
......@@ -7,19 +7,28 @@ CCSTCompoundStatement* unmarshal_parameter(Parameter *p)
return p->get_marshal_info()->accept(visitor);
}
CCSTCompoundStatement* unmarshal_value()
CCSTCompoundStatement* UnmarshalTypeVisitor::visit(Marshal_projection *data, const char *name)
{
// loop through fields.
for(std::vector<ProjectionField*>::iterator it = pt->fields().begin(); pt->fields().end(); it ++)
{
ProjectionField* pf = *it;
}
}
/* code to unmarshal parameters */
/*
// This code will produce the CAST that unmarshals the params. instead of where it was before
CCSTCompoundStatement* UnmarshalTypeVisitor::visit(Marshal_projection *data)
CCSTCompoundStatement* UnmarshalTypeVisitor::visit(Marshal_projection *data, const char *name)
{
ProjectionType *pt = dynamic_cast<ProjectionType*>(data->get_type());
Assert(pt != 0x0, "Error: Expected ProjectionType got something else.\n");
for(std::vector<ProjectionField*>::iterator it = pt->fields().begin(); pt->fields().end(); it ++)
{
}
std::vector<CCSTDeclaration*> declarations;
std::vector<CCSTStatement*> statements;
......@@ -65,6 +74,7 @@ CCSTCompoundStatement* UnmarshalTypeVisitor::visit(Marshal_projection *data)
}
return new CCSTCompoundStatement(declarations, statements);
}
*/
CCSTCompoundStatement* UnmarshalTypeVisitor::visit(Marshal_integer *data)
{
......
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