/* * Declarations for `out*.c`. * * Copyright © 2020-2025 Samuel Lidén Borell * * SPDX-License-Identifier: EUPL-1.2+ */ #ifndef SLUL_OUT_H #define SLUL_OUT_H #include "compiler.h" /* Defined in outcommon.c */ extern const char *outfile_path; extern FILE *outfile; extern int indentlevel; /* Foundational functions for outputting code. Defined in outcommon.c */ NORETURN void io_error(void); NORETURN void ast_error(const char *msg); void outc(char c); void indent(void); void outf(const char *fmt, ...); void beginf(const char *fmt, ...); void endf(const char *fmt, ...); void indentf(const char *fmt, ...); /* Basic ident/type referencing. Defined in out.c */ void emit_ident(struct Ident *ident); void emit_typeref_prefix(struct TypeRef *tr); void emit_typeref_suffix(struct TypeRef *tr); void emit_type(struct Type *type); /* Declarations. Defined in outdecl.c */ void predeclare_type(struct Type *type); void define_type(struct Type *type); void predeclare_funcs(struct Func *funcs_list); void define_funcs(struct Func *funcs_list); /** ID of statement being outputted in current function */ extern int stmt_id; /** Emits statements inside a statement block (e.g. a function body). Does not emit the surrounding `{` and `}`. */ void emit_statements_inside(struct Stmt *stmt); /** Emits all string constants */ void emit_string_constants(void); /** Emits an expression. The final result may optionally be stored in the variable given by concatenating target_ident and target_num. */ void emit_expr(const struct TypeRef *typeref, const char *target_ident, int target_num, struct Expr *expr); #endif