Updates for TR comments

master
Andrew Johnson 6 years ago
parent 6ab22d027f
commit e43403a68e

@ -1,5 +1,5 @@
type JSJIT = u64; struct JSJIT(u64);
enum JSJITorExpr { enum JSJITorExpr {
Jit { label: JSJIT }, Jit { label: JSJIT },
@ -18,7 +18,7 @@ fn jump(l: JSJIT) -> JSJITorExpr
//jump to compiled code //jump to compiled code
//this depends on implementation //this depends on implementation
//so we will just leave this as a stub //so we will just leave this as a stub
JSJITorExpr::Jit { label: 0 } JSJITorExpr::Jit { label: JSJIT(0) }
} }
fn eval(e: JSJITorExpr) -> JSJITorExpr fn eval(e: JSJITorExpr) -> JSJITorExpr
{ {
@ -36,14 +36,14 @@ fn eval(e: JSJITorExpr) -> JSJITorExpr
let r = eval(*r); let r = eval(*r);
//call add op codes for possible l,r representations //call add op codes for possible l,r representations
//should return wrapped value from above //should return wrapped value from above
JSJITorExpr::Jit { label: 0 } JSJITorExpr::Jit { label: JSJIT(0) }
} }
JSExpr::OperatorMul { lexpr: l, rexpr: r } => { JSExpr::OperatorMul { lexpr: l, rexpr: r } => {
let l = eval(*l); let l = eval(*l);
let r = eval(*r); let r = eval(*r);
//call mul op codes for possible l,r representations //call mul op codes for possible l,r representations
//should return wrapped value from above //should return wrapped value from above
JSJITorExpr::Jit { label: 0 } JSJITorExpr::Jit { label: JSJIT(0) }
} }
} }
} }

@ -15,10 +15,38 @@ impl<'a> Red for Ball<'a> { }
static num: i32 = 5; static num: i32 = 5;
struct Context<'s>(&'s mut String);
impl<'s> Context<'s>
{
fn mutate<'c>(&mut self, cs: &'c mut String) -> &'c mut String
{
let swap_a = self.0.pop().unwrap();
let swap_b = cs.pop().unwrap();
self.0.push(swap_b);
cs.push(swap_a);
cs
}
}
fn main() fn main()
{ {
let x = 3; let x = 3;
ground_lifetime(&x); ground_lifetime(&x);
let obj = Box::new(Ball { diameter: &num }) as Box<Red + 'static>; let obj = Box::new(Ball { diameter: &num }) as Box<Red + 'static>;
let mut s = "outside string context abc".to_string();
{
//temporary context
let mut c = Context(&mut s);
{
//further temporary context
let mut s2 = "inside string context def".to_string();
c.mutate(&mut s2);
println!("s2 {}", s2);
}
}
println!("s {}", s);
} }

@ -56,4 +56,7 @@ fn main()
<Baz as Foo>::f(&b); <Baz as Foo>::f(&b);
<Baz as Bar>::f(&b); <Baz as Bar>::f(&b);
f::<Foo>(&b);
f::<Bar>(&b);
} }

Loading…
Cancel
Save