/* Generated by zi2c from compiler_source.zi. */ #ifndef ZIRAN_COMPILER_SOURCE_H #define ZIRAN_COMPILER_SOURCE_H #include #include "zir_string_types.h" #include "zir_slice.h" #ifdef __cplusplus extern "C" { #endif typedef int32_t SourceError; typedef int32_t StatementKind; typedef struct SourceRewrite SourceRewrite; typedef struct CommentScan CommentScan; typedef struct ControlBlock ControlBlock; typedef struct ProcedureHeader ProcedureHeader; typedef int32_t MustUseModifier; typedef int32_t InliningModifier; typedef int32_t TargetModifier; 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; }; 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 compiler_source_SourceIdentifier(uint8_t byte); int64_t compiler_source_FindUnquoted(String source, String needle, bool word); bool compiler_source_StartsWord(String source, String word); bool compiler_source_IdentifierText(String source, bool member_path); bool compiler_source_NonJaiControl(String source, String word); bool compiler_source_LooksLikeLabel(String source); StatementKind compiler_source_ClassifyStatement(String source); void compiler_source_NormalizeRecordSeparators(Slice body, bool split_commas); bool compiler_source_ContainsDirective(String source, String directive); SourceRewrite compiler_source_RewriteRawStrings(String source, Slice output, int64_t marker_limit); CommentScan compiler_source_StripComments(String source, Slice output, int32_t depth); int32_t compiler_source_NetBlockBraces(String source); int64_t compiler_source_StatementSeparator(String source); ControlBlock compiler_source_SplitControlBlock(String source); int64_t compiler_source_ClosingParenthesis(String source); ProcedureHeader compiler_source_ProcedureHeaderParts(String source); int64_t compiler_source_NormalizeTypeSpacing(String source, Slice output); int64_t compiler_source_CopyProcedureText(String source, Slice output, bool normalize_type); int64_t compiler_source_OpeningBraceOutsideLiterals(String source); bool compiler_source_BraceOutsideLiterals(String source); bool compiler_source_LooksLikeProcedureHeader(String source); ControlBlock compiler_source_SplitProcedureBody(String source); MustUseModifier compiler_source_ProcedureMustUse(String source, String result_type); InliningModifier compiler_source_ProcedureInlining(String source); TargetModifier compiler_source_ProcedureTarget(String source); /* Small procedures other modules inline; compiler_source.c defines them. */ #if !defined(__cplusplus) && !defined(ZIRAN_COMPILER_SOURCE_H_SOURCE) && !defined(ZIRAN_NO_HEADER_INLINE) #include #include "zir_string_types.h" static inline void compiler_source_NormalizeRecordSeparators_ziran_inline(Slice body, bool split_commas); #define compiler_source_NormalizeRecordSeparators(...) compiler_source_NormalizeRecordSeparators_ziran_inline(__VA_ARGS__) static inline bool compiler_source_BraceOutsideLiterals_ziran_inline(String source); #define compiler_source_BraceOutsideLiterals(...) compiler_source_BraceOutsideLiterals_ziran_inline(__VA_ARGS__) static inline void compiler_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)[SliceIndex(body, (int64_t)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)[SliceIndex(body, (int64_t)at)]); (*value_0) = 10; } at = (int64_t)((uint64_t)at + UINT64_C(1)); } } static inline bool compiler_source_BraceOutsideLiterals_ziran_inline(String source) { int64_t value_0 = compiler_source_OpeningBraceOutsideLiterals(source); return value_0 >= 0LL; } #endif #ifdef __cplusplus } #endif #endif /* ZIRAN_COMPILER_SOURCE_H */