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

removing old files and committing new lcd files

parent 4f2b47d0
all: compiler
all: lcd_compiler
compiler: flounder_parser.o idl_compiler.o ast.o visitor.o
g++ flounder_parser.o visitor.o idl_compiler.o ast.o -o compiler
lcd_compiler: lcd_idl.o lcd_ast.o lcd_compiler.o
g++ lcd_idl.o lcd_ast.o lcd_compiler.o -o compiler
idl_compiler.o: idl_compiler.cpp flounder_parser.h
g++ -c -g idl_compiler.cpp flounder_parser.h
lcd_compiler.o: lcd_compiler.cpp lcd_idl.h
g++ -c -g lcd_compiler.cpp lcd_idl.h
ast.o: ast.cpp ast.h
g++ -c -g ast.cpp ast.h
lcd_ast.o: lcd_ast.cpp lcd_ast.h
g++ -c -g lcd_ast.cpp lcd_ast.h
visitor.o: visitor.cpp visitor.h
g++ -c -g visitor.cpp visitor.h
lcd_idl.o: lcd_ast.h lcd_idl.cpp lcd_idl.h
g++ -c -g lcd_idl.cpp lcd_idl.h
flounder_parser.o: flounder_parser.cpp flounder_parser.h
g++ -c -g flounder_parser.cpp flounder_parser.h
lcd_idl.cpp:
vembyr-1.1/peg.py --cpp lcd_idl.peg > lcd_idl.cpp
flounder_parser.cpp:
vembyr-1.1/peg.py --cpp flounder > flounder_parser.cpp
flounder_parser.h:
vembyr-1.1/peg.py --h flounder > flounder_parser.h
lcd_idl.h:
vembyr-1.1/peg.py --h lcd_idl.peg > lcd_idl.h
clean:
rm flounder_parser.* *.o compiler peg_peg.py
......
#include "ast.h"
Interface::Interface(char * n, char * desc, std::vector<Message*> * m)
{
name = n;
description = desc;
function_decs = m;
}
Interface::Interface(char * n, std::vector<Message*> * m)
{
name = n;
description = 0;
function_decs = m;
}
std::vector<Message*> *Interface::getMessages()
{
return this->function_decs;
}
void Interface::init_types()
{
// best way to do builtin types ?
this->types = new std::map<char *,char *>();
/*
bool cap char give_away_cap int int8
int16 int32 int64 intptr iref size
string uint8 uint16 uint32 uint64 uintptr
*/
// insert pairs
this->types->insert( std::pair<char *, char *>("bool", "int"));
// this for all in above....
}
void Interface::add_type_alias(char * a, char * b)
{
}
Message::Message(char * n, std::vector<Argument*> * a)
{
this->name = n;
this->args = a;
}
char * Message::getName()
{
return this->name;
}
std::vector<Argument*> *Message::getArguments()
{
return this->args;
}
Argument::Argument(Type * t_, char * n, char * s)
{
array = true;
t = t_;
name = n;
size = s;
}
Argument::Argument(Type * t_, char * n)
{
array = false;
t = t_;
name = n;
size = 0;
}
bool Argument::isDynamic()
{
return this->array;
}
Type * Argument::getType()
{
return this->t;
}
char * Argument::getName()
{
return this->name;
}
char * Argument::getSize()
{
return this->size;
}
Type::Type(char * t)
{
this->t = t;
}
char * Type::getStr()
{
return this->t;
}
#ifndef AST_H
#define AST_H
#include <vector>
#include <stdint.h>
class Type
{
char * t;
public:
Type(char * t);
char * getStr();
};
class Argument
{
bool array; // true if arg of form: int name[size]
Type * t;
char * name;
char * size; // NULL if array = false
public:
Argument(Type * t, char * n, char * s);
Argument(Type * t, char *n);
bool isDynamic();
Type * getType();
char * getName();
char * getSize();
};
class Message
{
char * name;
std::vector<Argument*> * args;
public:
Message(char * n, std::vector<Argument* > * a);
char * getName();
std::vector<Argument*> * getArguments();
};
class Interface
{
std::map<char *, char *> types;
char * name;
char * description;
std::vector<Message*> * function_decs;
void init_types();
public:
Interface(char * n, char * desc, std::vector<Message*> * m);
Interface(char * n, std::vector<Message*> * m);
std::vector<Message*> * getMessages();
};
enum builtin_type { bool_=1, cap_, char_, give_away_cap,
int_, int8, int16, int32, int64,
intptr, iref, size, string, uint8,
uint16, uint32, uint64, uintptr };
#endif
#include "lcd_ast.h"
Module::Module(char * n, std::vector<Rpc *>* rs, std::vector<Message *>* ms,
std::map<char *, Projection *>* e, std::map<char *, Module *>* mods)
{
this->name = n;
this->rpcs = rs;
this->messages = ms;
this->env = e;
this->modules = mods;
}
Module::Module(std::vector<char *>* in, std::vector<Rpc *>* rs, std::vector<Message *>* ms,
std::map<char *, Projection *>* e, std::map<char *, Module *>* mods)
{
this->includes = in;
this->rpcs = rs;
this->messages = ms;
this->env = e;
this->modules = mods;
}
char * Module::get_name()
{
return this->name;
}
Rpc::Rpc(Type* r, char * n, std::vector<Parameter *>* param)
{
this->ret = r;
this->name = n;
this->parameters = param;
}
Projection::Projection(char * name, Type* real, std::vector<ProjField *>* f)
{
this->name = name;
this->underlying = real;
this->fields = f;
}
char * Projection::get_name()
{
return this->name;
}
ProjField::ProjField(int s, Type* t, char * name)
{
this->specifications = s;
this->t = t;
this->name = name;
}
/* o is option such as "struct" or "projection
t is type such as "int"
m is module, "" if it belongs to top level
p is * etc */
Type::Type(char * o, char * t, char * m, char * p)
{
this->option = o;
this->type_ = t;
this->module = m;
this->pointer = p;
}
Parameter::Parameter(Type* t, char * n)
{
this->type = t;
this->name = n;
}
bool Parameter::isProjection()
{
}
Message::Message(char * n, std::vector<Capability *>* cap)
{
this->name = n;
this->caps = cap;
}
/* Capability constructor */
Capability::Capability(char * n)
{
this->name = n;
}
/* get name of capability */
char * Capability::get_name()
{
return this->name;
}
#ifndef LCD_AST_H
#define LCD_AST_H
#include <vector>
#include <map>
#define IN 0x1
#define OUT 0x2
#define BIND 0x4
#define ALLOC 0x8
enum definition_type {rpc, module, message, projection};
class Definition
{
public:
virtual definition_type get_definition_type() = 0;
};
class Type
{
char * option;
char * type_;
char * module;
char * pointer;
public:
Type(char * o, char * t, char * m, char * p);
};
class Parameter
{
Type* type;
char* name;
public:
Parameter(Type* t,char * n);
bool isProjection();
};
class Rpc : public Definition
{
Type* ret;
char * name;
std::vector<Parameter *>* parameters;
public:
Rpc(Type* r, char * n, std::vector<Parameter *>* param);
definition_type get_definition_type(){return rpc;}
};
class Capability // capability? for message
{
char * name;
public:
Capability(char * n);
char * get_name();
};
class ProjField
{
int specifications; // set bits for in out bind alloc
Type* t;
char * name;
public:
ProjField(int s, Type* t, char * name);
};
class Projection : public Definition
{
char * name;
Type* underlying;
std::vector<ProjField *>* fields;
public:
Projection(char * name, Type* real, std::vector<ProjField *>* f);
definition_type get_definition_type(){return projection;}
char * get_name();
};
class Message : public Definition
{
char * name;
std::vector<Capability *>* caps;
public:
Message(char * n, std::vector<Capability *>* e);
std::vector<Capability *>* get_capabilities();
definition_type get_definition_type() {return message; }
};
class Module
{
char * name; // just leave "" if top level
std::vector<char *> * includes; // only top level can have includes
std::vector<Rpc *> * rpcs;
std::vector<Message *> * messages;
std::map<char *, Projection *> *env;
std::map<char *, Module *> *modules;
public:
Module(char * n, std::vector<Rpc *>* rs, std::vector<Message *>* ms,
std::map<char *, Projection *>* e, std::map<char *, Module *>* mods);
// for top level
Module(std::vector<char *>* in, std::vector<Rpc *>* rs, std::vector<Message *>* ms,
std::map<char *, Projection *>* e, std::map<char *, Module *>* mods);
char * get_name();
};
#endif
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