You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: stackless_bytecode_generator.rs
    path of file: ./repos/diem/language/move-prover/bytecode/src
    
    the code of the file until where you have to start completion: // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0

use crate::{
    function_target::FunctionData,
    stackless_bytecode::{
        AssignKind, AttrId,
        Bytecode::{self},
        Constant, Label, Operation, PropKind,
    },
};
use itertools::Itertools;
use move_binary_format::{
    access::ModuleAccess,
    file_format::{
        Bytecode as MoveBytecode, CodeOffset, CompiledModule, FieldHandleIndex, SignatureIndex,
    },
    views::{FunctionHandleView, ViewInternals},
};
use move_core_types::value::MoveValue;
use move_model::{
    ast::{ConditionKind, TempIndex},
    model::{FunctionEnv, Loc, StructId},
    ty::{PrimitiveType, Type},
};
use std::{
    collections::{BTreeMap, BTreeSet},
    matches,
};

pub struct StacklessBytecodeGenerator<'a> {
    func_env: &'a FunctionEnv<'a>,
    module: &'a CompiledModule,
    temp_count: usize,
    temp_stack: Vec<usize>,
    local_types: Vec<Type>,
    code: Vec<Bytecode>,
    location_table: BTreeMap<AttrId, Loc>,
    loop_invariants: BTreeSet<AttrId>,
}

impl<'a> StacklessBytecodeGenerator<'a> {
    pub fn new(func_env: &'a FunctionEnv<'a>) -> Self {
        let local_types = (0..func_env.get_local_count())
            .map(|i| func_env.get_local_type(i))
            .collect_vec();
        StacklessBytecodeGenerator {
            func_env,
            module: func_env.module_env.get_verified_module(),
            temp_count: local_types.len(),
            temp_stack: vec![],
            local_types,
            code: vec![],
            location_table: BTreeMap::new(),
            loop_invariants: BTreeSet::new(),
        }
    }

    pub fn generate_function(mut self) -> FunctionData {
        let original_code = self.func_env.get_bytecode();
        let mut label_map = BTreeMap::new();

        // Generate labels.
        for (pos, bytecode) in original_code.iter().enumerate() {
            if let MoveBytecode::BrTrue(code_offset)
            | MoveBytecode::BrFalse(code_offset)
            | MoveBytecode::Branch(code_offset) = bytecode
            {
                let offs = *code_offset as CodeOffs
    
    pub fn generate_function(mut self) -> FunctionData {
        let original_code = self.func_env.get_bytecode();
        let mut label_map = BTreeMap::new();

        // Generate labels.
        for (pos, bytecode) in original_code.iter().enumerate() {
            if let MoveBytecode::BrTrue(code_offset)
            | MoveBytecode::BrFalse(code_offset)
            | MoveBytecode::Branch(code_offset) = bytecode
            {
                let offs = *code_offset as CodeOffset;
                if label_map.get(&offs).is_none() {
                    let label = Label::new(label_map.len());
                    label_map.insert(offs, label);
                }
            }
            if let MoveBytecode::BrTrue(_) | MoveBytecode::BrFalse(_) = bytecode {
                let next_offs = (pos + 1) as CodeOffset;
                if label_map.get(&next_offs).is_none() {
                    let fall_through_label = Label::new(label_map.len());
                    label_map.insert(next_offs, fall_through_label);
                }
            };
        }

        // Generate bytecode.
        for (code_offset, bytecode) in original_code.iter().enumerate() {
            self.generate_bytecode(bytecode, code_offset as CodeOffset, &label_map);
        }

        // Eliminate fall-through for non-branching instructions
        let code = std::mem::take(&mut self.code);
        for bytecode in code.into_iter() {
            if let Bytecode::Label(attr_id, label) = bytecode {
                if !self.code.is_empty() && !self.code[self.code.len() - 1].is_branch() {
                    self.code.push(Bytecode::Jump(attr_id, label));
                }
            }
            self.code.push(bytecode);
        }

        let Self {
            func_env,
            module: _,
            temp_count: _,
            temp_stack: _,
            local_types,
            code,
            location_table,
            loop_invariants,
        } = self;

        FunctionData::new(
            func_env,
            code,
            local_types,
            func_env.get_return_types(),
            location_table,
            func_env.get_acquires_global_resources(),
            loop_invariants,
        )
    }