From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id gK9xLIFdGGeUJgAA62LTzQ:P1 (envelope-from ) for ; Wed, 23 Oct 2024 04:20:49 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id gK9xLIFdGGeUJgAA62LTzQ (envelope-from ) for ; Wed, 23 Oct 2024 04:20:49 +0200 X-Envelope-To: patches@johnnyrichard.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=XJ9o4bSL; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b=Wsrybq89; dmarc=pass (policy=none) header.from=maniero.me; arc=pass ("mailchannels.net:s=arc-2022:i=1"); spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht ARC-Seal: i=2; s=key1; d=johnnyrichard.com; t=1729650049; a=rsa-sha256; cv=pass; b=Se0EBJbmMc1k/Uyc9RaFu6n6uoPmESeTxcVsHBe8YOUMAJv/edLs/GWCZK3Bcqd1ptGoxF GZpUuY7uk4EMGatmUBQ64ovUlF7JNvFg+kTwWvfPXaO2HjmF0V3fXAYI3k3K3ufiK7hbq4 jnVk+2CA9tgpmsezOjPLxAO1tKrPkMCgs4OxfNHER6j5QSmHsfEwwXMOZ3x4APkaaPba+s Ln870pm6z4AdDXIQTfmdpyuMBEMcnyavgV1BDnrFps8B0sNZIbbve+IopFx3rgBSLvU6HQ jC6+mu2gg96zxCDKnO9I1qVI0YdFoqj0Kya70msXO00mNatnWCghxzFg5xkgNA== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=XJ9o4bSL; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b=Wsrybq89; dmarc=pass (policy=none) header.from=maniero.me; arc=pass ("mailchannels.net:s=arc-2022:i=1"); spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1729650049; 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=nhSY0sHHVZ7cERIbejuJn9gfsxp0mDpwX+XDu45hfq0=; b=UycNulRPFhEl/5NXMCLFuXth5N4icZUkzytZCrNn1WRFoOsvc4o6mcbwWOQqYbi39gflDw e41sKisLpYF0E8t3cWGdBsc4CQcB+e7nAzWc+n07Ox4lJwSQIzNvCX7aU7l617Jvs4dOA3 k4UhUzECwBnb8Buhd/WGO3HCzmF54ZZvHpmf0vuaa1vt8jbO4rxcyaVN4oP6rXKbn103aE TobSvzDfDYhPOT07JsujEZyEOnn0qHQq1MUSOqo+6NxzLFlLpaHx8VJ+VZrBLHvm3MLHqU g8V369LoCCtGgh3VEFDVNYHYhTUzy5cwbgKMOKPE0SDbZvCXzOz/NRvitGrjfA== 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 98F5574526 for ; Wed, 23 Oct 2024 04:20:49 +0200 (CEST) DKIM-Signature: a=rsa-sha256; bh=xL9iic3sAQzrk7VpYlQnp3xTqRma38k2GorJ8U7xvrU=; 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=1729650048; v=1; b=XJ9o4bSL9MZeJuA8p9wHpT64Cs8E9pD/lVHDELyscYBLXUN6vpvhGGz0hygvDBnwp6moaOts 5N/5N48SLBUtBewyFxj2vDOWDCc1jtF7gvGucuxsFqisyuJYoTqAk0Gi2dbDHiTwYjLtkSj5NTQ h2XjyQDTVEI+AutDt1JuGgJEIaCd2y8zfu+fRTqvAEPpmL/NlLpF/hS+8YjDSZIT9iT7affkbwn VDuj5UeGLweYNJx2ljSDPrvN0srzly3LeA5cEp4YPjnUBNVomlG1OYeeGoDaGXafckdU+Tx8YCM hABGwZ8oZdvXY7vAJx01hjjBwdo55wzd0VDrL6/lZqXoA== Received: from lists.sr.ht (unknown [46.23.81.154]) by mail-a.sr.ht (Postfix) with ESMTPSA id A92A5202DE for ; Wed, 23 Oct 2024 02:20:48 +0000 (UTC) Received: from frog.ash.relay.mailchannels.net (frog.ash.relay.mailchannels.net [23.83.222.63]) by mail-a.sr.ht (Postfix) with ESMTPS id 87E82202B1 for <~johnnyrichard/olang-devel@lists.sr.ht>; Wed, 23 Oct 2024 02:20:47 +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 E3C8742E02 for <~johnnyrichard/olang-devel@lists.sr.ht>; Wed, 23 Oct 2024 02:20:45 +0000 (UTC) Received: from nl-srv-smtpout1.hostinger.io (trex-4.trex.outbound.svc.cluster.local [100.103.228.149]) (Authenticated sender: hostingeremail) by relay.mailchannels.net (Postfix) with ESMTPA id 5F81644027 for <~johnnyrichard/olang-devel@lists.sr.ht>; Wed, 23 Oct 2024 02:20:45 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1729650045; a=rsa-sha256; cv=none; b=A7b9FmttmtjtCKIclJo+ej/PtnG6Ji0DgSs3ySYTIwZyu3cvGGAgcUrbi3LpV9fOt7+Lz6 GoisncvG/QgokM736t6QUFiWqyekI50hDODZ6/ovcdJKqTuS3v2HznK4W8ui6M9F0jcFPn STYkujag0wfQH7SOff5x46cJ/BryhQ6Zn2j3hcU/9jR90bLvAXcl5W/k/N+cUG1vp8DQD0 sk0rZZ9S3qppg5/v0gpANeSnd6ze69KamKoiYXqF0XIt8B/pK/CzqK0GkeeizEeCY+kqfL abO610LgXM6JdSFuk6kOJmiPkSId7icHzQFJiJ9oKcbjnZ/pZZjVS0nfQOuC/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1729650045; 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=nhSY0sHHVZ7cERIbejuJn9gfsxp0mDpwX+XDu45hfq0=; b=x5jI0xZiI4n5eopxU2XLX+/b0ffYqo8OB3b7Be6gGF8OaRvVu6Ze7sLSuhzj6mAjyzpZp2 3xoF50O8LASRfHR+Q3MyuPlH8/xbWd9K89pf0M0TT5PzKIpw2NHLiAgDMMVkXq15r1OCc9 SHSNgcJmlCVDQHJ/BtdcgRO3OVLhb0w+n9EwjBNA+m6blnDLu3yRNcSr5mkwIyfoDQn4FX aw8K7r595DysVqMucy6/He3nOfQHjivejQo5rvJKMdRjk/gghwmyesyqLhPeseNyYL3ByR 8MuzpHsqgee4Y1fG5WABjIMYaABSLixgiY9+HlhdluUZ/GIgdtateB6130GtKg== ARC-Authentication-Results: i=1; rspamd-5bbb596db8-j9c44; 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-Abaft-Cooing: 443eb3904d3b6ab2_1729650045846_1966997040 X-MC-Loop-Signature: 1729650045846:2491573227 X-MC-Ingress-Time: 1729650045846 Received: from nl-srv-smtpout1.hostinger.io (nl-srv-smtpout1.hostinger.io [145.14.150.87]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.103.228.149 (trex/7.0.2); Wed, 23 Oct 2024 02:20:45 +0000 From: Carlos Maniero DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maniero.me; s=hostingermail1; t=1729650043; 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=nhSY0sHHVZ7cERIbejuJn9gfsxp0mDpwX+XDu45hfq0=; b=Wsrybq89N92HXqi5cwtA98B29II1GdL0St37/GHQnbiavLKw8a4dhM5StsGgtp6DuFrrG6 xdB2hzvusZqcOlESk6FzSt/Mpn/woi2pIDzN1kIJf7X98z3y3yMw50qIwjP0BZboPunVqT UlSJ7tcCARXMGAzoIZLmOrymIeKicS9g1NIcLlCZhhMnW/UAPd+mqe8dxZp2q0mRbbCgKE 2RrYpB2Oe+2O1V/AjICc1VY/7bJEoUqayDh6YGSwW4I7zaYN40sSiBIGSo6j5LaQk+MkMY 6RYqxInc1VU4Q/YmJ/CRiQrOeg4GUr24Za7LVqNp0/7FsDk9pG2Dhs5kZvP95Q== To: ~johnnyrichard/olang-devel@lists.sr.ht Cc: Carlos Maniero Subject: [PATCH olang v1 4/5] ast: remove expr reference from return and var assign nodes Message-ID: <20241023022022.38379-5-carlos@maniero.me> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241023022022.38379-1-carlos@maniero.me> References: <20241023022022.38379-1-carlos@maniero.me> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Date: Wed, 23 Oct 2024 02:20:43 +0000 (UTC) X-CM-Analysis: v=2.4 cv=VemlP0p9 c=1 sm=1 tr=0 ts=67185d7b a=WwxFCuf3mf1fs3oSi6/dng==:117 a=WwxFCuf3mf1fs3oSi6/dng==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=7gtipPPwewwSLnUmRe0A:9 a=BXDaF_L80NY05PYiAFlV:22 X-CM-Envelope: MS4xfK9sLL7smtARSK3+tmAG++bZl2BCAl0/zSZvfWHd6u7Bo74wWWJWwmHRviWfrTDnS+6tbbkSo1pGSq/j3ZiFZ1wupxhlWaQmWxfDWj+8I9xSgAwQL9Kg xfUVvNp5Vu8fGqffGMMIAAub0hle2DutLJ8qu1eoSYVrnVQJVNxHtqlmxyrMNRrLxNqW7mZryX17YAWlwBNRddNWqol9wzBn0D9HYFonTR5Ph1fnGtEAFkzq 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-Country: NL X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -5.59 X-Spam-Score: -5.59 X-Migadu-Queue-Id: 98F5574526 X-Migadu-Scanner: mx10.migadu.com X-TUID: UtmUmLT4Kad2 We will introduce an new ast_node called expr that will be the base struct for nodes of kind expression. To avoid misunderstandings this two nodes that used to have a expr field, now have a field named value. Signed-off-by: Carlos Maniero --- src/ast.c | 4 ++-- src/ast.h | 4 ++-- src/codegen_aarch64.c | 2 +- src/codegen_x86_64.c | 4 ++-- src/pretty_print_ast.c | 2 +- src/type_checker.c | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ast.c b/src/ast.c index eef01ce..b96a463 100644 --- a/src/ast.c +++ b/src/ast.c @@ -180,7 +180,7 @@ ast_new_node_ref(arena_t *arena, token_loc_t loc, string_view_t id) } ast_node_t * -ast_new_node_return_stmt(arena_t *arena, token_loc_t loc, ast_node_t *expr) +ast_new_node_return_stmt(arena_t *arena, token_loc_t loc, ast_node_t *value) { ast_node_t *node_return_stmt = (ast_node_t *)arena_alloc(arena, sizeof(ast_node_t)); @@ -188,7 +188,7 @@ ast_new_node_return_stmt(arena_t *arena, token_loc_t loc, ast_node_t *expr) node_return_stmt->kind = AST_NODE_RETURN_STMT; node_return_stmt->loc = loc; - node_return_stmt->as_return_stmt.expr = expr; + node_return_stmt->as_return_stmt.value = value; return node_return_stmt; } diff --git a/src/ast.h b/src/ast.h index 9d82317..7c5e9af 100644 --- a/src/ast.h +++ b/src/ast.h @@ -182,13 +182,13 @@ typedef struct ast_var_assign_stmt { AST_NODE_HEAD; ast_node_t *ref; - ast_node_t *expr; + ast_node_t *value; } ast_var_assign_stmt_t; typedef struct ast_return_stmt { AST_NODE_HEAD; - ast_node_t *expr; + ast_node_t *value; } ast_return_stmt_t; typedef struct ast_if_stmt diff --git a/src/codegen_aarch64.c b/src/codegen_aarch64.c index 1de238d..bc511f0 100644 --- a/src/codegen_aarch64.c +++ b/src/codegen_aarch64.c @@ -97,7 +97,7 @@ codegen_aarch64_emit_function(FILE *out, ast_fn_definition_t *fn) assert(return_node->kind == AST_NODE_RETURN_STMT); ast_return_stmt_t return_stmt = return_node->as_return_stmt; - ast_node_t *literal_node = return_stmt.expr; + ast_node_t *literal_node = return_stmt.value; assert(literal_node->kind == AST_NODE_LITERAL); ast_literal_t literal_u32 = literal_node->as_literal; diff --git a/src/codegen_x86_64.c b/src/codegen_x86_64.c index 933a42d..9006250 100644 --- a/src/codegen_x86_64.c +++ b/src/codegen_x86_64.c @@ -709,9 +709,9 @@ codegen_x86_64_emit_block(codegen_x86_64_t *codegen, ast_block_t *block) case AST_NODE_RETURN_STMT: { ast_return_stmt_t return_stmt = node->as_return_stmt; - ast_node_t *expr = return_stmt.expr; + ast_node_t *value = return_stmt.value; - codegen_x86_64_emit_expression(codegen, expr); + codegen_x86_64_emit_expression(codegen, value); fprintf(codegen->out, " mov %%rbp, %%rsp\n"); fprintf(codegen->out, " pop %%rbp\n"); diff --git a/src/pretty_print_ast.c b/src/pretty_print_ast.c index d18fa56..bc5d119 100644 --- a/src/pretty_print_ast.c +++ b/src/pretty_print_ast.c @@ -221,7 +221,7 @@ ast_node_to_pretty_print_node(ast_node_t *ast, arena_t *arena) node->name = "Return_Statement"; pretty_print_node_t *child = - ast_node_to_pretty_print_node(return_stmt.expr, arena); + ast_node_to_pretty_print_node(return_stmt.value, arena); list_append(node->children, child); return node; diff --git a/src/type_checker.c b/src/type_checker.c index 53c2e05..235d711 100644 --- a/src/type_checker.c +++ b/src/type_checker.c @@ -196,7 +196,7 @@ populate_scope(checker_t *checker, scope_t *scope, ast_node_t *ast) case AST_NODE_RETURN_STMT: { ast_return_stmt_t return_stmt = ast->as_return_stmt; - populate_scope(checker, scope, return_stmt.expr); + populate_scope(checker, scope, return_stmt.value); return; } -- 2.46.1