mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 18:58:30 +00:00
Rename dir: compiler
-> crates
This commit is contained in:
parent
e1004b538d
commit
a127564b31
221 changed files with 17 additions and 19 deletions
21
crates/erg_common/fresh.rs
Normal file
21
crates/erg_common/fresh.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
use crate::shared::Shared;
|
||||
|
||||
thread_local! {
|
||||
static VAR_ID: Shared<usize> = Shared::new(0);
|
||||
}
|
||||
|
||||
pub fn fresh_varname() -> String {
|
||||
VAR_ID.with(|id| {
|
||||
*id.borrow_mut() += 1;
|
||||
let i = *id.borrow();
|
||||
format!("%v{i}")
|
||||
})
|
||||
}
|
||||
|
||||
pub fn fresh_param_name() -> String {
|
||||
VAR_ID.with(|id| {
|
||||
*id.borrow_mut() += 1;
|
||||
let i = *id.borrow();
|
||||
format!("%p{i}")
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue