can 'use' pointers to structures; cleanup
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 14 Dec 2020 21:47:52 +0000 (15:47 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 14 Dec 2020 21:47:52 +0000 (15:47 -0600)
Makefile
docs/spec
onyx
src/onyxparser.c
src/onyxsymres.c

index 6568870626909d57d81b350e048a5fd8388aaab0..36c211d14ab0781cc03247705dea713419964297 100644 (file)
--- 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
index 41a1dbf97e2d2717ca00b6745502da2b3dcb888e..9b3d7830eae7cd16c37fdd18eacfeef60f9def73 100644 (file)
--- 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 8502fe9b80a6dee4c47a2b9e47c7347b08a08252..82f9930ce153e6dd4e3b3d7b100d5e26cd5db2cf 100755 (executable)
Binary files a/onyx and b/onyx differ
index 4c6783b634a6b77063a4151a5f932674e7ea6957..35857d95af2c127937c2e76180e1c6abd7533d61 100644 (file)
@@ -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);
             }
         }
 
index 99343dcf4fbdafa51aacaeac89b0d52cd9f9d7b9..a17c23da28dbbb21010945040a8420a4abcfd40d 100644 (file)
@@ -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);