difftreelog
fix(evaluator) indirect_self bug
in: master
4 files changed
Cargo.lockdiffbeforeafterboth1# This file is automatically @generated by Cargo.1# This file is automatically @generated by Cargo.2# It is not intended for manual editing.2# It is not intended for manual editing.3[[package]]4name = "closure"5version = "0.3.0"6source = "registry+https://github.com/rust-lang/crates.io-index"7checksum = "d6173fd61b610d15a7566dd7b7620775627441c4ab9dac8906e17cb93a24b782"83[[package]]9[[package]]4name = "jsonnet-evaluator"10name = "jsonnet-evaluator"5version = "0.1.0"11version = "0.1.0"6dependencies = [12dependencies = [13 "closure",7 "jsonnet-parser",14 "jsonnet-parser",8 "jsonnet-stdlib",15 "jsonnet-stdlib",9]16]crates/jsonnet-evaluator/src/ctx.rsdiffbeforeafterboth74 new_this: Option<ObjValue>,74 new_this: Option<ObjValue>,75 new_super_obj: Option<ObjValue>,75 new_super_obj: Option<ObjValue>,76 ) -> Context {76 ) -> Context {77 println!("Extend with {:?} {:?}", new_dollar, new_this);78 let dollar = new_dollar.or_else(|| self.0.dollar.clone());77 let dollar = new_dollar.or_else(|| self.0.dollar.clone());79 let this = new_this.or_else(|| self.0.this.clone());78 let this = new_this.or_else(|| self.0.this.clone());80 let super_obj = new_super_obj.or_else(|| self.0.super_obj.clone());79 let super_obj = new_super_obj.or_else(|| self.0.super_obj.clone());crates/jsonnet-evaluator/src/evaluate.rsdiffbeforeafterboth30 (30 (31 b.name.clone(),31 b.name.clone(),32 binding!(move |this, super_obj| {32 binding!(move |this, super_obj| {33 println!("Evaluating binding");34 Val::Lazy(lazy_val!(33 Val::Lazy(lazy_val!(35 closure!(clone context_creator, clone b, || evaluate(34 closure!(clone context_creator, clone b, || evaluate(36 context_creator.0(this.clone(), super_obj.clone()),35 context_creator.0(this.clone(), super_obj.clone()),137 let future_bindings = FutureNewBindings::new();136 let future_bindings = FutureNewBindings::new();138 let future_this = FutureObjValue::new();137 let future_this = FutureObjValue::new();139 let context_creator = context_creator!(138 let context_creator = context_creator!(140 closure!(clone context, clone future_bindings, |this: Option<ObjValue>, super_obj: Option<ObjValue>| {139 closure!(clone context, clone future_bindings, clone future_this, |this: Option<ObjValue>, super_obj: Option<ObjValue>| {141 println!("Context created");142 context.clone().extend(140 context.clone().extend(143 future_bindings.clone().unwrap(),141 future_bindings.clone().unwrap(),144 context.clone().dollar().clone().or_else(||this.clone()),142 context.clone().dollar().clone().or_else(||this.clone()),145 this,143 Some(future_this.clone().unwrap()),146 super_obj144 super_obj147 )145 )148 })146 })154 Member::BindStmt(b) => Some(b.clone()),152 Member::BindStmt(b) => Some(b.clone()),155 _ => None,153 _ => None,156 })154 })157 .map(|b| {155 .map(|b| evaluate_binding(&b, context_creator.clone()))158 evaluate_binding(&b, context_creator.clone())159 })160 {156 {161 bindings.insert(n, b);157 bindings.insert(n, b);162 }158 }163 future_bindings.fill(bindings);159 future_bindings.fill(bindings);164160165 println!("Bindings filled");166 let mut new_members = BTreeMap::new();161 let mut new_members = BTreeMap::new();167 for member in members.into_iter() {162 for member in members.into_iter() {168 match member {163 match member {180 add: plus,175 add: plus,181 visibility: visibility.clone(),176 visibility: visibility.clone(),182 invoke: binding!(177 invoke: binding!(183 closure!(clone value, clone context_creator, clone future_this, |this, super_obj| {178 closure!(clone value, clone context_creator, |this, super_obj| {184 // FIXME: I should take "this" instead of "future_this" there?185 // TODO: Assert179 // TODO: Assert186 evaluate(180 evaluate(187 context_creator.0(this, super_obj),181 context_creator.0(this, super_obj),205 add: false,199 add: false,206 visibility: Visibility::Hidden,200 visibility: Visibility::Hidden,207 invoke: binding!(201 invoke: binding!(208 closure!(clone value, clone context_creator, clone future_this, |this, super_obj| {202 closure!(clone value, clone context_creator, |this, super_obj| {209 // FIXME: I should take "this" instead of "future_this" there?210 // TODO: Assert203 // TODO: Assert211 evaluate_method(204 evaluate_method(212 context_creator.0(this, super_obj),205 context_creator.0(this, super_obj),231pub fn evaluate(context: Context, expr: &Expr) -> Val {224pub fn evaluate(context: Context, expr: &Expr) -> Val {232 use Expr::*;225 use Expr::*;233 match &*expr {226 match &*expr {234 Literal(LiteralType::This) => {227 Literal(LiteralType::This) => Val::Obj(235 println!("{:?}", context.this());236 Val::Obj(237 context228 context238 .this()229 .this()239 .clone()230 .clone()240 .unwrap_or_else(|| panic!("this not found")),231 .unwrap_or_else(|| panic!("this not found")),241 )232 ),242 }243 Literal(LiteralType::Super) => Val::Obj(233 Literal(LiteralType::Super) => Val::Obj(244 context234 context245 .super_obj()235 .super_obj()crates/jsonnet-evaluator/src/lib.rsdiffbeforeafterboth192 // `self` assigned to `me` was lost when being192 // `self` assigned to `me` was lost when being193 // referenced from field193 // referenced from field194 eval_stdlib!(194 eval_stdlib!(195 r#"{195 r#"{196 local me = std.trace("test", self),196 local me = self,197 b: me,197 b: me,198 }.b"#198 }.b"#199 );199 );200 }200 }201201