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
|
#ifndef ASSEM_H
|
||||||
#define ASSEM_H
|
#define ASSEM_H
|
||||||
|
|
||||||
#include "..\LinkerLib\linker.h"
|
#include "..\LinkerLib\linker.hpp"
|
||||||
|
|
||||||
class Assem{
|
class Assem{
|
||||||
public:
|
public:
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
#ifndef CODEGEN_H
|
#ifndef CODEGEN_H
|
||||||
#define CODEGEN_H
|
#define CODEGEN_H
|
||||||
|
|
||||||
#include "std.h"
|
#include "std.hpp"
|
||||||
|
|
||||||
enum{
|
enum{
|
||||||
IR_JUMP,IR_JUMPT,IR_JUMPF,IR_JUMPGE,
|
IR_JUMP,IR_JUMPT,IR_JUMPF,IR_JUMPGE,
|
||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
#include "std.h"
|
#include "std.hpp"
|
||||||
#include "decl.h"
|
#include "decl.hpp"
|
||||||
#include "type.h"
|
#include "type.hpp"
|
||||||
|
|
||||||
Decl::~Decl(){
|
Decl::~Decl(){
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
#include "std.h"
|
#include "std.hpp"
|
||||||
#include "nodes.h"
|
#include "nodes.hpp"
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
// Sequence of declarations //
|
// Sequence of declarations //
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ struct DeclSeqNode : public Node{
|
|||||||
int size(){ return decls.size(); }
|
int size(){ return decls.size(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "exprnode.h"
|
#include "exprnode.hpp"
|
||||||
#include "stmtnode.h"
|
#include "stmtnode.hpp"
|
||||||
|
|
||||||
//'kind' shouldn't really be in Parser...
|
//'kind' shouldn't really be in Parser...
|
||||||
//should probably be LocalDeclNode,GlobalDeclNode,ParamDeclNode
|
//should probably be LocalDeclNode,GlobalDeclNode,ParamDeclNode
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
#include "std.h"
|
#include "std.hpp"
|
||||||
#include "environ.h"
|
#include "environ.hpp"
|
||||||
|
|
||||||
Environ::Environ( const string &f,Type *r,int l,Environ *gs )
|
Environ::Environ( const string &f,Type *r,int l,Environ *gs )
|
||||||
:funcLabel(f),returnType(r),level(l),globals(gs){
|
:funcLabel(f),returnType(r),level(l),globals(gs){
|
||||||
|
|||||||
@@ -8,9 +8,9 @@
|
|||||||
#ifndef ENVIRON_H
|
#ifndef ENVIRON_H
|
||||||
#define ENVIRON_H
|
#define ENVIRON_H
|
||||||
|
|
||||||
#include "type.h"
|
#include "type.hpp"
|
||||||
#include "decl.h"
|
#include "decl.hpp"
|
||||||
#include "label.h"
|
#include "label.hpp"
|
||||||
|
|
||||||
class Environ{
|
class Environ{
|
||||||
public:
|
public:
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
#include "std.h"
|
#include "std.hpp"
|
||||||
#include "nodes.h"
|
#include "nodes.hpp"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#ifndef EXPRNODE_H
|
#ifndef EXPRNODE_H
|
||||||
#define EXPRNODE_H
|
#define EXPRNODE_H
|
||||||
|
|
||||||
#include "node.h"
|
#include "node.hpp"
|
||||||
|
|
||||||
struct ConstNode; //is constant int,float or string
|
struct ConstNode; //is constant int,float or string
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ struct ExprSeqNode : public Node {
|
|||||||
void castTo(Type *t, Environ *e);
|
void castTo(Type *t, Environ *e);
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "varnode.h"
|
#include "varnode.hpp"
|
||||||
|
|
||||||
struct CastNode : public ExprNode {
|
struct CastNode : public ExprNode {
|
||||||
ExprNode *expr;
|
ExprNode *expr;
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
#include "std.h"
|
#include "std.hpp"
|
||||||
#include "nodes.h"
|
#include "nodes.hpp"
|
||||||
|
|
||||||
set<string> Node::usedfuncs;
|
set<string> Node::usedfuncs;
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
#ifndef NODE_H
|
#ifndef NODE_H
|
||||||
#define NODE_H
|
#define NODE_H
|
||||||
|
|
||||||
#include "ex.h"
|
#include "ex.hpp"
|
||||||
#include "toker.h"
|
#include "toker.hpp"
|
||||||
#include "environ.h"
|
#include "environ.hpp"
|
||||||
#include "codegen.h"
|
#include "codegen.hpp"
|
||||||
|
|
||||||
struct VarNode;
|
struct VarNode;
|
||||||
struct ConstNode;
|
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 <cstdlib>
|
||||||
#include "parser.h"
|
#include "parser.hpp"
|
||||||
|
|
||||||
#ifdef DEMO
|
#ifdef DEMO
|
||||||
static const int TEXTLIMIT=16384;
|
static const int TEXTLIMIT=16384;
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
#ifndef PARSER_H
|
#ifndef PARSER_H
|
||||||
#define PARSER_H
|
#define PARSER_H
|
||||||
|
|
||||||
#include "toker.h"
|
#include "toker.hpp"
|
||||||
#include "nodes.h"
|
#include "nodes.hpp"
|
||||||
|
|
||||||
class Parser{
|
class Parser{
|
||||||
public:
|
public:
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
#include "std.h"
|
#include "std.hpp"
|
||||||
#include "nodes.h"
|
#include "nodes.hpp"
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// The program! //
|
// The program! //
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
#ifndef PROGNODE_H
|
#ifndef PROGNODE_H
|
||||||
#define PROGNODE_H
|
#define PROGNODE_H
|
||||||
|
|
||||||
#include "node.h"
|
#include "node.hpp"
|
||||||
#include "codegen.h"
|
#include "codegen.hpp"
|
||||||
|
|
||||||
struct UserFunc{
|
struct UserFunc{
|
||||||
string ident,proc,lib;
|
string ident,proc,lib;
|
||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
|
|
||||||
#include "std.h"
|
#include "std.hpp"
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
#ifndef STD_COMPILER_H
|
#ifndef STD_COMPILER_H
|
||||||
#define STD_COMPILER_H
|
#define STD_COMPILER_H
|
||||||
|
|
||||||
#include "../config/config.h"
|
#include "config.hpp"
|
||||||
#include "../stdutil/stdutil.h"
|
#include "stdutil.hpp"
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <map>
|
#include <map>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
#include "std.h"
|
#include "std.hpp"
|
||||||
#include "nodes.h"
|
#include "nodes.hpp"
|
||||||
|
|
||||||
static string fileLabel;
|
static string fileLabel;
|
||||||
static map<string, string> fileMap;
|
static map<string, string> fileMap;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#ifndef STMTNODE_H
|
#ifndef STMTNODE_H
|
||||||
#define STMTNODE_H
|
#define STMTNODE_H
|
||||||
|
|
||||||
#include "node.h"
|
#include "node.hpp"
|
||||||
|
|
||||||
struct StmtNode : public Node{
|
struct StmtNode : public Node{
|
||||||
int pos; //offset in source stream
|
int pos; //offset in source stream
|
||||||
@@ -26,8 +26,8 @@ struct StmtSeqNode : public Node{
|
|||||||
static void reset( const string &file,const string &lab );
|
static void reset( const string &file,const string &lab );
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "exprnode.h"
|
#include "exprnode.hpp"
|
||||||
#include "declnode.h"
|
#include "declnode.hpp"
|
||||||
|
|
||||||
struct IncludeNode : public StmtNode{
|
struct IncludeNode : public StmtNode{
|
||||||
string file,label;
|
string file,label;
|
||||||
+3
-3
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
#include "std.h"
|
#include "std.hpp"
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include "toker.h"
|
#include "toker.hpp"
|
||||||
#include "ex.h"
|
#include "ex.hpp"
|
||||||
|
|
||||||
int Toker::chars_toked;
|
int Toker::chars_toked;
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
#include "std.h"
|
#include "std.hpp"
|
||||||
#include "type.h"
|
#include "type.hpp"
|
||||||
|
|
||||||
static struct v_type : public Type{
|
static struct v_type : public Type{
|
||||||
bool canCastTo( Type *t ){
|
bool canCastTo( Type *t ){
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#ifndef TYPE_H
|
#ifndef TYPE_H
|
||||||
#define TYPE_H
|
#define TYPE_H
|
||||||
|
|
||||||
#include "decl.h"
|
#include "decl.hpp"
|
||||||
|
|
||||||
struct FuncType;
|
struct FuncType;
|
||||||
struct ArrayType;
|
struct ArrayType;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
#include "std.h"
|
#include "std.hpp"
|
||||||
#include "nodes.h"
|
#include "nodes.hpp"
|
||||||
|
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
// Common get/set for variables //
|
// Common get/set for variables //
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#ifndef VARNODE_H
|
#ifndef VARNODE_H
|
||||||
#define VARNODE_H
|
#define VARNODE_H
|
||||||
|
|
||||||
#include "varnode.h"
|
#include "varnode.hpp"
|
||||||
|
|
||||||
struct VarNode : public Node{
|
struct VarNode : public Node{
|
||||||
Type *sem_type;
|
Type *sem_type;
|
||||||
@@ -17,7 +17,7 @@ struct VarNode : public Node{
|
|||||||
virtual TNode *translate( Codegen *g )=0;
|
virtual TNode *translate( Codegen *g )=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "decl.h"
|
#include "decl.hpp"
|
||||||
|
|
||||||
struct DeclVarNode : public VarNode{
|
struct DeclVarNode : public VarNode{
|
||||||
Decl *sem_decl;
|
Decl *sem_decl;
|
||||||
Reference in New Issue
Block a user