Skip to content

Commit 542d607

Browse files
committed
feat: add temp.
1 parent 747051f commit 542d607

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

tigerc/src/frame.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ pub struct Variable {
2020

2121
pub trait Frame {
2222
fn new(name: Symbol, parameters: IndexMap<ir::LowerIdent, Variable>) -> Self;
23-
fn name(&self) -> Symbol;
23+
fn name(&self) -> &ir::LowerIdent;
2424
fn allocate_local(&mut self, symbol: ir::LowerIdent, var: Variable);
2525
}
2626

2727
// frame of a function
2828
struct FrameAmd64 {
2929
// function name
30-
name: Symbol,
30+
name: ir::LowerIdent,
3131
// parameters
3232
parameters: IndexMap<ir::LowerIdent, Variable>,
3333
// local variables
@@ -37,14 +37,14 @@ struct FrameAmd64 {
3737
impl Frame for FrameAmd64 {
3838
fn new(name: Symbol, parameters: IndexMap<ir::LowerIdent, Variable>) -> Self {
3939
FrameAmd64 {
40-
name,
40+
name: ir::LowerIdent::new(name),
4141
parameters,
4242
locals: IndexMap::new(),
4343
}
4444
}
4545

46-
fn name(&self) -> Symbol {
47-
self.name
46+
fn name(&self) -> &ir::LowerIdent {
47+
&self.name
4848
}
4949

5050
fn allocate_local(&mut self, symbol: ir::LowerIdent, var: Variable) {

tigerc/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub mod ident_pool;
66
pub mod ir;
77
pub mod parser;
88
pub mod symbol_table;
9+
pub mod temp;
910
pub mod tokenizer;
1011
pub mod type_ast;
1112
pub mod type_inference;

tigerc/src/temp.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use crate::ir::LowerIdent;
2+
3+
// for variable
4+
#[derive(Debug, PartialEq, Eq)]
5+
pub struct Temp(pub LowerIdent);
6+
7+
// for function
8+
#[derive(Debug, PartialEq, Eq)]
9+
pub struct Label(pub LowerIdent);

0 commit comments

Comments
 (0)