Clang format on hpp

This commit is contained in:
Krzosa Karol
2023-03-29 09:11:17 +02:00
parent 0622811a87
commit c97bb4272b

View File

@@ -12,7 +12,7 @@ struct Ast_Type;
struct Ast_Expr; struct Ast_Expr;
#ifndef CORE_BASE #ifndef CORE_BASE
#define CORE_BASE #define CORE_BASE
struct Allocator { struct Allocator {
typedef void *Allocate(Allocator *, size_t); typedef void *Allocate(Allocator *, size_t);
@@ -22,13 +22,13 @@ struct Allocator {
Deallocate *deallocate; Deallocate *deallocate;
}; };
struct String{ struct String {
uint8_t *str; uint8_t *str;
int64_t len; int64_t len;
}; };
typedef String Intern_String; typedef String Intern_String;
template<class T> template <class T>
struct Array { struct Array {
void *allocator; void *allocator;
T *data; T *data;
@@ -36,8 +36,8 @@ struct Array {
int64_t len; int64_t len;
}; };
template<class T> template <class T>
struct List_Node{ struct List_Node {
List_Node<T> *next; List_Node<T> *next;
List_Node<T> *prev; List_Node<T> *prev;
int cap; int cap;
@@ -45,8 +45,8 @@ struct List_Node{
T data[]; T data[];
}; };
template<class T> template <class T>
struct List{ struct List {
int block_size = 0; int block_size = 0;
int allocation_multiplier = 0; int allocation_multiplier = 0;
List_Node<T> *first = 0; List_Node<T> *first = 0;
@@ -56,7 +56,7 @@ struct List{
#endif #endif
enum Token_Kind{ enum Token_Kind {
TK_End, TK_End,
/*# /*#
import meta import meta
@@ -156,12 +156,12 @@ struct BigInt {
}; };
}; };
struct Token{ struct Token {
Token_Kind kind; Token_Kind kind;
uint32_t di; // debug_id uint32_t di; // debug_id
union{ union {
String string; String string;
struct{ struct {
uint8_t *str; uint8_t *str;
int64_t len; int64_t len;
}; };
@@ -181,18 +181,18 @@ struct Token{
uint8_t *line_begin; uint8_t *line_begin;
}; };
enum Ast_Type_Kind{ enum Ast_Type_Kind {
TYPE_NONE, TYPE_NONE,
TYPE_S64, // FIRST_NUMERIC TYPE_S64, // FIRST_NUMERIC
TYPE_S32, TYPE_S32,
TYPE_S16, TYPE_S16,
TYPE_S8 , TYPE_S8,
TYPE_INT, TYPE_INT,
TYPE_CHAR, TYPE_CHAR,
TYPE_U64, TYPE_U64,
TYPE_U32, TYPE_U32,
TYPE_U16, TYPE_U16,
TYPE_U8 , TYPE_U8,
TYPE_F32, TYPE_F32,
TYPE_F64, TYPE_F64,
TYPE_POINTER, TYPE_POINTER,
@@ -241,7 +241,7 @@ struct Value {
/*END*/ /*END*/
}; };
struct Ast_Resolved_Member{ struct Ast_Resolved_Member {
Intern_String name; Intern_String name;
int32_t offset; int32_t offset;
bool visited; bool visited;
@@ -265,7 +265,7 @@ struct Ast_Resolved_Member{
/*END*/ /*END*/
}; };
struct Ast_Type{ struct Ast_Type {
Ast_Type_Kind kind; Ast_Type_Kind kind;
int32_t size; int32_t size;
int32_t align; int32_t align;
@@ -274,9 +274,9 @@ struct Ast_Type{
int32_t padding; int32_t padding;
Ast *ast; Ast *ast;
union{ union {
Ast_Type *base; Ast_Type *base;
struct{ struct {
Ast_Type *base; Ast_Type *base;
int32_t size; int32_t size;
// @note: if you have array with size "[32]" // @note: if you have array with size "[32]"
@@ -284,19 +284,19 @@ struct Ast_Type{
// a function that expects an array of size "[]" // a function that expects an array of size "[]"
// so we want also should check this // so we want also should check this
uint64_t slice_hash; uint64_t slice_hash;
}arr; } arr;
struct{ struct {
Array<Ast_Resolved_Member> members; Array<Ast_Resolved_Member> members;
}agg; } agg;
struct{ struct {
Ast_Type * ret; Ast_Type *ret;
Array<Ast_Type *> args; Array<Ast_Type *> args;
uint64_t hash_without_ret; uint64_t hash_without_ret;
}func; } func;
}; };
}; };
enum Ast_Kind: uint32_t{ enum Ast_Kind : uint32_t {
AST_NONE, AST_NONE,
AST_NAMESPACE, AST_NAMESPACE,
@@ -345,7 +345,7 @@ enum Ast_Kind: uint32_t{
}; };
typedef uint32_t Ast_Flag; typedef uint32_t Ast_Flag;
enum{ enum {
AST_EXPR = 1ull << 1, AST_EXPR = 1ull << 1,
AST_STMT = 1ull << 2, AST_STMT = 1ull << 2,
AST_STRICT = 1ull << 3, AST_STRICT = 1ull << 3,
@@ -361,7 +361,7 @@ enum{
AST_IS_LVALUE = 1ull << 14, AST_IS_LVALUE = 1ull << 14,
}; };
struct Ast{ struct Ast {
uint64_t di; // Debug id, shouldn't ever be used in the program uint64_t di; // Debug id, shouldn't ever be used in the program
Token *pos; Token *pos;
@@ -370,17 +370,17 @@ struct Ast{
Ast_Flag flags; Ast_Flag flags;
}; };
struct Ast_Expr:Ast{ struct Ast_Expr : Ast {
Ast_Type *resolved_type; Ast_Type *resolved_type;
Ast_Decl *resolved_operator_overload; Ast_Decl *resolved_operator_overload;
union{ union {
Ast_Type *index_original_type; Ast_Type *index_original_type;
Ast_Type *cast_after_type; Ast_Type *cast_after_type;
Ast_Type *dot_access_step_resolution; Ast_Type *dot_access_step_resolution;
}; };
}; };
struct Ast_Atom: Ast_Expr{ struct Ast_Atom : Ast_Expr {
// We have a field type here // We have a field type here
// it has a different purpose from the // it has a different purpose from the
// resolved_type of Ast_Expr, it describes // resolved_type of Ast_Expr, it describes
@@ -410,13 +410,13 @@ struct Ast_Atom: Ast_Expr{
}; };
typedef uint32_t Ast_Call_Item_Flag; typedef uint32_t Ast_Call_Item_Flag;
enum{ enum {
CALL_INDEX = 1ull << 1, CALL_INDEX = 1ull << 1,
CALL_NAME = 1ull << 2, CALL_NAME = 1ull << 2,
CALL_INCLUDED= 1ull << 4, CALL_INCLUDED = 1ull << 4,
}; };
struct Ast_Call_Item: Ast_Expr{ struct Ast_Call_Item : Ast_Expr {
Ast_Call_Item_Flag call_flags; Ast_Call_Item_Flag call_flags;
int32_t resolved_index; int32_t resolved_index;
Ast_Expr *item; Ast_Expr *item;
@@ -427,8 +427,8 @@ struct Ast_Call_Item: Ast_Expr{
Intern_String resolved_name; Intern_String resolved_name;
}; };
struct Ast_Call: Ast_Expr{ struct Ast_Call : Ast_Expr {
union{ union {
Ast_Expr *name; Ast_Expr *name;
Ast_Expr *typespec; Ast_Expr *typespec;
}; };
@@ -436,30 +436,30 @@ struct Ast_Call: Ast_Expr{
Ast_Decl *resolved_decl; Ast_Decl *resolved_decl;
}; };
struct Ast_Var_Unpack: Ast_Expr{ struct Ast_Var_Unpack : Ast_Expr {
Array<Ast_Decl *> vars; Array<Ast_Decl *> vars;
Ast_Expr *expr; Ast_Expr *expr;
}; };
struct Ast_Unary: Ast_Expr{ struct Ast_Unary : Ast_Expr {
Token_Kind op; Token_Kind op;
Ast_Expr *expr; Ast_Expr *expr;
uint64_t padding[2]; // For folding constants into atoms uint64_t padding[2]; // For folding constants into atoms
}; };
struct Ast_Index: Ast_Expr{ struct Ast_Index : Ast_Expr {
Ast_Expr *expr; Ast_Expr *expr;
Ast_Expr *index; Ast_Expr *index;
}; };
struct Ast_Binary: Ast_Expr{ struct Ast_Binary : Ast_Expr {
Token_Kind op; Token_Kind op;
Ast_Expr *left; Ast_Expr *left;
Ast_Expr *right; Ast_Expr *right;
Ast_Type *before_type; Ast_Type *before_type;
}; };
struct Ast_Builtin: Ast_Expr{ struct Ast_Builtin : Ast_Expr {
Ast_Expr *expr; Ast_Expr *expr;
Intern_String assert_message; Intern_String assert_message;
uint64_t padding[1]; // For folding constants into atoms uint64_t padding[1]; // For folding constants into atoms
@@ -472,25 +472,25 @@ struct Ast_Builtin: Ast_Expr{
// look into global scope and to the locals list. // look into global scope and to the locals list.
// //
struct Ast_Return: Ast{ struct Ast_Return : Ast {
Ast_Type *resolved_type; Ast_Type *resolved_type;
Array<Ast_Expr *> expr; Array<Ast_Expr *> expr;
}; };
struct Ast_If_Node: Ast{ struct Ast_If_Node : Ast {
Ast_Expr *expr ; Ast_Expr *expr;
Ast_Scope *scope; Ast_Scope *scope;
Ast_Binary*init; Ast_Binary *init;
}; };
struct Ast_If: Ast{ struct Ast_If : Ast {
Array<Ast_If_Node *> ifs; Array<Ast_If_Node *> ifs;
}; };
struct Ast_Pass: Ast{}; struct Ast_Pass : Ast {};
struct Ast_Break: Ast{}; struct Ast_Break : Ast {};
struct Ast_For: Ast{ struct Ast_For : Ast {
Ast_Expr *init; Ast_Expr *init;
Ast_Expr *cond; Ast_Expr *cond;
Ast_Expr *iter; Ast_Expr *iter;
@@ -507,19 +507,19 @@ struct Ast_Lambda : Ast_Expr {
Ast_Scope *scope; Ast_Scope *scope;
}; };
struct Ast_Array: Ast_Expr{ struct Ast_Array : Ast_Expr {
Ast_Expr *base; Ast_Expr *base;
Ast_Expr *expr; Ast_Expr *expr;
uint64_t padding[2]; uint64_t padding[2];
}; };
struct Ast_Switch_Case: Ast{ struct Ast_Switch_Case : Ast {
Array<Ast_Expr *> labels; Array<Ast_Expr *> labels;
Ast_Scope *scope; Ast_Scope *scope;
bool fallthrough; bool fallthrough;
}; };
struct Ast_Switch: Ast{ struct Ast_Switch : Ast {
Ast_Expr *value; Ast_Expr *value;
Array<Ast_Switch_Case *> cases; Array<Ast_Switch_Case *> cases;
Ast_Scope *default_scope; Ast_Scope *default_scope;
@@ -544,7 +544,7 @@ struct Ast_Switch: Ast{
*/ */
struct Ast_Scope: Ast{ struct Ast_Scope : Ast {
String debug_name; // Only for debug purposes, dont depend on it String debug_name; // Only for debug purposes, dont depend on it
List<Ast_Scope *> implicit_imports; List<Ast_Scope *> implicit_imports;
List<Ast_Decl *> decls; List<Ast_Decl *> decls;
@@ -556,33 +556,33 @@ struct Ast_Scope: Ast{
Ast_Module *module; Ast_Module *module;
}; };
enum Ast_Module_State{ enum Ast_Module_State {
MODULE_REGISTERED, MODULE_REGISTERED,
MODULE_PARSED, MODULE_PARSED,
MODULE_RESOLVED, MODULE_RESOLVED,
}; };
struct Ast_Module: Ast_Scope{ struct Ast_Module : Ast_Scope {
Ast_Module_State state; Ast_Module_State state;
String absolute_base_folder; String absolute_base_folder;
String absolute_file_path; String absolute_file_path;
List<Ast_File *> all_loaded_files; List<Ast_File *> all_loaded_files;
}; };
struct Ast_File: Ast_Scope{ struct Ast_File : Ast_Scope {
String absolute_base_folder; String absolute_base_folder;
String absolute_file_path; String absolute_file_path;
String filecontent; String filecontent;
}; };
enum Ast_Decl_State{ enum Ast_Decl_State {
DECL_NOT_RESOLVED, DECL_NOT_RESOLVED,
DECL_RESOLVED, DECL_RESOLVED,
DECL_RESOLVED_TYPE, DECL_RESOLVED_TYPE,
DECL_RESOLVING, DECL_RESOLVING,
}; };
struct Ast_Operator_Info{ struct Ast_Operator_Info {
Intern_String op; Intern_String op;
String name; String name;
Token_Kind op_kind; Token_Kind op_kind;
@@ -590,7 +590,7 @@ struct Ast_Operator_Info{
bool valid_unary_expr; bool valid_unary_expr;
}; };
struct Ast_Decl: Ast{ struct Ast_Decl : Ast {
Ast_Decl_State state; Ast_Decl_State state;
Intern_String name; Intern_String name;
Intern_String unique_name; // For code generation, currently only present on lambdas Intern_String unique_name; // For code generation, currently only present on lambdas
@@ -600,14 +600,14 @@ struct Ast_Decl: Ast{
Ast_Scope *scope; Ast_Scope *scope;
Ast_Expr *typespec; Ast_Expr *typespec;
union{ union {
Ast_Expr *expr; Ast_Expr *expr;
Ast_Lambda *lambda; Ast_Lambda *lambda;
}; };
/*#import meta /*#import meta
meta.inline_value_fields() meta.inline_value_fields()
*/ */
union { union {
Value value; Value value;
struct { struct {