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

committing separate source-gen for caller and callee, but unimplimented, want to switch branches

parent 5680e04e
#include "gen_visitor.h"
SourceVisitor::SourceVisitor(FILE* out)
Caller_SourceVisitor::SourceVisitor(FILE* out)
{
this->out_f_ = out;
}
void SourceVisitor::visit(File* f)
void Caller_SourceVisitor::visit(File* f)
{
for(std::vector<Rpc*>::iterator it = f->rpc_defs()->begin(); it != f->rpc_defs()->end(); it++)
{
......@@ -16,7 +16,7 @@ void SourceVisitor::visit(File* f)
}
void SourceVisitor::visit(Rpc* r)
void Caller_SourceVisitor::visit(Rpc* r)
{
Type* rt = r->return_type();
......@@ -43,23 +43,23 @@ void SourceVisitor::visit(Rpc* r)
fprintf(this->out_f_, "}\n");
}
void SourceVisitor::visit(Parameter* p)
void Caller_SourceVisitor::visit(Parameter* p)
{
p->type()->accept(this);
// print p->name_
fprintf(this->out_f_, " %s", p->name());
}
void SourceVisitor::visit(ProjectionType *p)
void Caller_SourceVisitor::visit(ProjectionType *p)
{
fprintf(this->out_f_, "%s", p->real_type());
}
void SourceVisitor::visit(ProjectionField *pf)
void Caller_SourceVisitor::visit(ProjectionField *pf)
{
}
void SourceVisitor::visit(IntegerType *it)
void Caller_SourceVisitor::visit(IntegerType *it)
{
if(it->unsigned_huh())
fprintf(this->out_f_, "unsigned ");
......@@ -67,13 +67,91 @@ void SourceVisitor::visit(IntegerType *it)
fprintf(this->out_f_, "%s", it->type());
}
void SourceVisitor::visit(PointerType *pt)
void Caller_SourceVisitor::visit(PointerType *pt)
{
pt->p_type()->accept(this);
fprintf(this->out_f_, "* ");
}
void SourceVisitor::visit(Typedef* td)
void Caller_SourceVisitor::visit(Typedef* td)
{
fprintf(this->out_f_, "%s", td->alias());
}
Callee_SourceVisitor::SourceVisitor(FILE* out)
{
this->out_f_ = out;
}
void Callee_SourceVisitor::visit(File* f)
{
for(std::vector<Rpc*>::iterator it = f->rpc_defs()->begin(); it != f->rpc_defs()->end(); it++)
{
Rpc* r = (Rpc*) *it;
r->accept(this);
fprintf(this->out_f_, "\n\n");
}
}
void Callee_SourceVisitor::visit(Rpc* r)
{
Type* rt = r->return_type();
printf("here in hv hisit rpc\n");
printf("%d\n", rt->num());
rt->accept(this); // this seems unnecessary in this case
const char* name = r->name();
fprintf(this->out_f_, " %s(", name);
for(std::vector<Parameter*>::iterator it = r->parameters()->begin(); it != r->parameters()->end(); it++)
{
Parameter* p = (Parameter*) *it;
p->accept(this);
if((it+1) != r->parameters()->end())
fprintf(this->out_f_, ", ");
}
fprintf(this->out_f_, ") {\n");
for(std::vector<Parameter*>::iterator it = r->parameters()->begin(); it != r->parameters()->end(); it++)
{
Parameter* p = (Parameter*) *it;
fprintf(this->out_f_, "%s\n", p->marshal());
}
fprintf(this->out_f_, "}\n");
}
void Callee_SourceVisitor::visit(Parameter* p)
{
p->type()->accept(this);
// print p->name_
fprintf(this->out_f_, " %s", p->name());
}
void Callee_SourceVisitor::visit(ProjectionType *p)
{
fprintf(this->out_f_, "%s", p->real_type());
}
void Callee_SourceVisitor::visit(ProjectionField *pf)
{
}
void Callee_SourceVisitor::visit(IntegerType *it)
{
if(it->unsigned_huh())
fprintf(this->out_f_, "unsigned ");
fprintf(this->out_f_, "%s", it->type());
}
void Callee_SourceVisitor::visit(PointerType *pt)
{
pt->p_type()->accept(this);
fprintf(this->out_f_, "* ");
}
void Callee_SourceVisitor::visit(Typedef* td)
{
fprintf(this->out_f_, "%s", td->alias());
}
......
......@@ -33,7 +33,23 @@ class HeaderVisitor : public GenVisitor
virtual void visit(Typedef* td);
};
class SourceVisitor : public GenVisitor
class Caller_SourceVisitor : public GenVisitor
{
FILE* out_f_;
// int stub_or_proxy_; // 1 equals stub, 2 equals proxy
public:
SourceVisitor(FILE* out);
virtual void visit(File *f);
virtual void visit(Rpc *rpc);
virtual void visit(Parameter * p);
virtual void visit(ProjectionType * p);
virtual void visit(ProjectionField * pf);
virtual void visit(IntegerType * it);
virtual void visit(PointerType * it);
virtual void visit(Typedef* td);
};
class Callee_SourceVisitor : public GenVisitor
{
FILE* out_f_;
// int stub_or_proxy_; // 1 equals stub, 2 equals proxy
......
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