slight code cleanup
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Wed, 22 Jul 2020 13:46:23 +0000 (08:46 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Wed, 22 Jul 2020 13:46:23 +0000 (08:46 -0500)
onyx
progs/structs.onyx
src/onyxsymres.c

diff --git a/onyx b/onyx
index 982db0e14864bb625e5b685461b7541bed3589c3..7bd00ea4e5893c19f319dfc64d97557baf6acdf8 100755 (executable)
Binary files a/onyx and b/onyx differ
index a0608d710ce1e3dabc455255c44d75a787f1f537..4ec4729f94455935582ca9a9d6f672a41cd2c747 100644 (file)
@@ -121,10 +121,6 @@ minus :: proc (n: i32, k: i32) -> i32 {
     return n - k;
 }
 
-foo :: proc (f: (i32, i32) -> i32) -> i32 {
-    return f(5, 6);
-}
-
 proc #export "main" {
     v2 := alloc(sizeof Vec2) as ^Vec2;
     v2.x = 5;
index d056573d85b4285eae06c16e9301eb399da5c8d9..c269c6abcbc5074763335306c567679a2d01efda 100644 (file)
@@ -47,7 +47,7 @@ static void scope_leave();
 
 static AstType* symres_type(AstType* type);
 static void symres_local(AstLocal** local);
-static void symres_call(AstCall** pcall);
+static void symres_call(AstCall* call);
 static void symres_size_of(AstSizeOf* so);
 static void symres_expression(AstTyped** expr);
 static void symres_return(AstReturn* ret);
@@ -186,9 +186,7 @@ static void symres_local(AstLocal** local) {
     symbol_introduce((*local)->token, (AstNode *) *local);
 }
 
-static void symres_call(AstCall** pcall) {
-    AstCall* call = *pcall;
-
+static void symres_call(AstCall* call) {
     if (call->callee->kind == Ast_Kind_Field_Access) {
         AstFieldAccess* fa = (AstFieldAccess *) call->callee;
 
@@ -200,11 +198,9 @@ static void symres_call(AstCall** pcall) {
         implicit_arg->token = fa->expr->token;
         implicit_arg->next = (AstNode *) call->arguments;
 
-        (*pcall)->callee = (AstNode *) symbol;
-        (*pcall)->arguments = implicit_arg;
-        (*pcall)->arg_count++;
-
-        call = *pcall;
+        call->callee = (AstNode *) symbol;
+        call->arguments = implicit_arg;
+        call->arg_count++;
     }
 
     AstNode* callee = symbol_resolve(call->callee->token);
@@ -243,7 +239,7 @@ static void symres_expression(AstTyped** expr) {
             break;
 
         case Ast_Kind_Unary_Op: symres_unaryop((AstUnaryOp **) expr); break;
-        case Ast_Kind_Call: symres_call((AstCall **) expr); break;
+        case Ast_Kind_Call: symres_call((AstCall *) *expr); break;
         case Ast_Kind_Block: symres_block((AstBlock *) *expr); break;
 
         case Ast_Kind_Symbol:
@@ -321,7 +317,7 @@ static b32 symres_statement(AstNode* stmt) {
         case Ast_Kind_If:         symres_if((AstIf *) stmt);                        return 0;
         case Ast_Kind_While:      symres_while((AstWhile *) stmt);                  return 0;
         case Ast_Kind_For:        symres_for((AstFor *) stmt);                      return 0;
-        case Ast_Kind_Call:       symres_call((AstCall **) &stmt);                  return 0;
+        case Ast_Kind_Call:       symres_call((AstCall *) stmt);                    return 0;
         case Ast_Kind_Argument:   symres_expression((AstTyped **) &((AstArgument *)stmt)->value); return 0;
         case Ast_Kind_Block:      symres_block((AstBlock *) stmt);                  return 0;