From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id oH71HdX1Imc5cAEAe85BDQ:P1 (envelope-from ) for ; Thu, 31 Oct 2024 04:13:25 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id oH71HdX1Imc5cAEAe85BDQ (envelope-from ) for ; Thu, 31 Oct 2024 04:13:25 +0100 X-Envelope-To: patches@johnnyrichard.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=M26i7Jbw; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b=jLBEGwtT; spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht; arc=pass ("mailchannels.net:s=arc-2022:i=1"); dmarc=pass (policy=none) header.from=maniero.me ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1730344405; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=ZlTQ7KM/aeD8qOCxP9eNIYXkoMsKP9Fi6y+oENfpRVI=; b=RFtsYwHpYSVuptnkDn6mzkPuSWUNx37nN04trqeMw2Jysexqno/PcqUAQz4IBIophaMxpg 1Plimr0P6W+DlaTdF7ghHXdsVR+tRf2cYNQ7oYlGTu0M6ynG8qIbGv8cumHGTHM7P4OKUE iATwFGWOoUoyKDeiS6UQ4SUcgIir+Qz/YfIYwA2fJSRRC+fE7CUbHoTDS7CMzNEs487xu9 /2/xSXBsrX7x5RqrS1GsOpsgBu4SimNXEjXRuI5LU0OE/AsBCWL1hZs5V9S2JigIBe+fyJ dOUT9Cm/l+FXnfXe+Lm140lRd9+0OOeWzoZkZRWSnFPLv39VgiMaMX0UoKPxDg== ARC-Seal: i=2; s=key1; d=johnnyrichard.com; t=1730344405; a=rsa-sha256; cv=pass; b=lQgqogIHjnwnIKt0yM08MgNR2WcK+ooNR9Bm7R3AMPR5LRoe2ep5lkcu3A5eCmADAVRlVN kFguocz6lbJrMCoa5xces6khbXsgc5dSrkSvrkOUrJU3omECfdOLOE6Lf4oFlzSNgfefFN CtKc8r+qQ8R5EFXkL6hFDSt+21xnrS/7oiEY/e7WA/uRMkH3ziLJr325uGt1LIKRjK+ccv FUPo6GXy+LcpRcnFcx/FGjnAB2dJC4diu/nKP9ikay/Pr6JsGGOmUT+Ff7E8/fdk0+nWzH 1ByaxPGQsFjD/przGez8Sc07IZqqzcvfz+IUzE3FRLjtSg7etjZey/XgvJyNxQ== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=M26i7Jbw; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b=jLBEGwtT; spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht; arc=pass ("mailchannels.net:s=arc-2022:i=1"); dmarc=pass (policy=none) header.from=maniero.me Received: from mail-a.sr.ht (mail-a.sr.ht [46.23.81.152]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 27B2B7DABF for ; Thu, 31 Oct 2024 04:13:22 +0100 (CET) DKIM-Signature: a=rsa-sha256; bh=fUdYjtTiL33et6MiTCBaqyggaX+LUNh0Mb8TazNRPuo=; c=simple/simple; d=lists.sr.ht; h=From:To:Cc:Subject:In-Reply-To:References:Date:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-ID; q=dns/txt; s=20240113; t=1730344402; v=1; b=M26i7JbwyoDJjP5VZTRFgUzK1RNmI+4ItT0VrqcVtBxyAOdHuJQmUwzkCF9X2d9ZhyLGMXSC hsf6TbmrhGvkQaeQhBs6qjl0VPxCscmr/jeEj4IvXESsc8ZoP7DQsxu5R0tHo9LTj/Wvh2pX5aP x+Pl+1xNLTH376gnjeSUgK+hCNnUJY5WquvXls4SoA5rp96HmRHEzwApjDHgp80tRhIrBA0jYQp e+TDIyqp66jTRqAEMYkbsHykU0SHhWgb+Qf6Vmp23RK0pSgzyUC3fl6qu4789kF2f16/oy0LC4+ ogsS5oRyh83/MV56TSOaghsWrrzUB9htitgYV2qUYXh8A== Received: from lists.sr.ht (unknown [46.23.81.154]) by mail-a.sr.ht (Postfix) with ESMTPSA id ED8A320388 for ; Thu, 31 Oct 2024 03:13:21 +0000 (UTC) Received: from cow.ash.relay.mailchannels.net (cow.ash.relay.mailchannels.net [23.83.222.41]) by mail-a.sr.ht (Postfix) with ESMTPS id C5D1520388 for <~johnnyrichard/olang-devel@lists.sr.ht>; Thu, 31 Oct 2024 03:13:20 +0000 (UTC) X-Sender-Id: hostingeremail|x-authuser|carlos@maniero.me Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id E00E82C245B for <~johnnyrichard/olang-devel@lists.sr.ht>; Thu, 31 Oct 2024 03:13:18 +0000 (UTC) Received: from uk-fast-smtpout10.hostinger.io (100-103-158-175.trex-nlb.outbound.svc.cluster.local [100.103.158.175]) (Authenticated sender: hostingeremail) by relay.mailchannels.net (Postfix) with ESMTPA id 05DAF2C17A6 for <~johnnyrichard/olang-devel@lists.sr.ht>; Thu, 31 Oct 2024 03:13:17 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1730344398; a=rsa-sha256; cv=none; b=JsUpPToxQ8IuN8iJ8dpngvE3SHML3VSJRiXFcRFz5KbRWO3z1oUdkEQKYTbfaFQQbaQ7e0 x3GR3JwnFK73jQ4mzfJInkWVENdjs2WbEB9LPu+oLospvOB8VntbnnFhZi8LHKBBlMjbZ1 r/XtQuPFEfE9zdOwDmp4kCQuCeJuNj2k8Qf40brqb6MnIVQmE5YPrwXY0L0SLbnuqqGJG6 tpDEzuFPjg+Pi45TwRAD8ucYmK3QnYBI5xtWJ5c/nU3vXIs0jHcmlTjc869Z8A+fTO9/s7 AvMj02b7Q+5/IqBYx/zcy4gT82SwzUHrtvI9mcBaflvMyu/IGMM9VZRG0YUf7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1730344398; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ZlTQ7KM/aeD8qOCxP9eNIYXkoMsKP9Fi6y+oENfpRVI=; b=CcUOY94cAGkrOLDUf/V00Tm5NLxOA6aZTooL6SHmCj6qtAheQggT2yR0LAUWxka0zVphqa Jn4Mua78F4TUe0eDNSuOkVKEORW8fuKTfsTPPbcCn1bVGVKvrZawE1oyN2opGZla3Zq2VA SozUybLD/qRlyBubOhFH0M0QMurOSUE6+S2beaJ/q15dd1oCnFn/GSsQN/Iu0Jfn5gd4Re Zt4q0kgjXE70z9SUrL6ODC6IIw3XDsPLYeOWgVKgqCHoFgcad3vJoyFkJB/RAKDyeW5Bvw +FEQvY1b4L1t6ks4YveFi04qG0+11lEwF1CIuTW090JAaICZPpAMJ7lviw9X0g== ARC-Authentication-Results: i=1; rspamd-77cfccfb8-55hpk; auth=pass smtp.auth=hostingeremail smtp.mailfrom=carlos@maniero.me X-Sender-Id: hostingeremail|x-authuser|carlos@maniero.me X-MC-Relay: Neutral X-MailChannels-SenderId: hostingeremail|x-authuser|carlos@maniero.me X-MailChannels-Auth-Id: hostingeremail X-Irritate-Cooing: 0bb8403758ae3632_1730344398623_3660813226 X-MC-Loop-Signature: 1730344398623:1266164893 X-MC-Ingress-Time: 1730344398622 Received: from uk-fast-smtpout10.hostinger.io (uk-fast-smtpout10.hostinger.io [145.14.155.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.103.158.175 (trex/7.0.2); Thu, 31 Oct 2024 03:13:18 +0000 From: Carlos Maniero DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maniero.me; s=hostingermail1; t=1730344396; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZlTQ7KM/aeD8qOCxP9eNIYXkoMsKP9Fi6y+oENfpRVI=; b=jLBEGwtT5PrbdTjOivzZ26X9V2ZmkVdvp8dwOKcIkCTqNXXuyx3b5negVxjZE7HQ9CPzxY cZVkv7zFWyaZmZc9ucB0pTu9kT0o9Nw/GEAQJQN6GFGHBXLtwlRUzuz7+JvGUB4WH2EYn6 hFrGhWKkua5Td7816n8BSfeeL6mmpW9ZIBA+vM2nu4joLJm5K2lQzlsTZ5r4WDAD68FjHX jCUh+YQJHB0jsbwj6gRTwyMDy8Al3hYxnMc5zZCKCOEVVD0nGJQVNJ7qRJscNbY1KDFhFE 7Qj+WqGceL539V4Qz8UD/oHDiyxvBDNi8yoiarED/fgNExx7kY130WOXL8nOXA== To: ~johnnyrichard/olang-devel@lists.sr.ht Cc: Carlos Maniero Subject: [PATCH olang v2 3/6] semantics: refactor: use the ast_ident_t into the fn_call node Message-ID: <20241031031302.136553-4-carlos@maniero.me> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241031031302.136553-1-carlos@maniero.me> References: <20241031031302.136553-1-carlos@maniero.me> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Date: Thu, 31 Oct 2024 03:13:15 +0000 (UTC) X-CM-Analysis: v=2.4 cv=MYc+uI/f c=1 sm=1 tr=0 ts=6722f5cc a=WwxFCuf3mf1fs3oSi6/dng==:117 a=WwxFCuf3mf1fs3oSi6/dng==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=Hath-hCZPFYB10JWpYMA:9 a=BXDaF_L80NY05PYiAFlV:22 X-CM-Envelope: MS4xfBxMnT1+rEtS+1SyhVxgw/MWqrnrOEnKS1UEDBqHxUohnvcvd3Q9aqTaDfuRC1p1jXH3+p0/UzV52hCueNOiYViQWuh04KmTrkMzA0lA1Jyq8Wqfub2e WDjM/uugvqRES/6an4WXrqCRI6w8M7DDm0C7WzAilFpn3kCrDeU0wAMUR1qH6eH1eAhJ2w5Jzwo2HAyuinpW8WbbLlyY/0RghLZdAC1BN7mN3jf4Ws8boa+V X-AuthUser: carlos@maniero.me X-Sourcehut-Patchset-Status: UNKNOWN List-Unsubscribe: List-Subscribe: List-Archive: Archived-At: List-Post: List-ID: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel.lists.sr.ht> Sender: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel@lists.sr.ht> X-Migadu-Flow: FLOW_IN X-Migadu-Country: NL X-Migadu-Spam-Score: -4.76 X-Spam-Score: -4.76 X-Migadu-Queue-Id: 27B2B7DABF X-Migadu-Scanner: mx13.migadu.com X-TUID: 353D+gsNxOLb Signed-off-by: Carlos Maniero --- src/ast.c | 4 ++-- src/ast.h | 5 ++--- src/codegen_x86_64.c | 9 ++++----- src/pretty_print_ast.c | 5 +++-- src/type_checker.c | 3 ++- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/ast.c b/src/ast.c index e6b518e..443f0e2 100644 --- a/src/ast.c +++ b/src/ast.c @@ -71,7 +71,7 @@ ast_new_node_fn_def(arena_t *arena, ast_node_t * ast_new_node_fn_call(arena_t *arena, token_loc_t loc, - string_view_t id, + string_view_t ident_name, list_t *args) { assert(arena); @@ -85,7 +85,7 @@ ast_new_node_fn_call(arena_t *arena, node_fn_call->loc = loc; ast_fn_call_t *fn_call = &node_fn_call->as_fn_call; - fn_call->id = id; + fn_call->ident.name = ident_name; fn_call->args = args; return node_fn_call; diff --git a/src/ast.h b/src/ast.h index 9d128d7..c679d7d 100644 --- a/src/ast.h +++ b/src/ast.h @@ -101,9 +101,8 @@ typedef struct ast_fn_definition typedef struct ast_fn_call { AST_NODE_HEAD; - string_view_t id; + ast_ident_t ident; list_t *args; - scope_t *scope; } ast_fn_call_t; typedef struct ast_var_definition @@ -244,7 +243,7 @@ ast_new_node_fn_def(arena_t *arena, ast_node_t * ast_new_node_fn_call(arena_t *arena, token_loc_t loc, - string_view_t id, + string_view_t ident_name, list_t *args); ast_node_t * diff --git a/src/codegen_x86_64.c b/src/codegen_x86_64.c index 9b101f8..62511a1 100644 --- a/src/codegen_x86_64.c +++ b/src/codegen_x86_64.c @@ -157,9 +157,6 @@ codegen_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr_node) case AST_NODE_FN_CALL: { ast_fn_call_t fn_call = expr_node->as_fn_call; - symbol_t *symbol = scope_lookup(fn_call.scope, fn_call.id); - assert(symbol); - size_t i = 0; for (list_item_t *item = list_head(fn_call.args); item != NULL; item = list_next(item)) { @@ -182,9 +179,11 @@ codegen_x86_64_emit_expression(codegen_x86_64_t *codegen, ast_node_t *expr_node) get_reg_for(x86_call_args[i - 1], 8)); } - fprintf(codegen->out, " call " SV_FMT "\n", SV_ARG(fn_call.id)); + fprintf(codegen->out, + " call " SV_FMT "\n", + SV_ARG(fn_call.ident.name)); - return type_to_bytes(symbol->type); + return type_to_bytes(fn_call.ident.symbol->type); } case AST_NODE_BINARY_OP: { ast_binary_op_t bin_op = expr_node->as_bin_op; diff --git a/src/pretty_print_ast.c b/src/pretty_print_ast.c index 06b93f1..e717439 100644 --- a/src/pretty_print_ast.c +++ b/src/pretty_print_ast.c @@ -183,8 +183,9 @@ ast_node_to_pretty_print_node(ast_node_t *ast, arena_t *arena) ast_fn_call_t fn_call = ast->as_fn_call; char name[256]; - sprintf( - name, "Function_Call ", SV_ARG(fn_call.id)); + sprintf(name, + "Function_Call ", + SV_ARG(fn_call.ident.name)); node->name = (char *)arena_alloc(arena, sizeof(char) * (strlen(name) + 1)); strcpy(node->name, name); diff --git a/src/type_checker.c b/src/type_checker.c index 081034d..6b09666 100644 --- a/src/type_checker.c +++ b/src/type_checker.c @@ -179,7 +179,7 @@ populate_scope(checker_t *checker, scope_t *scope, ast_node_t *ast) } case AST_NODE_FN_CALL: { - ast->as_fn_call.scope = scope; + ast->as_fn_call.ident.scope = scope; list_item_t *item = list_head(ast->as_fn_call.args); @@ -291,6 +291,7 @@ resolve_symbols(checker_t *checker, ast_node_t *ast) } case AST_NODE_FN_CALL: { + resolve_id(checker, &ast->as_fn_call.ident); list_item_t *item = list_head(ast->as_fn_call.args); while (item != NULL) { -- 2.46.1