From: Scott Olson Date: Tue, 10 May 2016 02:03:13 +0000 (-0600) Subject: Handle statics. X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=ddfbb655e1b4793022265088c0548611758efba7;p=rust.git Handle statics. --- diff --git a/src/interpreter.rs b/src/interpreter.rs index d86dbdbe687..8fc302637f8 100644 --- a/src/interpreter.rs +++ b/src/interpreter.rs @@ -846,6 +846,8 @@ fn eval_operand(&mut self, op: &mir::Operand<'tcx>) -> EvalResult { Value { ref value } => Ok(self.const_to_ptr(value)?), Item { .. } => unimplemented!(), Promoted { index } => { + // TODO(tsion): Mark constants and statics as read-only and cache their + // values. let current_mir = self.mir(); let mir = ¤t_mir.promoted[index]; self.call_nested(mir).map(Option::unwrap) @@ -864,7 +866,11 @@ fn eval_lvalue(&mut self, lvalue: &mir::Lvalue<'tcx>) -> EvalResult { Var(i) => self.frame().locals[self.frame().var_offset + i as usize], Temp(i) => self.frame().locals[self.frame().temp_offset + i as usize], - Static(_def_id) => unimplemented!(), + Static(def_id) => { + // TODO(tsion): Mark constants and statics as read-only and cache their values. + let mir = self.load_mir(def_id); + self.call_nested(&mir)?.unwrap() + } Projection(ref proj) => { let base = self.eval_lvalue(&proj.base)?;