470 lines
15 KiB
C
470 lines
15 KiB
C
/* Generated by zi2c from declaration.zi. */
|
|
#ifndef ZIRAN_DECLARATION_H
|
|
#define ZIRAN_DECLARATION_H
|
|
|
|
#include <stdbool.h>
|
|
#include "zir_string.h"
|
|
#include "zir_slice.h"
|
|
#ifndef ZIRAN_TYPE_FORWARD_DeclarationError
|
|
#define ZIRAN_TYPE_FORWARD_DeclarationError
|
|
typedef int32_t DeclarationError;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_GoMethodDeclaration
|
|
#define ZIRAN_TYPE_FORWARD_GoMethodDeclaration
|
|
typedef struct GoMethodDeclaration GoMethodDeclaration;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_ExportDirective
|
|
#define ZIRAN_TYPE_FORWARD_ExportDirective
|
|
typedef struct ExportDirective ExportDirective;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_ParameterRewrite
|
|
#define ZIRAN_TYPE_FORWARD_ParameterRewrite
|
|
typedef struct ParameterRewrite ParameterRewrite;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_ImportMode
|
|
#define ZIRAN_TYPE_FORWARD_ImportMode
|
|
typedef int32_t ImportMode;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_ModuleImport
|
|
#define ZIRAN_TYPE_FORWARD_ModuleImport
|
|
typedef struct ModuleImport ModuleImport;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_ParameterEntry
|
|
#define ZIRAN_TYPE_FORWARD_ParameterEntry
|
|
typedef struct ParameterEntry ParameterEntry;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_ModuleParameterDirective
|
|
#define ZIRAN_TYPE_FORWARD_ModuleParameterDirective
|
|
typedef struct ModuleParameterDirective ModuleParameterDirective;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_InsertDirective
|
|
#define ZIRAN_TYPE_FORWARD_InsertDirective
|
|
typedef struct InsertDirective InsertDirective;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_LibraryDeclaration
|
|
#define ZIRAN_TYPE_FORWARD_LibraryDeclaration
|
|
typedef struct LibraryDeclaration LibraryDeclaration;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_MethodSymbol
|
|
#define ZIRAN_TYPE_FORWARD_MethodSymbol
|
|
typedef struct MethodSymbol MethodSymbol;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_UsingFilter
|
|
#define ZIRAN_TYPE_FORWARD_UsingFilter
|
|
typedef struct UsingFilter UsingFilter;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_ForeignDeclaration
|
|
#define ZIRAN_TYPE_FORWARD_ForeignDeclaration
|
|
typedef struct ForeignDeclaration ForeignDeclaration;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_ForeignTarget
|
|
#define ZIRAN_TYPE_FORWARD_ForeignTarget
|
|
typedef struct ForeignTarget ForeignTarget;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_ResultDeclaration
|
|
#define ZIRAN_TYPE_FORWARD_ResultDeclaration
|
|
typedef struct ResultDeclaration ResultDeclaration;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_ResultReturn
|
|
#define ZIRAN_TYPE_FORWARD_ResultReturn
|
|
typedef struct ResultReturn ResultReturn;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_ResultBinding
|
|
#define ZIRAN_TYPE_FORWARD_ResultBinding
|
|
typedef struct ResultBinding ResultBinding;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_SymmetricRewrite
|
|
#define ZIRAN_TYPE_FORWARD_SymmetricRewrite
|
|
typedef struct SymmetricRewrite SymmetricRewrite;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_TextRewrite
|
|
#define ZIRAN_TYPE_FORWARD_TextRewrite
|
|
typedef struct TextRewrite TextRewrite;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_NameReplacement
|
|
#define ZIRAN_TYPE_FORWARD_NameReplacement
|
|
typedef struct NameReplacement NameReplacement;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_PrintRewrite
|
|
#define ZIRAN_TYPE_FORWARD_PrintRewrite
|
|
typedef struct PrintRewrite PrintRewrite;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_StatementOutput
|
|
#define ZIRAN_TYPE_FORWARD_StatementOutput
|
|
typedef struct StatementOutput StatementOutput;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_BuilderPrintPiece
|
|
#define ZIRAN_TYPE_FORWARD_BuilderPrintPiece
|
|
typedef struct BuilderPrintPiece BuilderPrintPiece;
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_BuilderPrintScan
|
|
#define ZIRAN_TYPE_FORWARD_BuilderPrintScan
|
|
typedef struct BuilderPrintScan BuilderPrintScan;
|
|
#endif
|
|
#ifdef ZIRAN_DECLARATION_H_PRIVATE
|
|
#ifndef ZIRAN_TYPE_FORWARD_QuotedText
|
|
#define ZIRAN_TYPE_FORWARD_QuotedText
|
|
typedef struct QuotedText QuotedText;
|
|
#endif
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_ForeignData
|
|
#define ZIRAN_TYPE_FORWARD_ForeignData
|
|
typedef struct ForeignData ForeignData;
|
|
#endif
|
|
#ifdef ZIRAN_DECLARATION_H_PRIVATE
|
|
#ifndef ZIRAN_TYPE_FORWARD_CText
|
|
#define ZIRAN_TYPE_FORWARD_CText
|
|
typedef struct CText CText;
|
|
#endif
|
|
#endif
|
|
#include "source_text.h"
|
|
#include "source.h"
|
|
#include "scan.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
enum {
|
|
DeclarationError_None = 0,
|
|
DeclarationError_ExportQuote = 1,
|
|
DeclarationError_ExportName = 2,
|
|
DeclarationError_Parameters = 3,
|
|
DeclarationError_DefaultValue = 4,
|
|
DeclarationError_UsingModifier = 5,
|
|
DeclarationError_UsingType = 6,
|
|
DeclarationError_UsingName = 7,
|
|
DeclarationError_ImportQuote = 8,
|
|
DeclarationError_ImportCharacter = 9,
|
|
DeclarationError_ImportMode = 10,
|
|
DeclarationError_ImportDirSyntax = 11,
|
|
DeclarationError_ImportDirPath = 12,
|
|
DeclarationError_ImportDirName = 13,
|
|
DeclarationError_ImportFileSyntax = 14,
|
|
DeclarationError_ImportFilePath = 15,
|
|
DeclarationError_ImportFileName = 16,
|
|
DeclarationError_ImportAlias = 17,
|
|
DeclarationError_ImportAliasLimit = 18,
|
|
DeclarationError_ImportTarget = 19,
|
|
DeclarationError_ImportPackage = 20,
|
|
DeclarationError_ImportUsing = 21,
|
|
DeclarationError_LibraryQuote = 22,
|
|
DeclarationError_LibraryEnd = 23,
|
|
DeclarationError_LibraryCharacter = 24,
|
|
DeclarationError_UsingKind = 25,
|
|
DeclarationError_UsingList = 26,
|
|
DeclarationError_UsingEntry = 27,
|
|
DeclarationError_UsingMap = 28,
|
|
DeclarationError_ForeignResults = 29,
|
|
DeclarationError_ForeignField = 30,
|
|
DeclarationError_ForeignDefer = 31,
|
|
DeclarationError_ForeignVariadic = 32,
|
|
DeclarationError_ForeignReads = 33,
|
|
DeclarationError_ForeignType = 34,
|
|
DeclarationError_ForeignBody = 35,
|
|
DeclarationError_ForeignLibrary = 36,
|
|
DeclarationError_ForeignSymbol = 37,
|
|
DeclarationError_ForeignEnd = 38,
|
|
DeclarationError_ForeignHostRename = 39,
|
|
DeclarationError_ForeignGoResults = 40,
|
|
DeclarationError_ForeignGoField = 41,
|
|
DeclarationError_ForeignGoDefer = 42,
|
|
DeclarationError_ForeignGoVariadic = 43,
|
|
DeclarationError_ForeignDataType = 44,
|
|
DeclarationError_ForeignDataValue = 45,
|
|
DeclarationError_ResultCount = 46,
|
|
DeclarationError_ResultName = 47,
|
|
DeclarationError_ResultType = 48,
|
|
DeclarationError_ResultParameters = 49,
|
|
DeclarationError_ReturnCount = 50,
|
|
DeclarationError_SymmetricParameters = 51,
|
|
DeclarationError_SymmetricModifier = 52,
|
|
DeclarationError_ProcedureNameArguments = 53,
|
|
DeclarationError_BuilderFormat = 54,
|
|
DeclarationError_BuilderPercent = 55,
|
|
DeclarationError_BuilderArguments = 56,
|
|
DeclarationError_BuilderPieces = 57,
|
|
DeclarationError_BuilderArgumentCount = 58,
|
|
DeclarationError_BuilderPrintf = 59,
|
|
DeclarationError_GoVariadic = 60,
|
|
DeclarationError_GoMethodQuote = 61,
|
|
DeclarationError_GoMethodDuplicate = 62,
|
|
DeclarationError_GoMethodResults = 63,
|
|
DeclarationError_GoMethodForeign = 64,
|
|
DeclarationError_ProcedureTypeCount = 65,
|
|
DeclarationError_ProcedureTypeName = 66,
|
|
DeclarationError_ProcedureTypeType = 67,
|
|
DeclarationError_ProcedureTypeDefault = 68,
|
|
DeclarationError_ImportParameterList = 69,
|
|
DeclarationError_ImportParameterMode = 70,
|
|
DeclarationError_ParameterListSyntax = 71,
|
|
DeclarationError_ParameterName = 72,
|
|
DeclarationError_ParameterValue = 73,
|
|
DeclarationError_ParameterDuplicate = 74,
|
|
DeclarationError_ParameterType = 75,
|
|
DeclarationError_ParameterDefault = 76,
|
|
DeclarationError_ParameterFit = 77,
|
|
DeclarationError_InsertSyntax = 78,
|
|
};
|
|
|
|
struct GoMethodDeclaration {
|
|
DeclarationError error;
|
|
String name;
|
|
bool results;
|
|
bool variadic;
|
|
};
|
|
|
|
struct ExportDirective {
|
|
DeclarationError error;
|
|
int32_t kind;
|
|
String symbol;
|
|
String body;
|
|
};
|
|
|
|
struct ParameterRewrite {
|
|
DeclarationError error;
|
|
int64_t count;
|
|
int32_t parameters;
|
|
bool has_defaults;
|
|
uint64_t using_parameters;
|
|
};
|
|
|
|
enum {
|
|
ImportMode_Module = 0,
|
|
ImportMode_File = 1,
|
|
ImportMode_Directory = 2,
|
|
};
|
|
|
|
struct ModuleImport {
|
|
DeclarationError error;
|
|
bool present;
|
|
bool named;
|
|
bool using_import;
|
|
ImportMode mode;
|
|
String name;
|
|
String target;
|
|
String path;
|
|
String detail;
|
|
bool parameterized;
|
|
String parameters;
|
|
};
|
|
|
|
struct ParameterEntry {
|
|
DeclarationError error;
|
|
bool present;
|
|
String name;
|
|
String type;
|
|
String value;
|
|
int64_t next;
|
|
};
|
|
|
|
struct ModuleParameterDirective {
|
|
DeclarationError error;
|
|
bool present;
|
|
String list;
|
|
int64_t line;
|
|
};
|
|
|
|
struct InsertDirective {
|
|
DeclarationError error;
|
|
bool present;
|
|
String name;
|
|
};
|
|
|
|
struct LibraryDeclaration {
|
|
DeclarationError error;
|
|
bool present;
|
|
String name;
|
|
String target;
|
|
};
|
|
|
|
struct MethodSymbol {
|
|
bool valid;
|
|
String receiver;
|
|
String method;
|
|
};
|
|
|
|
struct UsingFilter {
|
|
DeclarationError error;
|
|
bool present;
|
|
int64_t count;
|
|
int64_t next;
|
|
};
|
|
|
|
struct ForeignDeclaration {
|
|
DeclarationError error;
|
|
bool present;
|
|
String name;
|
|
String library;
|
|
String symbol;
|
|
bool is_type;
|
|
bool go_results;
|
|
bool go_field;
|
|
bool go_defer;
|
|
bool go_variadic;
|
|
bool reads;
|
|
};
|
|
|
|
struct ForeignTarget {
|
|
DeclarationError error;
|
|
int64_t count;
|
|
};
|
|
|
|
struct ResultDeclaration {
|
|
DeclarationError error;
|
|
int32_t count;
|
|
String types[16];
|
|
int32_t parameter_count;
|
|
String parameters[64];
|
|
};
|
|
|
|
struct ResultReturn {
|
|
DeclarationError error;
|
|
bool present;
|
|
int32_t values;
|
|
int64_t count;
|
|
};
|
|
|
|
struct ResultBinding {
|
|
bool present;
|
|
int32_t count;
|
|
bool inferred;
|
|
String targets[16];
|
|
String value;
|
|
};
|
|
|
|
struct SymmetricRewrite {
|
|
DeclarationError error;
|
|
bool present;
|
|
bool needed;
|
|
int64_t header_count;
|
|
int64_t count;
|
|
};
|
|
|
|
struct TextRewrite {
|
|
DeclarationError error;
|
|
bool changed;
|
|
int64_t count;
|
|
};
|
|
|
|
struct NameReplacement {
|
|
String source;
|
|
String target;
|
|
};
|
|
|
|
struct PrintRewrite {
|
|
DeclarationError error;
|
|
int32_t statements;
|
|
int64_t lengths[64];
|
|
};
|
|
|
|
struct StatementOutput {
|
|
Slice bytes;
|
|
};
|
|
|
|
struct BuilderPrintPiece {
|
|
bool literal;
|
|
String text;
|
|
int32_t argument;
|
|
};
|
|
|
|
struct BuilderPrintScan {
|
|
DeclarationError error;
|
|
int32_t count;
|
|
BuilderPrintPiece pieces[64];
|
|
};
|
|
#ifdef ZIRAN_DECLARATION_H_PRIVATE
|
|
|
|
struct QuotedText {
|
|
bool valid;
|
|
String value;
|
|
int64_t end;
|
|
};
|
|
#endif
|
|
|
|
struct ForeignData {
|
|
ForeignDeclaration declaration;
|
|
String type;
|
|
};
|
|
#ifdef ZIRAN_DECLARATION_H_PRIVATE
|
|
|
|
struct CText {
|
|
uint8_t* data;
|
|
int64_t count;
|
|
};
|
|
#endif
|
|
String declaration_ErrorText(DeclarationError error);
|
|
GoMethodDeclaration declaration_ParseGoMethod(String source, int64_t name_limit);
|
|
UsingFilter declaration_UsingModifierClause(String source, Slice output, int64_t name_limit);
|
|
ExportDirective declaration_ProgramExport(String source, int64_t symbol_limit);
|
|
ParameterRewrite declaration_RewriteParameters(String source, Slice output, bool strip_defaults, bool strip_using, int64_t name_limit);
|
|
ParameterRewrite declaration_RewriteProcedureTypeParameters(String source, Slice output, int64_t name_limit);
|
|
ModuleImport declaration_ImportDeclaration(String source, int64_t name_limit, int64_t path_limit);
|
|
String declaration_ParameterLiteralType(String value);
|
|
bool declaration_ParameterTypeName(String type);
|
|
bool declaration_ParameterFits(String type, String value);
|
|
int64_t declaration_ParameterCanonical(String value, Slice output);
|
|
ParameterEntry declaration_NextParameter(String list, int64_t at, bool declaration, int64_t name_limit);
|
|
DeclarationError declaration_ParameterListError(String list, bool declaration, int64_t name_limit);
|
|
InsertDirective declaration_InsertDeclaration(String source, int64_t name_limit);
|
|
ModuleParameterDirective declaration_ModuleParametersPrefix(String source, int64_t name_limit);
|
|
LibraryDeclaration declaration_SystemLibrary(String source, int64_t name_limit, int64_t path_limit);
|
|
MethodSymbol declaration_ForeignMethod(String source, int64_t receiver_limit, int64_t method_limit);
|
|
ForeignDeclaration declaration_ParseForeign(String source, int64_t name_limit);
|
|
void declaration_ParseForeignTail(String declaration, int64_t directive, int64_t name_limit, ForeignDeclaration* result);
|
|
ForeignData declaration_ParseForeignData(String source, int64_t name_limit);
|
|
ForeignTarget declaration_ResolveForeignTarget(ForeignDeclaration declaration, String library, Slice output, int64_t name_limit);
|
|
bool declaration_ForeignVarargs(String parameters);
|
|
ResultDeclaration declaration_ParseResults(String source, String template_parameters);
|
|
int64_t declaration_ResultsRecord(ResultDeclaration results, Slice output);
|
|
int64_t declaration_ResultsParameters(ResultDeclaration results, Slice output);
|
|
int64_t declaration_ResultsBody(ResultDeclaration results, Slice output);
|
|
ResultReturn declaration_RewriteResultReturn(String source, String record, int32_t results, Slice output);
|
|
ResultBinding declaration_MultipleBinding(String source, int32_t maximum, int64_t name_limit);
|
|
bool declaration_UsesTypeParameter(String source, String parameters);
|
|
bool declaration_DefaultScopeIndependent(String source, int64_t token_limit);
|
|
TextRewrite declaration_RewriteProcedureName(String source, String name, Slice output);
|
|
TextRewrite declaration_RewriteLocalNames(String source, Slice names, Slice output);
|
|
SymmetricRewrite declaration_RewriteSymmetric(String source, Slice header_output, Slice wrapper_output, int64_t name_limit);
|
|
bool declaration_PrintfSpelling(String format, bool loose);
|
|
int32_t FormatPrintfSpelling(uint8_t* format, int32_t loose);
|
|
void declaration_BuilderPrintLiteral(Slice output, int64_t* used, String text);
|
|
BuilderPrintScan declaration_ScanPrintFormat(String format, int32_t arguments);
|
|
PrintRewrite declaration_BuilderPrintPieces(String source, Slice output, int32_t maximum);
|
|
|
|
/* Small procedures other modules inline; declaration.c defines them. */
|
|
#if !defined(__cplusplus) && !defined(ZIRAN_DECLARATION_H_SOURCE) && !defined(ZIRAN_NO_HEADER_INLINE)
|
|
#include <stdbool.h>
|
|
#include "zir_string.h"
|
|
static inline DeclarationError declaration_ParameterListError_ziran_inline(String list, bool declaration, int64_t name_limit);
|
|
#define declaration_ParameterListError(...) declaration_ParameterListError_ziran_inline(__VA_ARGS__)
|
|
|
|
static inline DeclarationError
|
|
declaration_ParameterListError_ziran_inline(String list, bool declaration, int64_t name_limit)
|
|
{
|
|
int64_t at = 0LL;
|
|
while (at >= 0LL) {
|
|
ParameterEntry entry = declaration_NextParameter(list, at, declaration, name_limit);
|
|
if (((DeclarationError)(entry.error)) != DeclarationError_None) {
|
|
return (DeclarationError)(entry.error);
|
|
}
|
|
int64_t earlier = 0LL;
|
|
while (earlier >= 0LL && earlier < at) {
|
|
ParameterEntry previous = declaration_NextParameter(list, earlier, declaration, name_limit);
|
|
if (StringEqual(previous.name, entry.name)) {
|
|
return DeclarationError_ParameterDuplicate;
|
|
}
|
|
earlier = previous.next;
|
|
}
|
|
at = entry.next;
|
|
}
|
|
return DeclarationError_None;
|
|
}
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* ZIRAN_DECLARATION_H */
|