compiler: CMake-ify
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
project(compiler)
|
||||
|
||||
add_library(${PROJECT_NAME} MODULE
|
||||
"assem.hpp"
|
||||
"codegen.hpp"
|
||||
"compiler.cpp"
|
||||
"compiler.hpp"
|
||||
"decl.cpp"
|
||||
"decl.hpp"
|
||||
"declnode.cpp"
|
||||
"declnode.hpp"
|
||||
"environ.cpp"
|
||||
"environ.hpp"
|
||||
"ex.hpp"
|
||||
"exprnode.cpp"
|
||||
"exprnode.hpp"
|
||||
"label.hpp"
|
||||
"node.cpp"
|
||||
"node.hpp"
|
||||
"nodes.hpp"
|
||||
"parser.cpp"
|
||||
"parser.hpp"
|
||||
"prognode.cpp"
|
||||
"prognode.hpp"
|
||||
"std.cpp"
|
||||
"std.hpp"
|
||||
"stmtnode.cpp"
|
||||
"stmtnode.hpp"
|
||||
"stringmap.hpp"
|
||||
"toker.cpp"
|
||||
"toker.hpp"
|
||||
"type.cpp"
|
||||
"type.hpp"
|
||||
"var.hpp"
|
||||
"varnode.cpp"
|
||||
"varnode.hpp"
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
config
|
||||
stdutil
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
${PROJECT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
target_compile_definitions(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
_CRT_SECURE_NO_WARNINGS
|
||||
# windows.h
|
||||
WIN32_LEAN_AND_MEAN
|
||||
NOGPICAPMASKS
|
||||
NOVIRTUALKEYCODES
|
||||
NOWINMESSAGES
|
||||
NOWINSTYLES
|
||||
NOSYSMETRICS
|
||||
NOMENUS
|
||||
NOICONS
|
||||
NOKEYSTATES
|
||||
NOSYSCOMMANDS
|
||||
NORASTEROPS
|
||||
NOSHOWWINDOW
|
||||
NOATOM
|
||||
NOCLIPBOARD
|
||||
NOCOLOR
|
||||
NOCTLMGR
|
||||
NODRAWTEXT
|
||||
NOGDI
|
||||
NOKERNEL
|
||||
NOUSER
|
||||
NONLS
|
||||
NOMB
|
||||
NOMEMMGR
|
||||
NOMETAFILE
|
||||
NOMINMAX
|
||||
NOMSG
|
||||
NOOPENFILE
|
||||
NOSCROLL
|
||||
NOSERVICE
|
||||
NOSOUND
|
||||
NOTEXTMETRIC
|
||||
NOWH
|
||||
NOWINOFFSETS
|
||||
NOCOMM
|
||||
NOKANJI
|
||||
NOHELP
|
||||
NOPROFILER
|
||||
NODEFERWINDOWPOS
|
||||
NOMCX
|
||||
NOIME
|
||||
NOMDI
|
||||
NOINOUT
|
||||
)
|
||||
endif()
|
||||
@@ -2,7 +2,7 @@
|
||||
#ifndef ASSEM_H
|
||||
#define ASSEM_H
|
||||
|
||||
#include "..\LinkerLib\linker.h"
|
||||
#include "..\LinkerLib\linker.hpp"
|
||||
|
||||
class Assem{
|
||||
public:
|
||||
@@ -2,7 +2,7 @@
|
||||
#ifndef CODEGEN_H
|
||||
#define CODEGEN_H
|
||||
|
||||
#include "std.h"
|
||||
#include "std.hpp"
|
||||
|
||||
enum{
|
||||
IR_JUMP,IR_JUMPT,IR_JUMPF,IR_JUMPGE,
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
|
||||
#include "std.h"
|
||||
#include "decl.h"
|
||||
#include "type.h"
|
||||
#include "std.hpp"
|
||||
#include "decl.hpp"
|
||||
#include "type.hpp"
|
||||
|
||||
Decl::~Decl(){
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "std.h"
|
||||
#include "nodes.h"
|
||||
#include "std.hpp"
|
||||
#include "nodes.hpp"
|
||||
|
||||
//////////////////////////////
|
||||
// Sequence of declarations //
|
||||
|
||||
@@ -24,8 +24,8 @@ struct DeclSeqNode : public Node{
|
||||
int size(){ return decls.size(); }
|
||||
};
|
||||
|
||||
#include "exprnode.h"
|
||||
#include "stmtnode.h"
|
||||
#include "exprnode.hpp"
|
||||
#include "stmtnode.hpp"
|
||||
|
||||
//'kind' shouldn't really be in Parser...
|
||||
//should probably be LocalDeclNode,GlobalDeclNode,ParamDeclNode
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "std.h"
|
||||
#include "environ.h"
|
||||
#include "std.hpp"
|
||||
#include "environ.hpp"
|
||||
|
||||
Environ::Environ( const string &f,Type *r,int l,Environ *gs )
|
||||
:funcLabel(f),returnType(r),level(l),globals(gs){
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
#ifndef ENVIRON_H
|
||||
#define ENVIRON_H
|
||||
|
||||
#include "type.h"
|
||||
#include "decl.h"
|
||||
#include "label.h"
|
||||
#include "type.hpp"
|
||||
#include "decl.hpp"
|
||||
#include "label.hpp"
|
||||
|
||||
class Environ{
|
||||
public:
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "std.h"
|
||||
#include "nodes.h"
|
||||
#include "std.hpp"
|
||||
#include "nodes.hpp"
|
||||
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#ifndef EXPRNODE_H
|
||||
#define EXPRNODE_H
|
||||
|
||||
#include "node.h"
|
||||
#include "node.hpp"
|
||||
|
||||
struct ConstNode; //is constant int,float or string
|
||||
|
||||
@@ -30,7 +30,7 @@ struct ExprSeqNode : public Node {
|
||||
void castTo(Type *t, Environ *e);
|
||||
};
|
||||
|
||||
#include "varnode.h"
|
||||
#include "varnode.hpp"
|
||||
|
||||
struct CastNode : public ExprNode {
|
||||
ExprNode *expr;
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "std.h"
|
||||
#include "nodes.h"
|
||||
#include "std.hpp"
|
||||
#include "nodes.hpp"
|
||||
|
||||
set<string> Node::usedfuncs;
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
#ifndef NODE_H
|
||||
#define NODE_H
|
||||
|
||||
#include "ex.h"
|
||||
#include "toker.h"
|
||||
#include "environ.h"
|
||||
#include "codegen.h"
|
||||
#include "ex.hpp"
|
||||
#include "toker.hpp"
|
||||
#include "environ.hpp"
|
||||
#include "codegen.hpp"
|
||||
|
||||
struct VarNode;
|
||||
struct ConstNode;
|
||||
@@ -1,10 +0,0 @@
|
||||
|
||||
#ifndef NODES_H
|
||||
#define NODES_H
|
||||
|
||||
#include "exprnode.h"
|
||||
#include "stmtnode.h"
|
||||
#include "declnode.h"
|
||||
#include "prognode.h"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
#ifndef NODES_H
|
||||
#define NODES_H
|
||||
|
||||
#include "exprnode.hpp"
|
||||
#include "stmtnode.hpp"
|
||||
#include "declnode.hpp"
|
||||
#include "prognode.hpp"
|
||||
|
||||
#endif
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
|
||||
#include "std.h"
|
||||
#include "std.hpp"
|
||||
#include <cstdlib>
|
||||
#include "parser.h"
|
||||
#include "parser.hpp"
|
||||
|
||||
#ifdef DEMO
|
||||
static const int TEXTLIMIT=16384;
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#ifndef PARSER_H
|
||||
#define PARSER_H
|
||||
|
||||
#include "toker.h"
|
||||
#include "nodes.h"
|
||||
#include "toker.hpp"
|
||||
#include "nodes.hpp"
|
||||
|
||||
class Parser{
|
||||
public:
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "std.h"
|
||||
#include "nodes.h"
|
||||
#include "std.hpp"
|
||||
#include "nodes.hpp"
|
||||
|
||||
//////////////////
|
||||
// The program! //
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#ifndef PROGNODE_H
|
||||
#define PROGNODE_H
|
||||
|
||||
#include "node.h"
|
||||
#include "codegen.h"
|
||||
#include "node.hpp"
|
||||
#include "codegen.hpp"
|
||||
|
||||
struct UserFunc{
|
||||
string ident,proc,lib;
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
|
||||
#include "std.h"
|
||||
#include "std.hpp"
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#ifndef STD_COMPILER_H
|
||||
#define STD_COMPILER_H
|
||||
|
||||
#include "../config/config.h"
|
||||
#include "../stdutil/stdutil.h"
|
||||
#include "config.hpp"
|
||||
#include "stdutil.hpp"
|
||||
|
||||
#include <set>
|
||||
#include <map>
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "std.h"
|
||||
#include "nodes.h"
|
||||
#include "std.hpp"
|
||||
#include "nodes.hpp"
|
||||
|
||||
static string fileLabel;
|
||||
static map<string, string> fileMap;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#ifndef STMTNODE_H
|
||||
#define STMTNODE_H
|
||||
|
||||
#include "node.h"
|
||||
#include "node.hpp"
|
||||
|
||||
struct StmtNode : public Node{
|
||||
int pos; //offset in source stream
|
||||
@@ -26,8 +26,8 @@ struct StmtSeqNode : public Node{
|
||||
static void reset( const string &file,const string &lab );
|
||||
};
|
||||
|
||||
#include "exprnode.h"
|
||||
#include "declnode.h"
|
||||
#include "exprnode.hpp"
|
||||
#include "declnode.hpp"
|
||||
|
||||
struct IncludeNode : public StmtNode{
|
||||
string file,label;
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
|
||||
#include "std.h"
|
||||
#include "std.hpp"
|
||||
#include <cctype>
|
||||
#include "toker.h"
|
||||
#include "ex.h"
|
||||
#include "toker.hpp"
|
||||
#include "ex.hpp"
|
||||
|
||||
int Toker::chars_toked;
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "std.h"
|
||||
#include "type.h"
|
||||
#include "std.hpp"
|
||||
#include "type.hpp"
|
||||
|
||||
static struct v_type : public Type{
|
||||
bool canCastTo( Type *t ){
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#ifndef TYPE_H
|
||||
#define TYPE_H
|
||||
|
||||
#include "decl.h"
|
||||
#include "decl.hpp"
|
||||
|
||||
struct FuncType;
|
||||
struct ArrayType;
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "std.h"
|
||||
#include "nodes.h"
|
||||
#include "std.hpp"
|
||||
#include "nodes.hpp"
|
||||
|
||||
//////////////////////////////////
|
||||
// Common get/set for variables //
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#ifndef VARNODE_H
|
||||
#define VARNODE_H
|
||||
|
||||
#include "varnode.h"
|
||||
#include "varnode.hpp"
|
||||
|
||||
struct VarNode : public Node{
|
||||
Type *sem_type;
|
||||
@@ -17,7 +17,7 @@ struct VarNode : public Node{
|
||||
virtual TNode *translate( Codegen *g )=0;
|
||||
};
|
||||
|
||||
#include "decl.h"
|
||||
#include "decl.hpp"
|
||||
|
||||
struct DeclVarNode : public VarNode{
|
||||
Decl *sem_decl;
|
||||
Reference in New Issue
Block a user