pub fn new(ccx: &'blk CrateContext<'blk, 'tcx>,
               llfndecl: ValueRef,
               fn_ty: FnType,
               definition: Option<(Instance<'tcx>, &ty::FnSig<'tcx>, Abi, ast::NodeId)>,
               block_arena: &'blk TypedArena<common::BlockS<'blk, 'tcx>>)
               -> FunctionContext<'blk, 'tcx> {
        let (param_substs, def_id, inlined_id) = match definition {
            Some((instance, _, _, inlined_id)) => {
                common::validate_substs(instance.substs);
                (instance.substs, Some(instance.def), Some(inlined_id))
            }
            None => (ccx.tcx().mk_substs(Substs::empty()), None, None)
        };

        let local_id = def_id.and_then(|id| ccx.tcx().map.as_local_node_id(id));

        debug!("FunctionContext::new({})",
               definition.map_or(String::new(), |d| d.0.to_string()));

        let cfg = inlined_id.map(|id| build_cfg(ccx.tcx(), id));
        let nested_returns = if let Some((blk_id, Some(ref cfg))) = cfg {
            has_nested_returns(ccx.tcx(), cfg, blk_id)
        } else {
            false
        };

        let check_attrs = |attrs: &[ast::Attribute]| {
            let default_to_mir = ccx.sess().opts.debugging_opts.orbit;
            let invert = if default_to_mir { "rustc_no_mir" } else { "rustc_mir" };
            (default_to_mir ^ attrs.iter().any(|item| item.check_name(invert)),
             attrs.iter().any(|item| item.check_name("no_debug")))
        };

        let (use_mir, no_debug) = if let Some(id) = local_id {
            check_attrs(ccx.tcx().map.attrs(id))
        } else if let Some(def_id) = def_id {
            check_attrs(&ccx.sess().cstore.item_attrs(def_id))
        } else {
            check_attrs(&[])
        };

        let mir = if use_mir {
            def_id.and_then(|id| ccx.get_mir(id))
        } else {
            None
        };

        let debug_context = if let (false, Some(definition)) = (no_debug, definition) {
            let (instance, sig, abi, _) = definition;
            debuginfo::create_function_debug_context(ccx, instance, sig, abi, llfndecl)
        } else {
            debuginfo::empty_function_debug_context(ccx)
        };

        FunctionContext {
            needs_ret_allocas: nested_returns && mir.is_none(),
            mir: mir,
            llfn: llfndecl,
            llretslotptr: Cell::new(None),
            param_env: ccx.tcx().empty_parameter_environment(),
            alloca_insert_pt: Cell::new(None),
            llreturn: Cell::new(None),
            landingpad_alloca: Cell::new(None),
            lllocals: RefCell::new(NodeMap()),
            llupvars: RefCell::new(NodeMap()),
            lldropflag_hints: RefCell::new(DropFlagHintsMap::new()),
            fn_ty: fn_ty,
            param_substs: param_substs,
            span: inlined_id.and_then(|id| ccx.tcx().map.opt_span(id)),
            block_arena: block_arena,
            lpad_arena: TypedArena::new(),
            ccx: ccx,
            debug_context: debug_context,
            scopes: RefCell::new(Vec::new()),
            cfg: cfg.and_then(|(_, cfg)| cfg)
        }
    }
/// Create a function context for the given function.
/// Beware that you must call `fcx.init` or `fcx.bind_args`
/// before doing anything with the returned function context.
Create a function context for the given function.
Beware that you must call `fcx.init` or `fcx.bind_args`
before doing anything with the returned function context.
Create a function context for the given function . Beware that you must call ` fcx . init ` or ` fcx . bind_args ` before doing anything with the returned function context .
pub fn new(ccx: &'blk CrateContext<'blk, 'tcx>,
               llfndecl: ValueRef,
               fn_ty: FnType,
               definition: Option<(Instance<'tcx>, &ty::FnSig<'tcx>, Abi, ast::NodeId)>,
               block_arena: &'blk TypedArena<common::BlockS<'blk, 'tcx>>)
               -> FunctionContext<'blk, 'tcx> {
        let (param_substs, def_id, inlined_id) = match definition {
            Some((instance, _, _, inlined_id)) => {
                common::validate_substs(instance.substs);
                (instance.substs, Some(instance.def), Some(inlined_id))
            }
            None => (ccx.tcx().mk_substs(Substs::empty()), None, None)
        };
        let local_id = def_id.and_then(|id| ccx.tcx().map.as_local_node_id(id));
        debug!("FunctionContext::new({})",
               definition.map_or(String::new(), |d| d.0.to_string()));
        let cfg = inlined_id.map(|id| build_cfg(ccx.tcx(), id));
        let nested_returns = if let Some((blk_id, Some(ref cfg))) = cfg {
            has_nested_returns(ccx.tcx(), cfg, blk_id)
        } else {
            false
        };
        let check_attrs = |attrs: &[ast::Attribute]| {
            let default_to_mir = ccx.sess().opts.debugging_opts.orbit;
            let invert = if default_to_mir { "rustc_no_mir" } else { "rustc_mir" };
            (default_to_mir ^ attrs.iter().any(|item| item.check_name(invert)),
             attrs.iter().any(|item| item.check_name("no_debug")))
        };
        let (use_mir, no_debug) = if let Some(id) = local_id {
            check_attrs(ccx.tcx().map.attrs(id))
        } else if let Some(def_id) = def_id {
            check_attrs(&ccx.sess().cstore.item_attrs(def_id))
        } else {
            check_attrs(&[])
        };
        let mir = if use_mir {
            def_id.and_then(|id| ccx.get_mir(id))
        } else {
            None
        };
        let debug_context = if let (false, Some(definition)) = (no_debug, definition) {
            let (instance, sig, abi, _) = definition;
            debuginfo::create_function_debug_context(ccx, instance, sig, abi, llfndecl)
        } else {
            debuginfo::empty_function_debug_context(ccx)
        };
        FunctionContext {
            needs_ret_allocas: nested_returns && mir.is_none(),
            mir: mir,
            llfn: llfndecl,
            llretslotptr: Cell::new(None),
            param_env: ccx.tcx().empty_parameter_environment(),
            alloca_insert_pt: Cell::new(None),
            llreturn: Cell::new(None),
            landingpad_alloca: Cell::new(None),
            lllocals: RefCell::new(NodeMap()),
            llupvars: RefCell::new(NodeMap()),
            lldropflag_hints: RefCell::new(DropFlagHintsMap::new()),
            fn_ty: fn_ty,
            param_substs: param_substs,
            span: inlined_id.and_then(|id| ccx.tcx().map.opt_span(id)),
            block_arena: block_arena,
            lpad_arena: TypedArena::new(),
            ccx: ccx,
            debug_context: debug_context,
            scopes: RefCell::new(Vec::new()),
            cfg: cfg.and_then(|(_, cfg)| cfg)
        }
    }
pub fn new ( ccx : & ' blk CrateContext < ' blk , ' tcx > , llfndecl : ValueRef , fn_ty : FnType , definition : Option < ( Instance < ' tcx > , & ty :: FnSig < ' tcx > , Abi , ast :: NodeId ) > , block_arena : & ' blk TypedArena < common :: BlockS < ' blk , ' tcx > > ) -> FunctionContext < ' blk , ' tcx > { let ( param_substs , def_id , inlined_id ) = match definition { Some ( ( instance , _ , _ , inlined_id ) ) => { common :: validate_substs ( instance . substs ) ; ( instance . substs , Some ( instance . def ) , Some ( inlined_id ) ) } None => ( ccx . tcx ( ) . mk_substs ( Substs :: empty ( ) ) , None , None ) } ; let local_id = def_id . and_then ( | id | ccx . tcx ( ) . map . as_local_node_id ( id ) ) ; debug ! ( " " definition map_or ( String new ( ) d d 0 to_string ( ) ) ) ; let cfg = inlined_id . map ( | id | build_cfg ( ccx . tcx ( ) , id ) ) ; let nested_returns = if let Some ( ( blk_id , Some ( ref cfg ) ) ) = cfg { has_nested_returns ( ccx . tcx ( ) , cfg , blk_id ) } else { false } ; let check_attrs = | attrs : & [ ast :: Attribute ] | { let default_to_mir = ccx . sess ( ) . opts . debugging_opts . orbit ; let invert = if default_to_mir { " " } else { " " } ; ( default_to_mir ^ attrs . iter ( ) . any ( | item | item . check_name ( invert ) ) , attrs . iter ( ) . any ( | item | item . check_name ( " " ) ) ) } ; let ( use_mir , no_debug ) = if let Some ( id ) = local_id { check_attrs ( ccx . tcx ( ) . map . attrs ( id ) ) } else if let Some ( def_id ) = def_id { check_attrs ( & ccx . sess ( ) . cstore . item_attrs ( def_id ) ) } else { check_attrs ( & [ ] ) } ; let mir = if use_mir { def_id . and_then ( | id | ccx . get_mir ( id ) ) } else { None } ; let debug_context = if let ( false , Some ( definition ) ) = ( no_debug , definition ) { let ( instance , sig , abi , _ ) = definition ; debuginfo :: create_function_debug_context ( ccx , instance , sig , abi , llfndecl ) } else { debuginfo :: empty_function_debug_context ( ccx ) } ; FunctionContext { needs_ret_allocas : nested_returns && mir . is_none ( ) , mir : mir , llfn : llfndecl , llretslotptr : Cell :: new ( None ) , param_env : ccx . tcx ( ) . empty_parameter_environment ( ) , alloca_insert_pt : Cell :: new ( None ) , llreturn : Cell :: new ( None ) , landingpad_alloca : Cell :: new ( None ) , lllocals : RefCell :: new ( NodeMap ( ) ) , llupvars : RefCell :: new ( NodeMap ( ) ) , lldropflag_hints : RefCell :: new ( DropFlagHintsMap :: new ( ) ) , fn_ty : fn_ty , param_substs : param_substs , span : inlined_id . and_then ( | id | ccx . tcx ( ) . map . opt_span ( id ) ) , block_arena : block_arena , lpad_arena : TypedArena :: new ( ) , ccx : ccx , debug_context : debug_context , scopes : RefCell :: new ( Vec :: new ( ) ) , cfg : cfg . and_then ( | ( _ , cfg ) | cfg ) } }
Create a function context for the given function.
Create a function context for the given function .
ccx
&'blk CrateContext<'blk, 'tcx>
llfndecl
ValueRef
fn_ty
FnType
definition
Option<(Instance<'tcx>, &ty::FnSig<'tcx>, Abi, ast::NodeId)>
block_arena
&'blk TypedArena<common::BlockS<'blk, 'tcx>>
ccx
&'blk CrateContext<'blk, 'tcx>
llfndecl
ValueRef
fn_ty
FnType
definition
Option<(Instance<'tcx>, &ty::FnSig<'tcx>, Abi, ast::NodeId)>
block_arena
&'blk TypedArena<common::BlockS<'blk, 'tcx>>