From: Brendan Hansen Date: Mon, 14 Dec 2020 21:47:52 +0000 (-0600) Subject: can 'use' pointers to structures; cleanup X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=74c9e06f4432208e5f3d3e7b0377c768bc7efff6;p=onyx.git can 'use' pointers to structures; cleanup --- diff --git a/Makefile b/Makefile index 65688706..36c211d1 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,4 @@ RELEASE=1 -TIME=0 OBJ_FILES=\ build/onyxlex.o \ @@ -27,10 +26,6 @@ else endif endif -ifeq ($(TIME), 1) - TIMEFLAG=-DREPORT_TIMES=1 -endif - INCLUDES=-I./include LIBS= TARGET=./onyx diff --git a/docs/spec b/docs/spec index 41a1dbf9..9b3d7830 100644 --- a/docs/spec +++ b/docs/spec @@ -40,7 +40,7 @@ | 6 | & | ^ << >> >>> | | 5 | <= < >= > | | 4 | == != | - | 3 | && || ^^ | + | 3 | && || | | 2 | |> .. | | 1 | = += -= *= /= %= &= |= ^= <<= >>= >>>= | +---+-------------------------------------------+ @@ -77,9 +77,6 @@ && Logical AND || Logical OR - ^^ Logical XOR All logical operators are of equal precedence. && and || are standard operators in many C-style languages. - ^^ is a boolean XOR operation and is not found in any of the languages I know about, but I don't see a reason - not to have it. There are a few places in the compiler that could utilize the ^^ operator. diff --git a/onyx b/onyx index 8502fe9b..82f9930c 100755 Binary files a/onyx and b/onyx differ diff --git a/src/onyxparser.c b/src/onyxparser.c index 4c6783b6..35857d95 100644 --- a/src/onyxparser.c +++ b/src/onyxparser.c @@ -1723,9 +1723,7 @@ static AstFunction* parse_function_definition(OnyxParser* parser) { expect_token(parser, Token_Type_Symbol); } else { - AstNode* sym_node = make_node(AstNode, Ast_Kind_Symbol); - sym_node->token = expect_token(parser, Token_Type_Symbol); - func_def->overloaded_function = sym_node; + func_def->overloaded_function = (AstNode *) parse_expression(parser); } } diff --git a/src/onyxsymres.c b/src/onyxsymres.c index 99343dcf..a17c23da 100644 --- a/src/onyxsymres.c +++ b/src/onyxsymres.c @@ -494,14 +494,21 @@ static void symres_use(AstUse* use) { if (use->expr->type_node == NULL) goto cannot_use; - if (use->expr->type_node->kind == Ast_Kind_Struct_Type || - use->expr->type_node->kind == Ast_Kind_Poly_Call_Type) { + AstType* effective_type = use->expr->type_node; + if (effective_type->kind == Ast_Kind_Pointer_Type) + effective_type = ((AstPointerType *) effective_type)->elem; + + if (effective_type->kind == Ast_Kind_Struct_Type || + effective_type->kind == Ast_Kind_Poly_Call_Type) { if (use->expr->type == NULL) use->expr->type = type_build_from_ast(semstate.node_allocator, use->expr->type_node); if (use->expr->type == NULL) goto cannot_use; Type* st = use->expr->type; + if (st->kind == Type_Kind_Pointer) + st = st->Pointer.elem; + bh_arr_each(StructMember *, smem, st->Struct.memarr) { AstFieldAccess* fa = make_field_access(use->expr, (*smem)->name); symbol_raw_introduce(semstate.curr_scope, (*smem)->name, use->token->pos, (AstNode *) fa);