From: Brendan Hansen Date: Fri, 24 Feb 2023 05:05:15 +0000 (-0600) Subject: cleanup: removed all notion of 'notes' deprecated feature X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=ee42c6a148f6f68610dc3cb2989a6a1c761dc1ae;p=onyx.git cleanup: removed all notion of 'notes' deprecated feature --- diff --git a/compiler/include/astnodes.h b/compiler/include/astnodes.h index 2b14bc3d..60eb8693 100644 --- a/compiler/include/astnodes.h +++ b/compiler/include/astnodes.h @@ -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; diff --git a/compiler/include/lex.h b/compiler/include/lex.h index 55dccefb..6665cd32 100644 --- a/compiler/include/lex.h +++ b/compiler/include/lex.h @@ -78,8 +78,6 @@ typedef enum TokenType { Token_Type_Literal_True, Token_Type_Literal_False, - Token_Type_Note, - Token_Type_Count, } TokenType; diff --git a/compiler/src/astnodes.c b/compiler/src/astnodes.c index d35b4d5c..1dcfb843 100644 --- a/compiler/src/astnodes.c +++ b/compiler/src/astnodes.c @@ -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; diff --git a/compiler/src/checker.c b/compiler/src/checker.c index 2fa0d62f..8494d842 100644 --- a/compiler/src/checker.c +++ b/compiler/src/checker.c @@ -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)); } } } diff --git a/compiler/src/entities.c b/compiler/src/entities.c index 745ae4ae..8c4fa813 100644 --- a/compiler/src/entities.c +++ b/compiler/src/entities.c @@ -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; diff --git a/compiler/src/lex.c b/compiler/src/lex.c index 50576ec1..43079f69 100644 --- a/compiler/src/lex.c +++ b/compiler/src/lex.c @@ -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)))) { diff --git a/compiler/src/onyx.c b/compiler/src/onyx.c index b58be803..b6b53252 100644 --- a/compiler/src/onyx.c +++ b/compiler/src/onyx.c @@ -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; } diff --git a/compiler/src/parser.c b/compiler/src/parser.c index 410ac3b6..0e195ec0 100644 --- a/compiler/src/parser.c +++ b/compiler/src/parser.c @@ -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); diff --git a/compiler/src/wasm_emit.c b/compiler/src/wasm_emit.c index 27fc5d2e..cc337cd9 100644 --- a/compiler/src/wasm_emit.c +++ b/compiler/src/wasm_emit.c @@ -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; }