From 320141f01b823fc5a6cffc0fbbb2d8085a2eae9e Mon Sep 17 00:00:00 2001
From: Per Lindgren <per.lindgren@ltu.se>
Date: Wed, 21 Oct 2020 15:51:49 +0200
Subject: [PATCH] initial commit wip1

---
 examples/stacked_borrows.rs | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/examples/stacked_borrows.rs b/examples/stacked_borrows.rs
index 176bed5..e87e08e 100644
--- a/examples/stacked_borrows.rs
+++ b/examples/stacked_borrows.rs
@@ -33,19 +33,24 @@ impl Store {
     }
     fn alloc(&mut self, id: Id) {
         self.stack.push_front(Item::Unique(self.tag));
+        self.env.insert(id, self.tag);
         self.tag += 1;
+        println!("alloc {:?}", self)
     }
 }
 
 #[derive(Debug)]
 enum Expr {
     Id(Id),
-    Num(i32),
+    Lit,
     Ref(Box<Expr>),
     RefMut(Box<Expr>),
     Deref(Box<Expr>),
 }
 
+fn id(id: &str) -> String {
+    id.to_string()
+}
 #[derive(Debug)]
 enum Stmt {
     Let(Id, Expr), // assumed mutable, e.g. let mut a = 0;
@@ -76,7 +81,15 @@ fn check_stmts(v: &Vec<Stmt>, store: &mut Store) {
 fn main() {
     let mut env = Env::new();
     use {Expr::*, Stmt::*};
-    let v = vec![Let("a".to_owned(), Num(0))];
-    
+
+    let v = vec![
+        Let(id("a"), Lit),                        // let a = ...;
+        Let(id("b"), Lit),                        // let b = ...;
+        Let(id("c"), Ref(Box::new(Id(id("a"))))), // let c = &a;
+        Assign(Id(id("a")), Lit),                 // a = ...;
+    ];
+
+    println!("prog {:?}", v);
+
     check_stmts(&v, &mut Store::new());
 }
-- 
GitLab