From 094b10576eb4bd68faec27a55240686ac98afa7c Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Tue, 27 Sep 2022 15:15:23 +0200 Subject: [PATCH] Helping out sublime indexing --- base_string.cpp | 3 ++- core_main.cpp | 19 ++++++++++++++----- core_typechecking.cpp | 5 ++++- core_typechecking.h | 6 ++++-- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/base_string.cpp b/base_string.cpp index 2a149c9..9af9bc7 100644 --- a/base_string.cpp +++ b/base_string.cpp @@ -385,7 +385,8 @@ string_to_upper_case(Allocator *arena, String s) { return copy; } -FLAG32(MatchFlag){ +typedef U32 MatchFlag; +enum { MatchFlag_None=0, MatchFlag_FindLast=1, MatchFlag_IgnoreCase=2, diff --git a/core_main.cpp b/core_main.cpp index 7ef42cd..7e3f226 100644 --- a/core_main.cpp +++ b/core_main.cpp @@ -57,8 +57,10 @@ For modules it's a bit different cause they should be distributed as valid. ------------------------------------------------------------------------------- - [ ] Basic + - [ ] Calculate size and alignment of struct data types + - [ ] Pass size and alignment calculations to C ? - [ ] Fix . operator lookups - + - [ ] Combining casts with . operator - [ ] Builtin data structures - [ ] Fix Length etc. they should be function calls not operators @@ -69,6 +71,11 @@ For modules it's a bit different cause they should be distributed as valid. - [ ] Dynamic arrays - [ ] Hash tables +- [ ] C Codegen + - [ ] Function renaming to prevent colissions + +- [ ] Using language construct + - [ ] Bytecode interpreter - [ ] Ir - [ ] Interpreter @@ -76,8 +83,12 @@ For modules it's a bit different cause they should be distributed as valid. - [ ] Parametric Polymorphism +- [ ] Conditional compilation #if -- [ ] Improvements +- [ ] Any + - [ ] Assigning to any values like ints etc. should work perhaps? But what type they should have? + - [ ] Var args using any + - [ ] Slice of Any should work well - [ ] Probably need to give Ast_Expr a Value field, then I can express Type nicely - [ ] I would love for String, slice, Any etc. to have their struct declarations in source files, I also would want for stuff like string.str to work without weird special cases @@ -99,7 +110,6 @@ For modules it's a bit different cause they should be distributed as valid. - [ ] Write up on order independent declarations - [ ] constructor => thing :: (i: S32) -> {i = i, thing = 10} -- [ ] Casting to basic types by call S64(x) - [ ] Default values in structs??? Should compound stmts bring values from default values?? Maybe not? Whats the alternative @ideas @@ -108,8 +118,7 @@ For modules it's a bit different cause they should be distributed as valid. - [ ] Rust like enum where you associate values(other structs) with keys - [ ] Compound that zeros values - .{} , Compound that assumes defaults from struct definition - {} - [ ] Inject stack traces into the program -- [ ] Conditional compilation #if -- [ ] Polymorphism - create declaration of a polymorphic thing, when it's called just copy it, replace types and typecheck normally, when someone calls again you just search for the instantiation again + ## Done diff --git a/core_typechecking.cpp b/core_typechecking.cpp index e0d7f42..a6eb8bb 100644 --- a/core_typechecking.cpp +++ b/core_typechecking.cpp @@ -345,7 +345,8 @@ try_converting_untyped_to_default_type(Operand *op){ try_converting_untyped_to_default_type(&op->value); } -FLAG32(Typecheck_Flag){ +typedef U32 Typecheck_Flag; +enum { TYPE_AND_EXPR_REQUIRED = 0, TYPE_CAN_BE_NULL = 1, EXPR_CAN_BE_NULL = 2 @@ -1227,6 +1228,7 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_context){ Ast_Expr *expr = unpack_ast_call_expr_for_builtin(node); Operand name = resolve_expr(expr, inherit_flag(flags, AST_CANT_BE_NULL)); + node->kind = AST_SIZE_OF; if(!name.is_const){ compiler_error(node->pos, "SizeOf requires a constant value"); } @@ -1262,6 +1264,7 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_context){ else if(expr_atom_is_equal_intern(node->name, intern_alignof)){ Ast_Expr *expr = unpack_ast_call_expr_for_builtin(node); Operand name = resolve_expr(expr, inherit_flag(flags, AST_CANT_BE_NULL)); + node->kind = AST_ALIGN_OF; if(!name.is_const) compiler_error(node->pos, "AlignOf requires a constant value"); Ast_Type *type = name.type == type_type ? name.type_val : name.type; Value v = value_int(type->align); diff --git a/core_typechecking.h b/core_typechecking.h index 70a83ae..19d54ce 100644 --- a/core_typechecking.h +++ b/core_typechecking.h @@ -6,14 +6,16 @@ struct Operand{ U8 pound_strict: 1; }; -FLAG32(Resolve_Flag){ +typedef U32 Resolve_Flag; +enum{ AST_CANT_BE_NULL = bit_flag(0), AST_CAN_BE_NULL = bit_flag(1), RESOLVE_TYPESPEC_COMPLETE = bit_flag(2), RESOLVE_TYPESPEC = bit_flag(3), }; -FLAG32(Search_Flag){ +typedef U32 Search_Flag; +enum{ SEARCH_ONLY_CURRENT_SCOPE = bit_flag(1), };