Skip to content

Commit

Permalink
modify cpp save
Browse files Browse the repository at this point in the history
  • Loading branch information
limuy2022 committed Jan 21, 2024
1 parent 5c2f170 commit 3cdf95c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 63 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ file(GLOB_RECURSE CPP_SOURCES "src/*.cpp")

message(${CPP_SOURCES})

add_library(foo)
add_library(foo
src/compiler/compiler.cppm)

target_sources(foo
PUBLIC
Expand Down
2 changes: 0 additions & 2 deletions src/compiler/compile_env.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
module;
#include <limits>
#include <vector>
#include "parser.tab.hpp"
export module compile_env;
import compiler_def;
import TVMdef;
import Error;
import language;

export namespace trc::compiler {
// size_t最大值,代表不存在
Expand Down
43 changes: 0 additions & 43 deletions src/compiler/compiler.cpp

This file was deleted.

27 changes: 20 additions & 7 deletions src/compiler/compiler.hpp → src/compiler/compiler.cppm
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#pragma once

module;
#include <string>
export module compiler;
import Error;
import compiler_def;

namespace trc::TVM_space {
class TVM_static_data;
class TVM_static_data;
}

namespace trc::compiler {
class compiler_public_data;

class compiler_option;

class compiler {
public:
compiler();
Expand All @@ -36,3 +34,18 @@ class compiler {
};
}

namespace trc::compiler {
compiler::compiler() = default;

int compiler::parse(const compiler_option& option, const std::string& f, TVM_space::TVM_static_data* vm) {

}

int compiler::parse(const compiler_option& option, const std::string&filename, FILE* f, TVM_space::TVM_static_data* vm) {

}

FILE* compiler::open_file(const std::string& file) {

}
}
8 changes: 2 additions & 6 deletions src/compiler/compiler_def.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <unordered_map>
#include <vector>
#include <sstream>
#include "parser.tab.hpp"
export module compiler_def;
import TVM;
import Error;
Expand Down Expand Up @@ -81,15 +80,14 @@ public:
*/
class compiler_public_data {
public:
compiler_public_data(const compiler_option& option, TVM_space::TVM_static_data& vm, yy::location& location)
compiler_public_data(const compiler_option& option, TVM_space::TVM_static_data& vm)
: option(option)
, vm(vm)
, const_int(vm.const_i)
, const_float(vm.const_f)
, const_string(vm.const_s)
, const_long_int(vm.const_long)
, const_name(name_list)
, loc(location) {
, const_name(name_list) {
// 添加true,false,null常量
const_int.add(0);
const_int.add(1);
Expand All @@ -101,7 +99,6 @@ public:
std::vector<std::string> name_list;
constant_pool_controller<std::string> const_string, const_long_int,
const_name;
yy::location& loc;

/**
* @brief 报出错误
Expand All @@ -110,7 +107,6 @@ public:
void send_error(error::error_type errorn, const P&... argv) {
//todo:optimize it
std::stringstream ss;
ss << loc;
error::send_error_interal<true>(errorn, ss.str(), argv...);
}
};
Expand Down
7 changes: 3 additions & 4 deletions src/trc/Trc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ import help;
import run;
import style;
import tdb;
import tools.token;
import tshell;
import basic_def;
import data;
import color;
import help;
import Compiler;
import compiler;
import ctree_loader;
import filesys;
import code_loader;
Expand All @@ -51,8 +50,8 @@ struct {
const char* name;
argv_func_tools tool_func;
} cmd_tool[] = { { "tdb", tools::tools_out::tdb },
{ "help", tools::tools_out::help }, { "run", tools::tools_out::run },
{ "token", tools::tools_out::out_token }, { "dis", tools::tools_out::dis },
{ "help", tools::tools_out::help }, { "run", tools::tools_out::run }
, { "dis", tools::tools_out::dis },
{ "build", tools::tools_out::build },
{ "style", tools::tools_out::style } };

Expand Down

0 comments on commit 3cdf95c

Please sign in to comment.