]> git.lizzy.rs Git - rust.git/commitdiff
the `type_size` method's `substs` argument allows computing the locals before pushing...
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Thu, 9 Jun 2016 15:23:58 +0000 (17:23 +0200)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Thu, 9 Jun 2016 15:23:58 +0000 (17:23 +0200)
src/interpreter/mod.rs

index e70fe5e93f334f332e0f2db91292d6ea3840e12e..a7a57a79601707928213c4e3fbb84b75cff90bd5 100644 (file)
@@ -353,11 +353,16 @@ fn push_stack_frame(&mut self, def_id: DefId, span: codemap::Span, mir: CachedMi
 
         ::log_settings::settings().indentation += 1;
 
+        let locals: Vec<Pointer> = arg_tys.chain(var_tys).chain(temp_tys).map(|ty| {
+            let size = self.type_size(ty, substs);
+            self.memory.allocate(size)
+        }).collect();
+
         self.stack.push(Frame {
             mir: mir.clone(),
             next_block: mir::START_BLOCK,
             return_ptr: return_ptr,
-            locals: Vec::new(),
+            locals: locals,
             var_offset: num_args,
             temp_offset: num_args + num_vars,
             span: span,
@@ -365,13 +370,6 @@ fn push_stack_frame(&mut self, def_id: DefId, span: codemap::Span, mir: CachedMi
             substs: substs,
             stmt: 0,
         });
-
-        let locals: Vec<Pointer> = arg_tys.chain(var_tys).chain(temp_tys).map(|ty| {
-            let size = self.type_size(ty, self.substs());
-            self.memory.allocate(size)
-        }).collect();
-
-        self.frame_mut().locals = locals;
     }
 
     fn pop_stack_frame(&mut self) {