diff options
Diffstat (limited to 'src/compile')
31 files changed, 66 insertions, 187 deletions
diff --git a/src/compile/assertions.c b/src/compile/assertions.c index 6034b828..ce9abcbc 100644 --- a/src/compile/assertions.c +++ b/src/compile/assertions.c @@ -8,11 +8,7 @@ #include "../stdlib/text.h" #include "../stdlib/util.h" #include "../typecheck.h" -#include "conditionals.h" -#include "declarations.h" -#include "promotions.h" -#include "statements.h" -#include "text.h" +#include "compilation.h" public Text_t compile_assertion(env_t *env, ast_t *ast) { diff --git a/src/compile/assignments.c b/src/compile/assignments.c index ba24ecf0..ab28b972 100644 --- a/src/compile/assignments.c +++ b/src/compile/assignments.c @@ -1,17 +1,12 @@ // This file defines how to compile assignments -#include "assignments.h" + #include "../ast.h" #include "../environment.h" #include "../stdlib/datatypes.h" #include "../stdlib/text.h" #include "../stdlib/util.h" #include "../typecheck.h" -#include "declarations.h" -#include "expressions.h" -#include "integers.h" -#include "pointers.h" -#include "promotions.h" -#include "types.h" +#include "compilation.h" public Text_t compile_update_assignment(env_t *env, ast_t *ast) { diff --git a/src/compile/binops.c b/src/compile/binops.c index 469ef60c..87fd2c7a 100644 --- a/src/compile/binops.c +++ b/src/compile/binops.c @@ -1,19 +1,13 @@ // This file defines how to compile binary operations #include "../ast.h" -#include "expressions.h" #include "../environment.h" #include "../stdlib/datatypes.h" #include "../stdlib/text.h" #include "../stdlib/util.h" #include "../typecheck.h" #include "../types.h" -#include "declarations.h" -#include "functions.h" -#include "optionals.h" -#include "promotions.h" -#include "statements.h" -#include "types.h" +#include "compilation.h" static PUREFUNC Text_t compile_unsigned_type(type_t *t) { if (t->tag != IntType) errx(1, "Not an int type, so unsigned doesn't make sense!"); diff --git a/src/compile/blocks.c b/src/compile/blocks.c index c533c801..1059fd34 100644 --- a/src/compile/blocks.c +++ b/src/compile/blocks.c @@ -1,14 +1,12 @@ // This file defines how to compile blocks -#include "blocks.h" #include "../ast.h" -#include "expressions.h" #include "../environment.h" #include "../stdlib/datatypes.h" #include "../stdlib/text.h" #include "../stdlib/util.h" #include "../typecheck.h" -#include "statements.h" +#include "compilation.h" public Text_t compile_block(env_t *env, ast_t *ast) { return Texts("{\n", compile_inline_block(env, ast), "}\n"); } diff --git a/src/compile/cli.c b/src/compile/cli.c index d9299bae..4a3be333 100644 --- a/src/compile/cli.c +++ b/src/compile/cli.c @@ -1,16 +1,12 @@ // This file defines how to compile CLI argument parsing -#include "expressions.h" #include "../environment.h" #include "../stdlib/datatypes.h" #include "../stdlib/text.h" #include "../stdlib/util.h" #include "../typecheck.h" #include "../types.h" -#include "declarations.h" -#include "optionals.h" -#include "text.h" -#include "types.h" +#include "compilation.h" static Text_t get_flag_options(type_t *t, const char *separator) { if (t->tag == BoolType) { diff --git a/src/compile/comparisons.c b/src/compile/comparisons.c index 851088d8..d73664de 100644 --- a/src/compile/comparisons.c +++ b/src/compile/comparisons.c @@ -5,8 +5,7 @@ #include "../environment.h" #include "../stdlib/text.h" #include "../typecheck.h" -#include "promotions.h" -#include "types.h" +#include "compilation.h" Text_t compile_comparison(env_t *env, ast_t *ast) { diff --git a/src/compile/compilation.h b/src/compile/compilation.h new file mode 100644 index 00000000..a167d324 --- /dev/null +++ b/src/compile/compilation.h @@ -0,0 +1,34 @@ +// Common header files for compilation +#pragma once + +#include "assertions.h" // IWYU pragma: export +#include "assignments.h" // IWYU pragma: export +#include "binops.h" // IWYU pragma: export +#include "blocks.h" // IWYU pragma: export +#include "cli.h" // IWYU pragma: export +#include "compilation.h" // IWYU pragma: export +#include "comparisons.h" // IWYU pragma: export +#include "conditionals.h" // IWYU pragma: export +#include "declarations.h" // IWYU pragma: export +#include "doctests.h" // IWYU pragma: export +#include "enums.h" // IWYU pragma: export +#include "expressions.h" // IWYU pragma: export +#include "fieldaccess.h" // IWYU pragma: export +#include "files.h" // IWYU pragma: export +#include "functions.h" // IWYU pragma: export +#include "headers.h" // IWYU pragma: export +#include "indexing.h" // IWYU pragma: export +#include "integers.h" // IWYU pragma: export +#include "lists.h" // IWYU pragma: export +#include "loops.h" // IWYU pragma: export +#include "optionals.h" // IWYU pragma: export +#include "pointers.h" // IWYU pragma: export +#include "promotions.h" // IWYU pragma: export +#include "reductions.h" // IWYU pragma: export +#include "sets.h" // IWYU pragma: export +#include "statements.h" // IWYU pragma: export +#include "structs.h" // IWYU pragma: export +#include "tables.h" // IWYU pragma: export +#include "text.h" // IWYU pragma: export +#include "types.h" // IWYU pragma: export +#include "whens.h" // IWYU pragma: export diff --git a/src/compile/conditionals.c b/src/compile/conditionals.c index 98919152..6071b6c4 100644 --- a/src/compile/conditionals.c +++ b/src/compile/conditionals.c @@ -7,9 +7,7 @@ #include "../stdlib/text.h" #include "../stdlib/util.h" #include "../typecheck.h" -#include "expressions.h" -#include "optionals.h" -#include "statements.h" +#include "compilation.h" public Text_t compile_condition(env_t *env, ast_t *ast) { diff --git a/src/compile/declarations.c b/src/compile/declarations.c index 8ea58ce2..e7d9ad2c 100644 --- a/src/compile/declarations.c +++ b/src/compile/declarations.c @@ -1,13 +1,11 @@ // This file defines how to compile variable declarations #include "../ast.h" -#include "expressions.h" #include "../environment.h" #include "../stdlib/datatypes.h" #include "../stdlib/text.h" #include "../stdlib/util.h" #include "../typecheck.h" -#include "promotions.h" -#include "types.h" +#include "compilation.h" public Text_t compile_declaration(type_t *t, Text_t name) { diff --git a/src/compile/doctests.c b/src/compile/doctests.c index 720385d3..872684ed 100644 --- a/src/compile/doctests.c +++ b/src/compile/doctests.c @@ -8,12 +8,7 @@ #include "../stdlib/text.h" #include "../stdlib/util.h" #include "../typecheck.h" -#include "assignments.h" -#include "declarations.h" -#include "expressions.h" -#include "promotions.h" -#include "statements.h" -#include "types.h" +#include "compilation.h" public Text_t compile_doctest(env_t *env, ast_t *ast) { diff --git a/src/compile/enums.c b/src/compile/enums.c index 85b29e4b..d9c29f26 100644 --- a/src/compile/enums.c +++ b/src/compile/enums.c @@ -1,16 +1,12 @@ // This file defines how to compile enums #include "../ast.h" -#include "expressions.h" #include "../environment.h" #include "../naming.h" #include "../stdlib/tables.h" #include "../stdlib/text.h" #include "../typecheck.h" -#include "declarations.h" -#include "pointers.h" -#include "structs.h" -#include "types.h" +#include "compilation.h" Text_t compile_enum_typeinfo(env_t *env, ast_t *ast) { DeclareMatch(def, ast, EnumDef); diff --git a/src/compile/expressions.c b/src/compile/expressions.c index ce22042f..4d41af61 100644 --- a/src/compile/expressions.c +++ b/src/compile/expressions.c @@ -7,28 +7,7 @@ #include "../stdlib/text.h" #include "../stdlib/util.h" #include "../typecheck.h" -#include "binops.h" -#include "blocks.h" -#include "comparisons.h" -#include "conditionals.h" -#include "declarations.h" -#include "enums.h" -#include "fieldaccess.h" -#include "functions.h" -#include "indexing.h" -#include "integers.h" -#include "lists.h" -#include "optionals.h" -#include "pointers.h" -#include "promotions.h" -#include "reductions.h" -#include "sets.h" -#include "statements.h" -#include "structs.h" -#include "tables.h" -#include "text.h" -#include "types.h" -#include "whens.h" +#include "compilation.h" public Text_t compile_maybe_incref(env_t *env, ast_t *ast, type_t *t) { diff --git a/src/compile/fieldaccess.c b/src/compile/fieldaccess.c index 93b31665..f1780fc9 100644 --- a/src/compile/fieldaccess.c +++ b/src/compile/fieldaccess.c @@ -1,4 +1,5 @@ // This file defines how to compile field accessing like `foo.x` + #include "../ast.h" #include "../config.h" #include "../environment.h" @@ -6,11 +7,7 @@ #include "../stdlib/text.h" #include "../stdlib/util.h" #include "../typecheck.h" -#include "declarations.h" -#include "enums.h" -#include "expressions.h" -#include "pointers.h" -#include "structs.h" +#include "compilation.h" Text_t compile_field_access(env_t *env, ast_t *ast) { DeclareMatch(f, ast, FieldAccess); diff --git a/src/compile/files.c b/src/compile/files.c index 2cce010f..2b0ac4bf 100644 --- a/src/compile/files.c +++ b/src/compile/files.c @@ -1,6 +1,5 @@ // This file defines how to compile files -#include "files.h" #include "../ast.h" #include "../config.h" #include "../environment.h" @@ -11,12 +10,7 @@ #include "../stdlib/text.h" #include "../typecheck.h" #include "../types.h" -#include "declarations.h" -#include "enums.h" -#include "functions.h" -#include "statements.h" -#include "structs.h" -#include "text.h" +#include "compilation.h" static void initialize_vars_and_statics(env_t *env, ast_t *ast) { if (!ast) return; diff --git a/src/compile/functions.c b/src/compile/functions.c index 6fc626cf..665c7379 100644 --- a/src/compile/functions.c +++ b/src/compile/functions.c @@ -1,8 +1,6 @@ // This file defines how to compile functions -#include "functions.h" #include "../ast.h" -#include "expressions.h" #include "../environment.h" #include "../naming.h" #include "../stdlib/datatypes.h" @@ -13,17 +11,7 @@ #include "../stdlib/util.h" #include "../typecheck.h" #include "../types.h" -#include "blocks.h" -#include "declarations.h" -#include "integers.h" -#include "lists.h" -#include "promotions.h" -#include "sets.h" -#include "statements.h" -#include "structs.h" -#include "tables.h" -#include "text.h" -#include "types.h" +#include "compilation.h" public Text_t compile_function_declaration(env_t *env, ast_t *ast) { diff --git a/src/compile/headers.c b/src/compile/headers.c index 44859104..8c0863ee 100644 --- a/src/compile/headers.c +++ b/src/compile/headers.c @@ -12,14 +12,7 @@ #include "../stdlib/text.h" #include "../typecheck.h" #include "../types.h" -#include "declarations.h" -#include "enums.h" -#include "functions.h" -#include "headers.h" -#include "statements.h" -#include "structs.h" -#include "text.h" -#include "types.h" +#include "compilation.h" public Text_t compile_statement_namespace_header(env_t *env, Path_t header_path, ast_t *ast) { diff --git a/src/compile/indexing.c b/src/compile/indexing.c index 7245e9cf..e99feeb2 100644 --- a/src/compile/indexing.c +++ b/src/compile/indexing.c @@ -6,12 +6,7 @@ #include "../stdlib/text.h" #include "../stdlib/util.h" #include "../typecheck.h" -#include "expressions.h" -#include "integers.h" -#include "optionals.h" -#include "pointers.h" -#include "promotions.h" -#include "types.h" +#include "compilation.h" public Text_t compile_indexing(env_t *env, ast_t *ast) { diff --git a/src/compile/integers.c b/src/compile/integers.c index 10955fe1..9ebb8818 100644 --- a/src/compile/integers.c +++ b/src/compile/integers.c @@ -3,7 +3,6 @@ #include <gmp.h> #include "../ast.h" -#include "expressions.h" #include "../environment.h" #include "../stdlib/datatypes.h" #include "../stdlib/integers.h" @@ -11,7 +10,7 @@ #include "../stdlib/util.h" #include "../typecheck.h" #include "../types.h" -#include "promotions.h" +#include "compilation.h" public Text_t compile_int_to_type(env_t *env, ast_t *ast, type_t *target) { diff --git a/src/compile/lists.c b/src/compile/lists.c index a44d9098..5df39863 100644 --- a/src/compile/lists.c +++ b/src/compile/lists.c @@ -6,18 +6,12 @@ #include <uninorm.h> #include "../ast.h" -#include "expressions.h" #include "../config.h" #include "../environment.h" #include "../stdlib/text.h" #include "../stdlib/util.h" #include "../typecheck.h" -#include "functions.h" -#include "optionals.h" -#include "pointers.h" -#include "promotions.h" -#include "statements.h" -#include "types.h" +#include "compilation.h" static ast_t *add_to_list_comprehension(ast_t *item, ast_t *subject) { return WrapAST(item, MethodCall, .name = "insert", .self = subject, .args = new (arg_ast_t, .value = item)); diff --git a/src/compile/loops.c b/src/compile/loops.c index 6adb6700..c742589a 100644 --- a/src/compile/loops.c +++ b/src/compile/loops.c @@ -10,15 +10,7 @@ #include "../stdlib/text.h" #include "../stdlib/util.h" #include "../typecheck.h" -#include "blocks.h" -#include "declarations.h" -#include "expressions.h" -#include "functions.h" -#include "optionals.h" -#include "pointers.h" -#include "promotions.h" -#include "statements.h" -#include "types.h" +#include "compilation.h" public Text_t compile_for_loop(env_t *env, ast_t *ast) { diff --git a/src/compile/optionals.c b/src/compile/optionals.c index 0c844c75..1cd86c29 100644 --- a/src/compile/optionals.c +++ b/src/compile/optionals.c @@ -1,6 +1,5 @@ // This file defines how to compile optionals and null -#include "expressions.h" #include "../environment.h" #include "../naming.h" #include "../stdlib/datatypes.h" @@ -8,9 +7,7 @@ #include "../stdlib/util.h" #include "../typecheck.h" #include "../types.h" -#include "declarations.h" -#include "text.h" -#include "types.h" +#include "compilation.h" Text_t optional_into_nonnone(type_t *t, Text_t value) { if (t->tag == OptionalType) t = Match(t, OptionalType)->type; diff --git a/src/compile/pointers.c b/src/compile/pointers.c index 54e24f63..644b3bc7 100644 --- a/src/compile/pointers.c +++ b/src/compile/pointers.c @@ -6,13 +6,11 @@ #include <uninorm.h> #include "../ast.h" -#include "expressions.h" #include "../config.h" #include "../environment.h" #include "../stdlib/text.h" #include "../typecheck.h" -#include "assignments.h" -#include "promotions.h" +#include "compilation.h" public Text_t compile_to_pointer_depth(env_t *env, ast_t *ast, int64_t target_depth, bool needs_incref) { diff --git a/src/compile/promotions.c b/src/compile/promotions.c index eff946b9..fcedce3f 100644 --- a/src/compile/promotions.c +++ b/src/compile/promotions.c @@ -1,22 +1,12 @@ // This file defines how to do type promotions during compilation -#include "promotions.h" #include "../ast.h" -#include "expressions.h" #include "../environment.h" #include "../stdlib/datatypes.h" #include "../stdlib/text.h" #include "../typecheck.h" #include "../types.h" -#include "declarations.h" -#include "functions.h" -#include "integers.h" -#include "lists.h" -#include "optionals.h" -#include "pointers.h" -#include "sets.h" -#include "tables.h" -#include "types.h" +#include "compilation.h" static Text_t quoted_str(const char *str) { return Text$quoted(Text$from_str(str), false, Text("\"")); } diff --git a/src/compile/reductions.c b/src/compile/reductions.c index 2d7492af..e0477a9c 100644 --- a/src/compile/reductions.c +++ b/src/compile/reductions.c @@ -6,10 +6,7 @@ #include "../stdlib/text.h" #include "../stdlib/util.h" #include "../typecheck.h" -#include "declarations.h" -#include "expressions.h" -#include "optionals.h" -#include "statements.h" +#include "compilation.h" public Text_t compile_reduction(env_t *env, ast_t *ast) { diff --git a/src/compile/sets.c b/src/compile/sets.c index f9ffa0ae..d33677cc 100644 --- a/src/compile/sets.c +++ b/src/compile/sets.c @@ -1,17 +1,12 @@ // This file defines how to compile sets #include "../ast.h" -#include "expressions.h" #include "../environment.h" #include "../stdlib/datatypes.h" #include "../stdlib/text.h" #include "../typecheck.h" #include "../types.h" -#include "functions.h" -#include "pointers.h" -#include "promotions.h" -#include "statements.h" -#include "types.h" +#include "compilation.h" static ast_t *add_to_set_comprehension(ast_t *item, ast_t *subject) { return WrapAST(item, MethodCall, .name = "add", .self = subject, .args = new (arg_ast_t, .value = item)); diff --git a/src/compile/statements.c b/src/compile/statements.c index bccec75d..7c58559d 100644 --- a/src/compile/statements.c +++ b/src/compile/statements.c @@ -14,18 +14,7 @@ #include "../stdlib/text.h" #include "../stdlib/util.h" #include "../typecheck.h" -#include "assertions.h" -#include "assignments.h" -#include "blocks.h" -#include "conditionals.h" -#include "declarations.h" -#include "doctests.h" -#include "expressions.h" -#include "functions.h" -#include "loops.h" -#include "promotions.h" -#include "statements.h" -#include "whens.h" +#include "compilation.h" typedef ast_t *(*comprehension_body_t)(ast_t *, ast_t *); diff --git a/src/compile/structs.c b/src/compile/structs.c index 20f40c4d..526c11c7 100644 --- a/src/compile/structs.c +++ b/src/compile/structs.c @@ -3,16 +3,12 @@ #include <gc.h> #include "../ast.h" -#include "expressions.h" #include "../environment.h" #include "../naming.h" #include "../stdlib/tables.h" #include "../stdlib/text.h" #include "../typecheck.h" -#include "declarations.h" -#include "functions.h" -#include "pointers.h" -#include "types.h" +#include "compilation.h" public Text_t compile_struct_typeinfo(env_t *env, type_t *t, const char *name, arg_ast_t *fields, bool is_secret, diff --git a/src/compile/tables.c b/src/compile/tables.c index e9067c0f..b955178e 100644 --- a/src/compile/tables.c +++ b/src/compile/tables.c @@ -1,18 +1,12 @@ // This file defines how to compile tables #include "../ast.h" -#include "expressions.h" #include "../environment.h" #include "../stdlib/datatypes.h" #include "../stdlib/text.h" #include "../typecheck.h" #include "../types.h" -#include "functions.h" -#include "optionals.h" -#include "pointers.h" -#include "promotions.h" -#include "statements.h" -#include "types.h" +#include "compilation.h" static ast_t *add_to_table_comprehension(ast_t *entry, ast_t *subject) { DeclareMatch(e, entry, TableEntry); diff --git a/src/compile/text.c b/src/compile/text.c index c08ef31e..f8576f63 100644 --- a/src/compile/text.c +++ b/src/compile/text.c @@ -2,7 +2,6 @@ #include <ctype.h> #include "../ast.h" -#include "expressions.h" #include "../environment.h" #include "../naming.h" #include "../stdlib/datatypes.h" @@ -10,8 +9,7 @@ #include "../stdlib/text.h" #include "../typecheck.h" #include "../types.h" -#include "functions.h" -#include "types.h" +#include "compilation.h" public Text_t expr_as_text(Text_t expr, type_t *t, Text_t color) { diff --git a/src/compile/types.c b/src/compile/types.c index 607daad2..ce339645 100644 --- a/src/compile/types.c +++ b/src/compile/types.c @@ -6,7 +6,7 @@ #include "../stdlib/datatypes.h" #include "../stdlib/text.h" #include "../stdlib/util.h" -#include "text.h" +#include "compilation.h" public Text_t compile_type(type_t *t) { diff --git a/src/compile/whens.c b/src/compile/whens.c index 6af2ecf1..d9bef9e1 100644 --- a/src/compile/whens.c +++ b/src/compile/whens.c @@ -1,6 +1,5 @@ // This file defines how to compile 'when' statements/expressions -#include "whens.h" #include "../ast.h" #include "../config.h" #include "../environment.h" @@ -9,11 +8,7 @@ #include "../stdlib/text.h" #include "../stdlib/util.h" #include "../typecheck.h" -#include "blocks.h" -#include "declarations.h" -#include "expressions.h" -#include "statements.h" -#include "types.h" +#include "compilation.h" public Text_t compile_when_statement(env_t *env, ast_t *ast) { |
