aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
authorVexu <git@vexu.eu>2019-12-21 14:38:32 +0200
committerVexu <git@vexu.eu>2019-12-29 11:04:45 +0200
commitfceda07f94c9e4181f97ecacc1bdc1b9a0b7ab16 (patch)
tree44c4ff6b7f727e430cefaa4ee2af67953c2a332b /src/codegen.cpp
parentbda355d976c11a6bf1c820b6f1c2a477acd214fd (diff)
downloadzig-fceda07f94c9e4181f97ecacc1bdc1b9a0b7ab16.tar.gz
zig-fceda07f94c9e4181f97ecacc1bdc1b9a0b7ab16.zip
use self hosted translate-c for cimports
Diffstat (limited to 'src/codegen.cpp')
-rw-r--r--src/codegen.cpp24
1 files changed, 4 insertions, 20 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 1455b4b743..3a9cd381e2 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -15,7 +15,6 @@
#include "hash_map.hpp"
#include "ir.hpp"
#include "os.hpp"
-#include "translate_c.hpp"
#include "target.hpp"
#include "util.hpp"
#include "zig_llvm.h"
@@ -9090,7 +9089,7 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa
}
-void codegen_translate_c(CodeGen *g, Buf *full_path, FILE *out_file, bool use_userland_implementation) {
+void codegen_translate_c(CodeGen *g, Buf *full_path, FILE *out_file) {
Error err;
Buf *src_basename = buf_alloc();
Buf *src_dirname = buf_alloc();
@@ -9103,10 +9102,6 @@ void codegen_translate_c(CodeGen *g, Buf *full_path, FILE *out_file, bool use_us
init(g);
- TranslateMode trans_mode = buf_ends_with_str(full_path, ".h") ?
- TranslateModeImport : TranslateModeTranslate;
-
-
ZigList<const char *> clang_argv = {0};
add_cc_args(g, clang_argv, nullptr, true);
@@ -9126,15 +9121,9 @@ void codegen_translate_c(CodeGen *g, Buf *full_path, FILE *out_file, bool use_us
Stage2ErrorMsg *errors_ptr;
size_t errors_len;
Stage2Ast *ast;
- AstNode *root_node;
- if (use_userland_implementation) {
- err = stage2_translate_c(&ast, &errors_ptr, &errors_len,
- &clang_argv.at(0), &clang_argv.last(), resources_path);
- } else {
- err = parse_h_file(g, &root_node, &errors_ptr, &errors_len, &clang_argv.at(0), &clang_argv.last(),
- trans_mode, resources_path);
- }
+ err = stage2_translate_c(&ast, &errors_ptr, &errors_len,
+ &clang_argv.at(0), &clang_argv.last(), resources_path);
if (err == ErrorCCompileErrors && errors_len > 0) {
for (size_t i = 0; i < errors_len; i += 1) {
@@ -9158,12 +9147,7 @@ void codegen_translate_c(CodeGen *g, Buf *full_path, FILE *out_file, bool use_us
exit(1);
}
-
- if (use_userland_implementation) {
- stage2_render_ast(ast, out_file);
- } else {
- ast_render(out_file, root_node, 4);
- }
+ stage2_render_ast(ast, out_file);
}
static void update_test_functions_builtin_decl(CodeGen *g) {