cleanup: removed all notion of 'notes' deprecated feature
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 24 Feb 2023 05:05:15 +0000 (23:05 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 24 Feb 2023 05:05:15 +0000 (23:05 -0600)
compiler/include/astnodes.h
compiler/include/lex.h
compiler/src/astnodes.c
compiler/src/checker.c
compiler/src/entities.c
compiler/src/lex.c
compiler/src/onyx.c
compiler/src/parser.c
compiler/src/wasm_emit.c

index 2b14bc3d36462c72ad5af19bb895140840f9ade4..60eb86930e842c51545cab16e28d10ef5f8edf54 100644 (file)
@@ -97,7 +97,6 @@
     NODE(PolyProc)             \
     NODE(PolyQuery)            \
                                \
-    NODE(Note)                 \
     NODE(CallSite)             \
                                \
     NODE(CodeBlock)            \
@@ -234,8 +233,6 @@ typedef enum AstKind {
 
     Ast_Kind_Zero_Value,
 
-    Ast_Kind_Note,
-
     Ast_Kind_Count
 } AstKind;
 
@@ -1356,9 +1353,6 @@ struct AstDirectiveExportName {
     b32 created_export_entity : 1;
 };
 
-struct AstNote {
-    AstNode_base;
-};
 
 struct AstCallSite {
     AstTyped_base;
@@ -1441,7 +1435,6 @@ typedef enum EntityType {
     Entity_Type_Unknown,
 
     Entity_Type_Error,
-    Entity_Type_Note,
     Entity_Type_Load_Path,
     Entity_Type_Load_File,
     Entity_Type_Binding,
@@ -1594,7 +1587,6 @@ struct CompileOptions {
     b32 fun_output              : 1;
     b32 print_function_mappings : 1;
     b32 print_static_if_results : 1;
-    b32 print_notes             : 1;
     b32 no_colors               : 1;
     b32 no_file_contents        : 1;
 
index 55dccefb2c8cab4300587e51822e617e0643199a..6665cd323e18792e1c54cd7d9a1a052c08a6566b 100644 (file)
@@ -78,8 +78,6 @@ typedef enum TokenType {
     Token_Type_Literal_True,
     Token_Type_Literal_False,
 
-    Token_Type_Note,
-
     Token_Type_Count,
 } TokenType;
 
index d35b4d5c62be234231d6dc1a03d063663d8f3df4..1dcfb8434bd0db53a2aa632b3a9289857fcdaa03 100644 (file)
@@ -109,9 +109,7 @@ static const char* ast_node_names[] = {
 
     "FOREIGN BLOCK",
     "ZERO VALUE",
-
-    "NOTE",
-
+    
     "AST_NODE_KIND_COUNT",
 };
 
@@ -150,7 +148,6 @@ const char* entity_state_strings[Entity_State_Count] = {
 const char* entity_type_strings[Entity_Type_Count] = {
     "Unknown",
     "Error",
-    "Note",
     "Add to Load Path",
     "Load File",
     "Binding (Declaration)",
@@ -513,7 +510,6 @@ b32 convert_numlit_to_type(AstNumLit* num, Type* to_type) {
 
         else if (type->Basic.flags & Basic_Flag_Float) {
             if (type->Basic.size == 4) {
-                // TODO(Brendan): Check these boundary conditions
                 if (bh_abs(num->value.l) >= (1 << 23)) {
                     onyx_report_error(num->token->pos, Error_Critical, "Integer '%l' does not fit in 32-bit float exactly.", num->value.l);
                     return 0;
@@ -524,7 +520,6 @@ b32 convert_numlit_to_type(AstNumLit* num, Type* to_type) {
                 return 1;
             }
             if (type->Basic.size == 8) {
-                // TODO(Brendan): Check these boundary conditions
                 if (bh_abs(num->value.l) >= (1ull << 52)) {
                     onyx_report_error(num->token->pos, Error_Critical, "Integer '%l' does not fit in 64-bit float exactly.", num->value.l);
                     return 0;
index 2fa0d62fa4ea9bb0514f61e34bc20b67665031a5..8494d84286dc707946cd1c24ab6b31bf67b01a04 100644 (file)
@@ -1859,7 +1859,8 @@ CheckStatus check_field_access(AstFieldAccess** pfield) {
         StructMember containing_member = smem;
 
         // TODO: The following code is not right after it loops, but this should never loop
-        // due to a check in types.c line 947.
+        // due to a check in types.c line 947. When nested use-through-pointers are allowed,
+        // thing will have to be reconsidered.
         AstTyped **dest = &field->expr;
         do {
             assert(type_lookup_member_by_idx((*dest)->type, containing_member.use_through_pointer_index, &containing_member));
@@ -2602,13 +2603,19 @@ CheckStatus check_struct(AstStructType* s_node) {
             Type *arg_type = type_build_from_ast(context.ast_alloc, s_node->polymorphic_argument_types[i]);
             if (arg_type == NULL) YIELD(s_node->polymorphic_argument_types[i]->token->pos, "Waiting to build type for polymorph argument.");
 
-            // CLEANUP: This might be wrong...
-            if (s_node->polymorphic_arguments[i].value) {
-                TYPE_CHECK(&s_node->polymorphic_arguments[i].value, arg_type) {
-                    ERROR_(s_node->polymorphic_arguments[i].value->token->pos, "Expected value of type %s, got %s.",
-                        type_get_name(arg_type),
-                        type_get_name(s_node->polymorphic_arguments[i].value->type));
-                }
+            //
+            // This check should always be false, but it handles
+            // the case where somewhere a type was expected, but
+            // not enough values were provided. This is checked
+            // elsewhere when instantiating a polymorphic sturucture.
+            if (i >= bh_arr_length(s_node->polymorphic_arguments)
+                || !s_node->polymorphic_arguments[i].value) continue;
+
+            
+            TYPE_CHECK(&s_node->polymorphic_arguments[i].value, arg_type) {
+                ERROR_(s_node->polymorphic_arguments[i].value->token->pos, "Expected value of type %s, got %s.",
+                    type_get_name(arg_type),
+                    type_get_name(s_node->polymorphic_arguments[i].value->type));
             }
         }
     }
index 745ae4ae964c833fef96b8304df614f97b5907a7..8c4fa81362307c43d11fc9714f6f640cfeb0d8e1 100644 (file)
@@ -376,14 +376,6 @@ void add_entities_for_node(bh_arr(Entity *) *target_arr, AstNode* node, Scope* s
             break;
         }
 
-        case Ast_Kind_Note: {
-            ent.type = Entity_Type_Note;
-            ent.expr = (AstTyped *) node;
-            ent.state = Entity_State_Code_Gen;
-            ENTITY_INSERT(ent);
-            break;
-        }
-
         case Ast_Kind_Interface: {
             ent.type = Entity_Type_Interface;
             ent.interface = (AstInterface *) node;
index 50576ec1380ab29d0e0bd8161a620ab83665cc53..43079f6946a46927ecdd9bd0441cdbbec938317a 100644 (file)
@@ -75,8 +75,6 @@ static const char* token_type_names[] = {
     "true",
     "false",
 
-    "NOTE",
-
     "TOKEN_TYPE_COUNT"
 };
 
@@ -293,20 +291,6 @@ whitespace_skipped:
         goto token_parsed;
     }
 
-    /*if (*tokenizer->curr == '@') {
-        INCREMENT_CURR_TOKEN(tokenizer);
-        u32 len = 2;
-        while (char_is_alphanum(*(tokenizer->curr + 1)) || *(tokenizer->curr + 1) == '_') {
-            len++;
-            INCREMENT_CURR_TOKEN(tokenizer);
-        }
-
-        tk.type = Token_Type_Note;
-        tk.length = len;
-        INCREMENT_CURR_TOKEN(tokenizer);
-        goto token_parsed;
-    }*/
-
     // Number literal
     if (char_is_num(*tokenizer->curr)
         || (*(tokenizer->curr) == '.' && char_is_num(*(tokenizer->curr + 1)))) {
index b58be8030366c2b34f465bf8aad5bf98713976a3..b6b53252cff58eab7279e8dda5403dda84e3c63d 100644 (file)
@@ -58,7 +58,6 @@ static const char* docstring = "Onyx compiler version " VERSION "\n"
     "Developer flags:\n"
     "\t--print-function-mappings Prints a mapping from WASM function index to source location.\n"
     "\t--print-static-if-results Prints the conditional result of each #if statement. Useful for debugging.\n"
-    "\t--print-notes             Prints the location of notes throughout the loaded code.\n"
     "\t--no-colors               Disables colors in the error message.\n"
     "\t--no-file-contents        Disables '#file_contents' for security.\n"
     "\n";
@@ -150,9 +149,6 @@ static CompileOptions compile_opts_parse(bh_allocator alloc, int argc, char *arg
             else if (!strcmp(argv[i], "--print-static-if-results")) {
                 options.print_static_if_results = 1;
             }
-            else if (!strcmp(argv[i], "--print-notes")) {
-                options.print_notes = 1;
-            }
             else if (!strcmp(argv[i], "--no-colors")) {
                 options.no_colors = 1;
             }
index 410ac3b66e8a21edf20c034c767ca3aa64b074f2..0e195ec0f13031de11b1c511b0a15d4b204384e0 100644 (file)
@@ -85,13 +85,7 @@ static void consume_token(OnyxParser* parser) {
     parser->prev = parser->curr;
     // :LinearTokenDependent
     parser->curr++;
-    while (parser->curr->type == Token_Type_Comment || parser->curr->type == Token_Type_Note) {
-        // if (parser->curr->type == Token_Type_Note) {
-        //     AstNote* note = make_node(AstNode, Ast_Kind_Note);
-        //     note->token = parser->curr;
-        //     ENTITY_SUBMIT(note);
-        // }
-
+    while (parser->curr->type == Token_Type_Comment) {
         parser->curr++;
     }
 }
@@ -162,7 +156,7 @@ static b32 next_tokens_are(OnyxParser* parser, i32 n, ...) {
 
     i32 matched = 1;
 
-    // BUG: This does not take into consideration comments and notes that can occur between any tokens.
+    // BUG: This does not take into consideration comments that can occur between any tokens.
     fori (i, 0, n) {
         TokenType expected_type = va_arg(va, TokenType);
         if (peek_token(i)->type != expected_type) {
@@ -3644,7 +3638,7 @@ void onyx_parser_free(OnyxParser* parser) {
 
 void onyx_parse(OnyxParser *parser) {
     // NOTE: Skip comments at the beginning of the file
-    while (consume_token_if_next(parser, Token_Type_Comment) || consume_token_if_next(parser, Token_Type_Note));
+    while (consume_token_if_next(parser, Token_Type_Comment));
 
     parser->package = parse_file_package(parser);
     parser->file_scope = scope_create(parser->allocator, parser->package->private_scope, parser->tokenizer->tokens[0].pos);
index 27fc5d2e50adee0502ad2d97fb09474492e557b5..cc337cd9d41c896f777d06b3fe91c8780a514eff 100644 (file)
@@ -4739,19 +4739,6 @@ void emit_entity(Entity* ent) {
         case Entity_Type_Function: emit_function(module, ent->function); break;
         case Entity_Type_Global:   emit_global(module,   ent->global); break;
 
-        // Cleanup: Maybe these should be printed elsewhere?
-        // Also, they should be sorted? Or have that ability?
-        case Entity_Type_Note: {
-            if (!context.options->print_notes) break;
-
-            AstNote* note = (AstNote *) ent->expr;
-            OnyxFilePos pos = note->token->pos;
-
-            bh_printf("Note: %b %s:%d:%d\n", note->token->text, note->token->length, pos.filename, pos.line, pos.column);
-
-            break;
-        }
-
         default: break;
     }