Commit 892ac32a authored by Sarah Spall's avatar Sarah Spall Committed by Vikram Narayanan

updating repo to reflect the file reorganizaiton on my computer

parent 78f016d1
#ifndef LCD_HEADER_GENERATOR_H_
#define LCD_HEADER_GENERATOR_H_
#include "lcd_ast.h"
#include <stdio.h>
int GenerateHeader(Scope* tree, FILE* out_file);
#endif // LCD_HEADER_GENERATOR_H_
......@@ -8,12 +8,18 @@ enum PrimType { kChar = 1, kShort, kInt, kLong, kLongLong, kCapability};
class Base
{
M_info info;
};
class Scope : public Base
{
// add built in types here, so size can be evaluated before parse
private:
map<int,Type> types_;
void init_types();
public:
Scope();
lookup_symbol(char* sym);
};
class Type : public Base
......@@ -21,6 +27,7 @@ class Type : public Base
public:
virtual void accept(ASTVisitor *worker) = 0;
virtual void marshal() = 0;
virtual int size() = 0;
};
class Typedef : public Type
......@@ -42,8 +49,8 @@ class IntegerType : public Type
int size_:
public:
PrimitiveType(TypeModifier type_mod, PrimType primitive)
{ this->type_modifier_ = type_mod; this->primitive_ = primitive; }
IntegerType(PrimType type, bool unsigned, int size)
{ this->unsigned_ = unsigned; this->type_ = type; this->size_ = size;}
virtual void accept(ASTVisitor *worker) { worker->visit(this); }
virtual void marshal();
};
......@@ -95,10 +102,10 @@ class Parameter : public Base
{
Type* type_;
char* name_;
M_info m;
public:
Parameter(Type* type, char* name)
{ this->type_ = type; this->name_ = name; }
{ this->type_ = type; this->name_ = name; m = new M_info(); }
~Parameter();
void accept(ASTVisitor *worker) { worker->visit(this); }
};
......
#ifndef _peg_Parser_
#define _peg_Parser_
#include <string>
namespace Parser{
/* filename should be a path to a file */
extern const void * parse(const std::string & filename, bool stats = false);
/* data contains the bytes that will be parsed */
extern const void * parse(const char * data, bool stats = false);
/* ParseException can be thrown by the parser in case of parser failure */
class ParseException: public std::exception {
public:
std::string getReason() const;
int getLine() const;
int getColumn() const;
virtual ~ParseException() throw();
};
} /* Parser */
#endif
#ifndef MARSHAL_OP
#define MARSHAL_OP
class M_info
{
size_t size_;
};
class M_rpc : public M_info
{
/*
bool regs[LCD_MAX_REGS];
bool cap_regs[LCD_MAX_CAP_REGS]; */
public:
M_rpc();
};
class M_proj : public M_info
{
public:
M_proj(size_t size) { size_ = size; }
};
class M_param : public M_info
{
int reg;
int size;
public:
M_param();
init(int size, int reg);
};
class M_projType : public M_info
{
public:
M_projType(size_t size) { size_ = size; }
};
class M_intType : public M_info
{
public:
M_intType(size_t size) {size_ = size; }
};
class M_pointerType : public M_info
{
public:
M_pointerType(size_t size) { size_ = size; }
};
#ifndef _MARSHAL_
#define _MARHSAL_
#include "visitor.h"
class MarshalVisitor : public ASTVisitor
{
bool regs[LCD_MAX_REGS];
bool cap_regs[LCD_MAX_CAP_REGS];
int find_free_reg();
void set_reg_used(int reg);
public:
virtual void visit(File *file);
// virtual void visit(Message *message);
// virtual void visit(MessageField *message_field);
virtual void visit(ProjectionField *proj_field);
virtual void visit(Rpc *rpc);
virtual void visit(Parameter *parameter);
// Types
virtual void visit(ProjectionType *proj_type);
virtual void visit(IntegerType *this);
virtual void visit(PointerType *this);
virtual void visit(Typedef* this);
MarshalVisitor();
};
class packVisitor : public ASTVisitor
{
public:
virtual void visit(File *file);
// virtual void visit(Message *message);
// virtual void visit(MessageField *message_field);
virtual void visit(ProjectionField *proj_field);
virtual void visit(Rpc *rpc);
virtual void visit(Parameter *parameter);
// Types
virtual void visit(ProjectionType *proj_type);
virtual void visit(IntegerType *this);
virtual void visit(PointerType *this);
virtual void visit(Typedef* this);
packVisitor();
};
#endif
#ifndef SCOPE_H
#define SCOPE_H
#include "lcd_ast.h"
class Root_scope : public Scope
{
static Root_scope * instance_;
Root_scope();
public:
static Root_scope * instance();
something lookup_symbol(char * type);
something insert_symbol(char* type, value);
}
#endif
#ifndef LCD_SOURCE_GENERATOR_H_
#define LCD_SOURCE_GENERATOR_H_
#include "lcd_ast.h"
#include <stdio.h>
int GenerateSource(Scope* tree, FILE* out_file);
#endif // LCD_SOURCE_GENERATOR_H_
#ifndef _STUB_GENERATOR_
#define _STUB_GENERATOR_
#include "ast.h"
#include "header-generator.h"
#include <stdio.h>
#include <cstring>
#include <cstdlib>
int generate_stub_file(Interface * i, FILE * f_out);
#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