Commit 7b668427 authored by Sarah Spall's avatar Sarah Spall Committed by Vikram Narayanan

pointer is no longer treated as a type

parent 43e429fc
......@@ -2,10 +2,11 @@
/* global variable */
GlobalVariable::GlobalVariable(Type *type, const char *id)
GlobalVariable::GlobalVariable(Type *type, const char *id, int pointer_count)
{
this->type_ = type;
this->id_ = id;
this->pointer_count_ = pointer_count;
}
Type* GlobalVariable::type()
......@@ -35,10 +36,71 @@ Marshal_type* GlobalVariable::marshal_info()
return 0x0;
}
Rpc* GlobalVariable::scope()
int GlobalVariable::pointer_count()
{
printf("Error: this operation not allowed\n");
return 0x0;
return this->pointer_count_;
}
void GlobalVariable::set_in(bool b)
{
printf("this operation is now allowed\n");
}
void GlobalVariable::set_out(bool b)
{
printf("this operation is now allowed\n");
}
void GlobalVariable::set_alloc(bool b)
{
printf("this operation is now allowed\n");
}
void GlobalVariable::set_alloc_caller(bool b)
{
printf("this operation is now allowed\n");
}
void GlobalVariable::set_alloc_callee(bool b)
{
printf("this operation is now allowed\n");
}
void GlobalVariable::set_alloc_callee_caller(bool b)
{
printf("this operation is now allowed\n");
}
bool GlobalVariable::in()
{
printf("this operation is now allowed\n");
return false;
}
bool GlobalVariable::out()
{
printf("this operation is now allowed\n");
return false;
}
bool GlobalVariable::alloc()
{
printf("this operation is now allowed\n");
return false;
}
bool GlobalVariable::alloc_caller()
{
printf("this operation is now allowed\n");
return false;
}
bool GlobalVariable::alloc_callee()
{
printf("this operation is now allowed\n");
return false;
}
bool GlobalVariable::alloc_callee_caller()
{
printf("this operation is now allowed\n");
return false;
}
// probably more functions needed
......@@ -51,12 +113,26 @@ Parameter::Parameter()
{
this->type_ = 0x0;
this->name_ = "";
this->pointer_count_ = 0;
this->in_ = false;
this->out_ = false;
this->alloc_ = false;
this->alloc_callee_ = false;
this->alloc_caller_ = false;
this->alloc_callee_caller_ = false;
}
Parameter::Parameter(Type* type, const char* name)
Parameter::Parameter(Type* type, const char* name, int pointer_count)
{
this->type_ = type;
this->name_ = name;
this->pointer_count_ = pointer_count;
this->in_ = false;
this->out_ = false;
this->alloc_ = false;
this->alloc_callee_ = false;
this->alloc_caller_ = false;
this->alloc_callee_caller_ = false;
}
/*
......@@ -76,9 +152,9 @@ Type* Parameter::type()
return this->type_;
}
Rpc* Parameter::scope()
int Parameter::pointer_count()
{
return this->function_;
return this->pointer_count_;
}
void Parameter::set_accessor(Variable *v)
......@@ -101,6 +177,65 @@ Marshal_type* Parameter::marshal_info()
return this->marshal_info_;
}
void Parameter::set_in(bool b)
{
this->in_ = b;
}
void Parameter::set_out(bool b)
{
this->out_ = b;
}
void Parameter::set_alloc(bool b)
{
this->alloc_ = b;
}
void Parameter::set_alloc_caller(bool b)
{
this->alloc_caller_ = b;
}
void Parameter::set_alloc_callee(bool b)
{
this->alloc_callee_ = b;
}
void Parameter::set_alloc_callee_caller(bool b)
{
this->alloc_callee_caller_ = b;
}
bool Parameter::in()
{
return this->in_;
}
bool Parameter::out()
{
return this->out_;
}
bool Parameter::alloc()
{
return this->alloc_;
}
bool Parameter::alloc_caller()
{
return this->alloc_caller_;
}
bool Parameter::alloc_callee()
{
return this->alloc_callee_;
}
bool Parameter::alloc_callee_caller()
{
return this->alloc_callee_caller_;
}
/* end */
/* Return Variable */
......@@ -111,10 +246,11 @@ ReturnVariable::ReturnVariable()
}
ReturnVariable::ReturnVariable(Type *return_type)
ReturnVariable::ReturnVariable(Type *return_type, int pointer_count)
{
this->type_ = return_type;
this->name_ = "";
this->pointer_count_ = pointer_count;
}
void ReturnVariable::set_marshal_info(Marshal_type *mt)
......@@ -142,9 +278,9 @@ void ReturnVariable::set_accessor(Variable *v)
this->accessor_ = v;
}
Rpc* ReturnVariable::scope()
int ReturnVariable::pointer_count()
{
return this->function_;
return this->pointer_count_;
}
Variable* ReturnVariable::accessor()
......@@ -152,6 +288,71 @@ Variable* ReturnVariable::accessor()
return this->accessor_;
}
void ReturnVariable::set_in(bool b)
{
printf("error this operation not allowed\n");
}
void ReturnVariable::set_out(bool b)
{
printf("error this operation not allowed\n");
}
void ReturnVariable::set_alloc(bool b)
{
printf("error this operation not allowed\n");
}
void ReturnVariable::set_alloc_caller(bool b)
{
printf("error this operation not allowed\n");
}
void ReturnVariable::set_alloc_callee(bool b)
{
printf("error this operation not allowed\n");
}
void ReturnVariable::set_alloc_callee_caller(bool b)
{
printf("error this operation not allowed\n");
}
bool ReturnVariable::in()
{
printf("error this operation not allowed\n");
return false;
}
bool ReturnVariable::out()
{
printf("error this operation not allowed\n");
return false;
}
bool ReturnVariable::alloc()
{
printf("error this operation not allowed\n");
return false;
}
bool ReturnVariable::alloc_caller()
{
printf("error this operation not allowed\n");
return false;
}
bool ReturnVariable::alloc_callee()
{
printf("error this operation not allowed\n");
return false;
}
bool ReturnVariable::alloc_callee_caller()
{
printf("error this operation not allowed\n");
return false;
}
/* end */
/* implicit return variable */
......@@ -187,9 +388,9 @@ const char* ImplicitReturnVariable::identifier()
return this->p_->identifier();
}
Rpc* ImplicitReturnVariable::scope()
int ImplicitReturnVariable::pointer_count()
{
return this->function_;
return this->p_->pointer_count();
}
Variable* ImplicitReturnVariable::accessor()
......@@ -197,11 +398,76 @@ Variable* ImplicitReturnVariable::accessor()
return this->accessor_;
}
void ImplicitReturnVariable::set_in(bool b)
{
printf("error this operation not allowed\n");
}
void ImplicitReturnVariable::set_out(bool b)
{
printf("error this operation not allowed\n");
}
void ImplicitReturnVariable::set_alloc(bool b)
{
printf("error this operation not allowed\n");
}
void ImplicitReturnVariable::set_alloc_caller(bool b)
{
printf("error this operation not allowed\n");
}
void ImplicitReturnVariable::set_alloc_callee(bool b)
{
printf("error this operation not allowed\n");
}
void ImplicitReturnVariable::set_alloc_callee_caller(bool b)
{
printf("error this operation not allowed\n");
}
bool ImplicitReturnVariable::in()
{
printf("error this operation not allowed\n");
return false;
}
bool ImplicitReturnVariable::out()
{
printf("error this operation not allowed\n");
return false;
}
bool ImplicitReturnVariable::alloc()
{
printf("error this operation not allowed\n");
return false;
}
bool ImplicitReturnVariable::alloc_caller()
{
printf("error this operation not allowed\n");
return false;
}
bool ImplicitReturnVariable::alloc_callee()
{
printf("error this operation not allowed\n");
return false;
}
bool ImplicitReturnVariable::alloc_callee_caller()
{
printf("error this operation not allowed\n");
return false;
}
/* end */
/* projection field */
ProjectionField::ProjectionField(Type* field_type, const char* field_name)
ProjectionField::ProjectionField(Type* field_type, const char* field_name, int pointer_count)
{
this->in_ = false;
this->out_ = false;
......@@ -211,6 +477,7 @@ ProjectionField::ProjectionField(Type* field_type, const char* field_name)
this->alloc_callee_caller_ = false;
this->field_type_ = field_type;
this->field_name_ = field_name;
this->pointer_count_ = pointer_count;
}
/*
......@@ -225,9 +492,9 @@ Type* ProjectionField::type()
return this->field_type_;
}
Rpc* ProjectionField::scope()
int ProjectionField::pointer_count()
{
return this->accessor_->scope();
return this->pointer_count_;
}
const char* ProjectionField::identifier()
......
......@@ -95,60 +95,108 @@ class Variable : public Base
virtual void set_accessor(Variable *v) = 0;
virtual Variable* accessor() = 0;
virtual Marshal_type* marshal_info() = 0;
virtual Rpc* scope() = 0;
virtual int pointer_count();
virtual void set_in(bool b) = 0;
virtual void set_out(bool b) = 0;
virtual void set_alloc(bool b) = 0;
virtual void set_alloc_caller(bool b) = 0;
virtual void set_alloc_callee(bool b) = 0;
virtual void set_alloc_callee_caller(bool b) = 0;
virtual bool in() = 0;
virtual bool out() = 0;
virtual bool alloc() = 0;
virtual bool alloc_caller() = 0;
virtual bool alloc_callee() = 0;
virtual bool alloc_callee_caller() = 0;
};
class GlobalVariable : public Variable
{
Type *type_;
const char *id_;
int pointer_count_;
public:
GlobalVariable(Type *type, const char *id);
GlobalVariable(Type *type, const char *id, int pointer_count);
virtual Type* type();
virtual const char* identifier();
virtual void set_accessor(Variable *v);
virtual Variable* accessor();
virtual Marshal_type* marshal_info();
virtual Rpc* scope();
virtual int pointer_count();
virtual void set_in(bool b);
virtual void set_out(bool b);
virtual void set_alloc(bool b);
virtual void set_alloc_caller(bool b);
virtual void set_alloc_callee(bool b);
virtual void set_alloc_callee_caller(bool b);
virtual bool in();
virtual bool out();
virtual bool alloc();
virtual bool alloc_caller();
virtual bool alloc_callee();
virtual bool alloc_callee_caller();
};
class Parameter : public Variable
{
bool in_;
bool out_;
bool alloc_;
bool alloc_callee_;
bool alloc_caller_;
bool alloc_callee_caller_;
Type* type_;
const char* name_;
Marshal_type *marshal_info_;
bool in_;
bool out_;
bool alloc_;
bool bind_;
Variable *accessor_;
Rpc *function_;
int pointer_count_;
public:
Parameter();
Parameter(Type* type, const char* name);
Parameter(Type* type, const char* name, int pointer_count);
~Parameter();
// virtual Marshal_type* accept(MarshalVisitor *worker, Registers *data);
virtual Type* type();
virtual Rpc* scope();
void set_marshal_info(Marshal_type* mt); // ??????????????????????????????
Marshal_type* marshal_info(); //???????????????????????????????????
virtual const char* identifier();
virtual void set_accessor(Variable *v);
virtual bool bind();
virtual bool alloc();
virtual Variable* accessor();
virtual int pointer_count();
virtual void set_in(bool b);
virtual void set_out(bool b);
virtual void set_alloc(bool b);
virtual void set_alloc_caller(bool b);
virtual void set_alloc_callee(bool b);
virtual void set_alloc_callee_caller(bool b);
virtual bool in();
virtual bool out();
virtual Variable* accessor();
virtual bool alloc();
virtual bool alloc_caller();
virtual bool alloc_callee();
virtual bool alloc_callee_caller();
};
// a parameter without a name
class FPParameter : public Parameter
{
Type *type_;
int pointer_count_;
public:
FPParameter(Type *type);
FPParameter(Type *type, int pointer_count);
virtual Type* type();
virtual const char* identifier();
virtual int pointer_count();
};
class FunctionPointer : public Type
......@@ -212,20 +260,6 @@ class IntegerType : public Type
~IntegerType(){printf("inttype destructor\n");}
};
class PointerType : public Type
{
Type* type_;
public:
PointerType(Type* type);
// virtual Marshal_type* accept(MarshalVisitor *worker, Registers *data);
virtual CCSTTypeName* accept(TypeNameVisitor *worker);
virtual CCSTStatement* accept(AllocateTypeVisitor *worker, Variable *v);
virtual const char* name();
Type* type();
virtual int num();
~PointerType(){printf("pointer type destructor\n");}
};
class ProjectionField : public Variable //?
{
bool in_;
......@@ -238,30 +272,32 @@ class ProjectionField : public Variable //?
Type* field_type_;
const char* field_name_;
Variable *accessor_; //
int pointer_count_;
public:
ProjectionField(Type* field_type, const char* field_name);
ProjectionField(Type* field_type, const char* field_name, int pointer_count);
~ProjectionField();
// virtual Marshal_type* accept(MarshalVisitor *worker, Registers *data);
virtual Type* type();
virtual Rpc* scope();
virtual const char* identifier();
virtual void set_accessor(Variable *v);
virtual Variable* accessor();
virtual Marshal_type* marshal_info();
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();
virtual int pointer_count();
virtual void set_in(bool b);
virtual void set_out(bool b);
virtual void set_alloc(bool b);
virtual void set_alloc_caller(bool b);
virtual void set_alloc_callee(bool b);
virtual void set_alloc_callee_caller(bool b);
virtual bool in();
virtual bool out();
virtual bool alloc();
virtual bool alloc_caller();
virtual bool alloc_callee();
virtual bool alloc_callee_caller();
};
class ProjectionType : public Type // complex type
......@@ -290,19 +326,33 @@ class ReturnVariable : public Variable
Type* type_;
Marshal_type *marshal_info_;
Variable* accessor_;
Rpc* function_;
int pointer_count_;
public:
ReturnVariable();
ReturnVariable(Type* return_type);
ReturnVariable(Type* return_type, int pointer_count);
void set_marshal_info(Marshal_type *mt);
Marshal_type* marshal_info();
virtual const char* identifier();
virtual Type* type();
virtual void set_accessor(Variable *v);
virtual Rpc* scope();
virtual Variable* accessor();
virtual int pointer_count();
virtual void set_in(bool b);
virtual void set_out(bool b);
virtual void set_alloc(bool b);
virtual void set_alloc_caller(bool b);
virtual void set_alloc_callee(bool b);
virtual void set_alloc_callee_caller(bool b);
virtual bool in();
virtual bool out();
virtual bool alloc();
virtual bool alloc_caller();
virtual bool alloc_callee();
virtual bool alloc_callee_caller();
};
class ImplicitReturnVariable : public ReturnVariable
......@@ -310,7 +360,6 @@ class ImplicitReturnVariable : public ReturnVariable
Parameter* p_;
Marshal_type *marshal_info_;
Variable *accessor_;
Rpc* function_;
public:
ImplicitReturnVariable(Parameter *p);
......@@ -320,8 +369,22 @@ class ImplicitReturnVariable : public ReturnVariable
virtual void set_accessor(Variable *v);
virtual Type* type();
virtual const char* identifier();
virtual Rpc* scope();
virtual Variable* accessor();
virutal int pointer_count();
virtual void set_in(bool b);
virtual void set_out(bool b);
virtual void set_alloc(bool b);
virtual void set_alloc_caller(bool b);
virtual void set_alloc_callee(bool b);
virtual void set_alloc_callee_caller(bool b);
virtual bool in();
virtual bool out();
virtual bool alloc();
virtual bool alloc_caller();
virtual