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

committing to switch branches

parent f1c4147b
......@@ -37,11 +37,13 @@ CCSTFile* generate_client_source(Module* f)
// 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;
definitions.push_back(create_function_definition(create_function_declaration(r)
, create_caller_body(r)));
definitions.push_back(function_definition(function_declaration(r)
,caller_body(r)));
}
return new CCSTFile(definitions);
......
#include "ccst.h"
/*
creates the C code for a container struct
for the projection provided
*/
CCSTDeclaration* container_struct(const char* name, ProjectionType *pt)
{
CCSTStructDeclaration *container_field = new CCSTStructDeclaration();
CCSTStructUnionSpecifier *container = new CCSTStructUnionSpecifier(struct_t, name, container_fields);
std::vector<CCSTDecSpecifier*> struct_specifier;
struct_specifier.push_back(container);
std::vector<CCSTInitDeclarator*> empty;
return new CCSTDeclaration(struct_specifier, empty);
}
CCSTPostFixExpr* access_variable(Variable *p)
{
if(p->accessor() == 0x0) {
......@@ -98,7 +118,7 @@ CCSTPointer* create_pointer(int p_count)
* from a function declaration
* and a body
*/
CCSTFuncDef* create_function_definition(CCSTDeclaration* function_declaration, CCSTCompoundStatement *body)
CCSTFuncDef* function_definition(CCSTDeclaration* function_declaration, CCSTCompoundStatement *body)
{
Assert(function_declaration->decs_.size() == 1, "Error: More than one initializer/declarator in function declaration");
......@@ -118,7 +138,7 @@ CCSTParamTypeList* create_parameter_list()
/* creates a function declaration
* from an rpc, not callee
*/
CCSTDeclaration* create_function_declaration(Rpc* r)
CCSTDeclaration* function_declaration(Rpc* r)
{
std::vector<CCSTDecSpecifier*> specifier = type(r->explicit_return_type());
......
......@@ -407,85 +407,101 @@ Projection = "projection" Space+ id:Identifier Spacing "<" Spacing t:Proj_type "
Proj_type = "struct" Space+ id:Identifier Spacing {{
value = id;}}
Keyword = "out" {{ int * x = (int *) malloc(sizeof(int));
*x = 1;
value = x; }}
| "in" {{ int * x = (int *) malloc(sizeof(int));
*x = 2;
value = x; }}
| "bind" {{ int * x = (int *) malloc(sizeof(int));
*x = 3;
value = x; }}
| "alloc" {{ int * x = (int *) malloc(sizeof(int));
*x = 4;
value = x; }}
Keyword = "out" {{
int * x = (int *) malloc(sizeof(int));
*x = 1;
value = x;
}}
| "in" {{
int * x = (int *) malloc(sizeof(int));
*x = 2;
value = x;
}}
| "alloc" Spacing OPEN Spacing "caller" Spacing "," "callee" Spacing CLOSE {{
int *x = (int*) malloc(sizeof(int));
*x = 6;
value = x;
}}
| "alloc" Spacing OPEN Spacing "caller" Spacing CLOSE {{
int *x = (int*) malloc(sizeof(int));
*x = 4;
value = x;
}}
| "alloc" Spacing OPEN Spacing "callee" Spacing CLOSE {{
int *x = (int*) malloc(sizeof(int));
*x = 5;
value = x;
}}
| "alloc" {{
int * x = (int *) malloc(sizeof(int));
*x = 3;
value = x;
}}
Start = k:Keyword Spacing COMMA Spacing {{ value = k; }}
Specification = s:Start* l:Last {{
std::vector<bool>* specs = new std::vector<bool>(4, false);
for(Value::iterator it = s.getValues().begin(); it != s.getValues().end(); it ++)
{
const Value & v = *it;
int* x = (int*) v.getValue();
if(!x)
{
printf("error x is null\n");
exit(0);
}
specs->at(*x -1) = true;
std::vector<bool>* specs = new std::vector<bool>(7, false);
for(Value::iterator it = s.getValues().begin(); it != s.getValues().end(); it ++) {
const Value & v = *it;
int* x = (int*) v.getValue();
if(!x) {
printf("error x is null\n");
exit(0);
}
specs->at(*x) = true;
}
int * y = (int *) l.getValue();
if(!y) { printf("error y is null\n"); exit(0); }
specs->at(*y-1) = true;
value = specs; }}
int * y = (int *) l.getValue();
if(!y) {
printf("error y is null\n"); exit(0);
}
specs->at(*y) = true;
value = specs;
}}
ProjField = t:Type_form Spacing OPENS Spacing s:Specification CLOSES Spacing id:Identifier Spacing SEMI Spacing {{
bool in = false; bool out = false; bool bind = false; bool alloc = false;
std::vector<bool>* specs = (std::vector<bool>*) s.getValue();
int i = 0;
ProjectionField *pf = new ProjectionField((Type *) t.getValue(), (char *) id.getValue());
if(specs->at(0) == true) {
out = true;
}
if(specs->at(1) == true) {
in = true;
}
if(specs->at(2) == true) {
bind = true;
}
if(specs->at(3) == true) {
alloc = true;
pf->set_out(true);
} if(specs->at(2) == true) {
pf->set_in(true);
} if(specs->at(3) == true) {
pf->set_alloc(true);
} if(specs->at(4) == true) {
pf->set_alloc_caller(true);
} if(specs->at(5) == true) {
pf->set_alloc_callee(true);
} if(specs->at(6) == true) {
pf->alloc_callee_caller(true);
}
std::vector<ProjectionField*> *fields = new std::vector<ProjectionField*>();
fields->push_back(new ProjectionField(in, out, alloc, bind, (Type *) t.getValue(), (char *) id.getValue()))
fields->push_back(pf);
value = fields;
}}
| "rpc" Space+ rt:Type_form Spacing OPENS Spacing s:Specification CLOSES Spacing OPEN Spacing "*" Spacing id:Identifier CLOSE Spacing OPEN p:FP_Parameters CLOSE SEMI Spacing {{
bool in = false; bool out = false; bool bind = false; bool alloc = false;
std::vector<bool>* specs = (std::vector<bool>*) s.getValue();
printf("In Proj field\n");
int i = 0;
printf("%zu", specs->size());
if(specs->at(0) == true) {
out = true;
}
if(specs->at(1) == true) {
in = true;
}
if(specs->at(2) == true) {
bind = true;
}
if(specs->at(3) == true) {
alloc = true;
FunctionPointer *fp = new FunctionPointer((char*) id.getValue(), (Type*) rt.getValue(), (std::vector<FPParameter*>) *p.getValue());
ProjectionField *pf = new ProjectionField(fp, (char*) id.getValue());
if(specs->at(1) == true) {
pf->set_out(true);
} if(specs->at(2) == true) {
pf->set_in(true);
} if(specs->at(3) == true) {
pf->set_alloc(true);
} if(specs->at(4) == true) {
pf->set_alloc_caller(true);
} if(specs->at(5) == true) {
pf->set_alloc_callee(true);
} if(specs->at(6) == true) {
pf->alloc_callee_caller(true);
}
FunctionPointer *fp = new FunctionPointer((char*) id.getValue(), (Type*) rt.getValue(), (std::vector<FPParameter*>) *p.getValue());
std::vector<ProjectionField*> *fields = new std::vector<ProjectionField*>();
fields->push_back(new ProjectionField(in, out, alloc, bind, fp, (char*) id.getValue()));
fields->push_back(pf);
value = fields;
}}
| pc_unnamed_scope
......
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