switched to structs insetead of classes
This commit is contained in:
parent
1357458094
commit
8e968ffb41
|
@ -1,13 +1,15 @@
|
||||||
/*
|
/*
|
||||||
* Statement.c
|
* Statement.cpp
|
||||||
* Implementation of functions used to build the syntax tree.
|
* Implementation of functions used to build the syntax tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Statement.h"
|
#include "Statement.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
Statement::Statement(EStatementType type) : type(type) {};
|
Statement::Statement(EStatementType type) : type(type) {
|
||||||
|
|
||||||
SelectStatement::SelectStatement() : Statement(eSelect) {};
|
};
|
||||||
|
|
||||||
TableRef::TableRef(ETableRefType type) : type(type) {};
|
SelectStatement::SelectStatement() : Statement(eSelect) {
|
||||||
|
|
||||||
|
};
|
|
@ -7,8 +7,7 @@
|
||||||
|
|
||||||
#include "Expr.h"
|
#include "Expr.h"
|
||||||
#include "List.h"
|
#include "List.h"
|
||||||
|
#include "Table.h"
|
||||||
class TableRef;
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
eSelect,
|
eSelect,
|
||||||
|
@ -18,17 +17,14 @@ typedef enum {
|
||||||
} EStatementType;
|
} EStatementType;
|
||||||
|
|
||||||
|
|
||||||
|
struct Statement {
|
||||||
class Statement {
|
|
||||||
public:
|
|
||||||
Statement(EStatementType type);
|
Statement(EStatementType type);
|
||||||
|
|
||||||
EStatementType type;
|
EStatementType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class SelectStatement : public Statement {
|
struct SelectStatement : Statement {
|
||||||
public:
|
|
||||||
SelectStatement();
|
SelectStatement();
|
||||||
|
|
||||||
TableRef* from_table;
|
TableRef* from_table;
|
||||||
|
@ -38,24 +34,17 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
struct DeleteStatement : Statement {
|
||||||
* TableRef
|
// TODO
|
||||||
* Holds reference to tables. Can be either table names or a select statement.
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
eTableName,
|
|
||||||
eTableSelect
|
|
||||||
} ETableRefType;
|
|
||||||
|
|
||||||
class TableRef {
|
|
||||||
public:
|
|
||||||
TableRef(ETableRefType type);
|
|
||||||
|
|
||||||
ETableRefType type;
|
|
||||||
|
|
||||||
SelectStatement* stmt;
|
|
||||||
List<char*>* table_names;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct InsertStatement : Statement {
|
||||||
|
// TODO
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CreateStatement : Statement {
|
||||||
|
// TODO
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // __STATEMENT_H__
|
#endif // __STATEMENT_H__
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef __TABLEREF_H_
|
||||||
|
#define __TABLEREF_H_
|
||||||
|
|
||||||
|
class SelectStatement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TableRef
|
||||||
|
* Holds reference to tables. Can be either table names or a select statement.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
eTableName,
|
||||||
|
eTableSelect
|
||||||
|
} ETableRefType;
|
||||||
|
|
||||||
|
|
||||||
|
struct TableRef {
|
||||||
|
TableRef(ETableRefType type) : type(type) {}
|
||||||
|
|
||||||
|
ETableRefType type;
|
||||||
|
SelectStatement* stmt;
|
||||||
|
List<char*>* table_names;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -151,7 +151,7 @@ int main(int argc, char *argv[]) {
|
||||||
SelectTest2();
|
SelectTest2();
|
||||||
SelectTest3(true);
|
SelectTest3(true);
|
||||||
ThreadSafeTest(10, 1000);
|
ThreadSafeTest(10, 1000);
|
||||||
Benchmark1(500000);
|
Benchmark1(10000);
|
||||||
|
|
||||||
printf("\n## Finished running all tests...\n");
|
printf("\n## Finished running all tests...\n");
|
||||||
printf("######################################\n");
|
printf("######################################\n");
|
||||||
|
|
Loading…
Reference in New Issue