Files
waozi 8968733ec3
Build check / check (push) Canceled after 0s
Publish website / build (push) Failing after 20m25s
Publish website / deploy (push) Skipped
Organize compiler sources by phase, language and CPU target
Move 222 compiler modules under cmd/compiler and remove the repeated
compiler_ filename prefix. Update file imports, native symbol bindings,
build rules, bootstrap metadata and seeds, retained fixtures and docs.

Document the existing shared lowering pipeline and measured source-size
baseline, with feature-preserving sharing priorities and separate speed
acceptance criteria. No performance improvement is claimed for the move.

Local tests: all 272 retained make check cases (0 reused); bootstrap update
and independent make check-bootstrap reproduce all 95 roots at stage 2.
2026-12-04 10:17:23 -03:00

226 lines
6.8 KiB
C

/* Generated by zi2c from source.zi. */
#ifndef ZIRAN_SOURCE_H
#define ZIRAN_SOURCE_H
#include <stdbool.h>
#include "zir_string_types.h"
#include "zir_slice.h"
#ifndef ZIRAN_TYPE_FORWARD_SourceError
#define ZIRAN_TYPE_FORWARD_SourceError
typedef int32_t SourceError;
#endif
#ifndef ZIRAN_TYPE_FORWARD_StatementKind
#define ZIRAN_TYPE_FORWARD_StatementKind
typedef int32_t StatementKind;
#endif
#ifndef ZIRAN_TYPE_FORWARD_SourceRewrite
#define ZIRAN_TYPE_FORWARD_SourceRewrite
typedef struct SourceRewrite SourceRewrite;
#endif
#ifndef ZIRAN_TYPE_FORWARD_CommentScan
#define ZIRAN_TYPE_FORWARD_CommentScan
typedef struct CommentScan CommentScan;
#endif
#ifndef ZIRAN_TYPE_FORWARD_ControlBlock
#define ZIRAN_TYPE_FORWARD_ControlBlock
typedef struct ControlBlock ControlBlock;
#endif
#ifndef ZIRAN_TYPE_FORWARD_ProcedureHeader
#define ZIRAN_TYPE_FORWARD_ProcedureHeader
typedef struct ProcedureHeader ProcedureHeader;
#endif
#ifndef ZIRAN_TYPE_FORWARD_ProcedureLiteral
#define ZIRAN_TYPE_FORWARD_ProcedureLiteral
typedef struct ProcedureLiteral ProcedureLiteral;
#endif
#ifndef ZIRAN_TYPE_FORWARD_BraceClose
#define ZIRAN_TYPE_FORWARD_BraceClose
typedef struct BraceClose BraceClose;
#endif
#ifndef ZIRAN_TYPE_FORWARD_MustUseModifier
#define ZIRAN_TYPE_FORWARD_MustUseModifier
typedef int32_t MustUseModifier;
#endif
#ifndef ZIRAN_TYPE_FORWARD_InliningModifier
#define ZIRAN_TYPE_FORWARD_InliningModifier
typedef int32_t InliningModifier;
#endif
#ifndef ZIRAN_TYPE_FORWARD_TargetModifier
#define ZIRAN_TYPE_FORWARD_TargetModifier
typedef int32_t TargetModifier;
#endif
#ifdef __cplusplus
extern "C" {
#endif
enum {
SourceError_None = 0,
SourceError_Delimiter = 1,
SourceError_DelimiterLine = 2,
SourceError_Unterminated = 3,
};
enum {
StatementKind_Unknown = 0,
StatementKind_BlockOpen = 1,
StatementKind_BlockClose = 2,
StatementKind_Declaration = 3,
StatementKind_Assignment = 4,
StatementKind_Expression = 5,
StatementKind_If = 6,
StatementKind_While = 7,
StatementKind_For = 8,
StatementKind_Case = 9,
StatementKind_Return = 10,
StatementKind_Break = 11,
StatementKind_Continue = 12,
StatementKind_Defer = 13,
StatementKind_Unused = 14,
StatementKind_Unreachable = 15,
StatementKind_IfCase = 16,
};
struct SourceRewrite {
SourceError error;
int64_t count;
int32_t line;
int32_t column;
int64_t marker_begin;
int64_t marker_end;
};
struct CommentScan {
int64_t count;
int32_t depth;
};
struct ControlBlock {
bool valid;
int64_t head_end;
int64_t body_begin;
int64_t body_end;
int64_t tail_begin;
bool open;
};
struct ProcedureHeader {
String name;
String parameters;
String result;
};
struct ProcedureLiteral {
int64_t begin;
int64_t open;
int64_t close;
int32_t depth;
};
struct BraceClose {
int64_t close;
int32_t depth;
};
enum {
MustUseModifier_None = 0,
MustUseModifier_Required = 1,
MustUseModifier_Arguments = 2,
MustUseModifier_Duplicate = 3,
MustUseModifier_NoResult = 4,
};
enum {
InliningModifier_None = 0,
InliningModifier_Inline = 1,
InliningModifier_Cold = 2,
InliningModifier_Arguments = 3,
InliningModifier_Duplicate = 4,
InliningModifier_Both = 5,
};
enum {
TargetModifier_None = 0,
TargetModifier_Target = 1,
TargetModifier_Arguments = 2,
TargetModifier_Duplicate = 3,
};
bool source_SourceIdentifier(uint8_t byte);
int64_t source_FindUnquoted(String source, String needle, bool word);
bool source_StartsWord(String source, String word);
bool source_IdentifierText(String source, bool member_path);
bool source_NonJaiControl(String source, String word);
bool source_LooksLikeLabel(String source);
StatementKind source_ClassifyStatement(String source);
void source_NormalizeRecordSeparators(Slice body, bool split_commas);
bool source_ContainsDirective(String source, String directive);
SourceRewrite source_RewriteRawStrings(String source, Slice output, int64_t marker_limit);
CommentScan source_StripComments(String source, Slice output, int32_t depth);
int32_t source_NetBlockBraces(String source);
int64_t source_StatementSeparator(String source);
ControlBlock source_SplitControlBlock(String source);
int64_t source_ClosingParenthesis(String source);
BraceClose source_CloseBraces(String source, int32_t depth);
ProcedureLiteral source_FindProcedureLiteral(String source);
ProcedureHeader source_ProcedureHeaderParts(String source);
int64_t source_NormalizeTypeSpacing(String source, Slice output);
int64_t source_CopyProcedureText(String source, Slice output, bool normalize_type);
int64_t source_OpeningBraceOutsideLiterals(String source);
bool source_BraceOutsideLiterals(String source);
bool source_LooksLikeProcedureHeader(String source);
ControlBlock source_SplitProcedureBody(String source);
MustUseModifier source_ProcedureMustUse(String source, String result_type);
InliningModifier source_ProcedureInlining(String source);
TargetModifier source_ProcedureTarget(String source);
/* Small procedures other modules inline; source.c defines them. */
#if !defined(__cplusplus) && !defined(ZIRAN_SOURCE_H_SOURCE) && !defined(ZIRAN_NO_HEADER_INLINE)
#include <stdbool.h>
#include "zir_string_types.h"
static inline void source_NormalizeRecordSeparators_ziran_inline(Slice body, bool split_commas);
#define source_NormalizeRecordSeparators(...) source_NormalizeRecordSeparators_ziran_inline(__VA_ARGS__)
static inline bool source_BraceOutsideLiterals_ziran_inline(String source);
#define source_BraceOutsideLiterals(...) source_BraceOutsideLiterals_ziran_inline(__VA_ARGS__)
static inline void
source_NormalizeRecordSeparators_ziran_inline(Slice body, bool split_commas)
{
int64_t at = 0LL;
bool quoted = false;
int32_t nesting = 0;
while (at < (int64_t)(body).length) {
uint8_t byte = ((uint8_t *)(body).data)[at];
if (quoted) {
if (byte == 92 && (int64_t)((uint64_t)at + UINT64_C(1)) < (int64_t)(body).length) {
at = (int64_t)((uint64_t)at + UINT64_C(1));
} else if (byte == 34) {
quoted = false;
}
} else if (byte == 34) {
quoted = true;
} else if (byte == 91 || byte == 40) {
nesting = (int32_t)((uint32_t)nesting + 1u);
} else if (byte == 93 || byte == 41) {
nesting = (int32_t)((uint32_t)nesting - 1u);
} else if (nesting == 0 && (byte == 59 || (split_commas && byte == 44))) {
uint8_t* value_0 = &(((uint8_t *)(body).data)[at]);
(*value_0) = 10;
}
at = (int64_t)((uint64_t)at + UINT64_C(1));
}
}
static inline bool
source_BraceOutsideLiterals_ziran_inline(String source)
{
int64_t value_0 = source_OpeningBraceOutsideLiterals(source);
return value_0 >= 0LL;
}
#endif
#ifdef __cplusplus
}
#endif
#endif /* ZIRAN_SOURCE_H */