From f7e37ed345fac5d146ded6b1a222110018388be1 Mon Sep 17 00:00:00 2001 From: Shylock Hg Date: Thu, 30 Jan 2025 11:56:24 +0800 Subject: [PATCH] feat: add anonymous symbol. --- tigerc/src/ident_pool.rs | 2 ++ tigerc/src/ir.rs | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tigerc/src/ident_pool.rs b/tigerc/src/ident_pool.rs index cb93773..90ed4f6 100644 --- a/tigerc/src/ident_pool.rs +++ b/tigerc/src/ident_pool.rs @@ -26,6 +26,8 @@ symbols! { TOK_LET: "let", TOK_IN: "in", TOK_END: "end", + // use for inner symbol + REVERSED_ANONYMOUS: "__anonymous", } } diff --git a/tigerc/src/ir.rs b/tigerc/src/ir.rs index 70eed6b..978cd34 100644 --- a/tigerc/src/ir.rs +++ b/tigerc/src/ir.rs @@ -1,6 +1,6 @@ use std::hash::Hash; -use crate::ident_pool::Symbol; +use crate::ident_pool::{kw, Symbol}; use crate::temp::{Label, Temp}; // Identify different symbol with same name @@ -24,6 +24,10 @@ impl LowerIdent { }, } } + + pub fn new_anonymous() -> LowerIdent { + LowerIdent::new(kw::REVERSED_ANONYMOUS) + } } impl PartialEq for LowerIdent {