Compiling euler code with only link errors

This commit is contained in:
Krzosa Karol
2022-06-12 00:22:07 +02:00
parent 83130b130b
commit 4d6a8efd06
2 changed files with 8 additions and 5 deletions

View File

@@ -273,7 +273,7 @@ gen_ast(Ast *ast){
CASE(VAR, Decl){ CASE(VAR, Decl){
gen_var(node->name, node->type, node->expr, is_inside_struct ? DONT_EMIT_VALUE : ALWAYS_EMIT_VALUE); gen_var(node->name, node->type, node->expr, is_inside_struct ? DONT_EMIT_VALUE : ALWAYS_EMIT_VALUE);
gen(";"); if(!is_flag_set(ast->flags, AST_EXPR)) gen(";");
BREAK(); BREAK();
} }
@@ -477,7 +477,7 @@ compile_files(Array<String> filename){
resolve_package(it); resolve_package(it);
} }
#if 0 #if 1
gen(R"==( gen(R"==(
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>

View File

@@ -181,7 +181,7 @@ int main(int argument_count, char **arguments){
test_intern_table(); test_intern_table();
#if 0 #if 1
emit_line_directives = true; emit_line_directives = true;
if(argument_count > 1){ if(argument_count > 1){
Scratch scratch; Scratch scratch;
@@ -190,7 +190,9 @@ int main(int argument_count, char **arguments){
String compiler_call = string_fmt(scratch, "clang.exe %s.c -g -o %s.exe", arguments[1], arguments[1]); String compiler_call = string_fmt(scratch, "clang.exe %s.c -g -o %s.exe", arguments[1], arguments[1]);
String run_program = string_fmt(scratch, "%s.exe", arguments[1]); String run_program = string_fmt(scratch, "%s.exe", arguments[1]);
String result = compile_file(name); Array<String> files = {scratch};
files.add(name);
String result = compile_files(files);
FILE *f = fopen((const char *)c_filename.str, "w"); FILE *f = fopen((const char *)c_filename.str, "w");
assert(f); assert(f);
fprintf(f, "%.*s", (int)result.len, result.str); fprintf(f, "%.*s", (int)result.len, result.str);
@@ -201,7 +203,7 @@ int main(int argument_count, char **arguments){
system((const char *)run_program.str); system((const char *)run_program.str);
} }
#endif #else
Scratch scratch; Scratch scratch;
Array<String> files = {scratch}; Array<String> files = {scratch};
// files.add("lambdas.kl"_s); // files.add("lambdas.kl"_s);
@@ -213,5 +215,6 @@ int main(int argument_count, char **arguments){
// files.add("euler.kl"_s); // files.add("euler.kl"_s);
String result = compile_files(files); String result = compile_files(files);
printf("%s", result.str); printf("%s", result.str);
#endif
__debugbreak(); __debugbreak();
} }