Struct rustc::middle::trans::common::FunctionContext[src]
pub struct FunctionContext<'a> {
pub llfn: ValueRef,
pub llenv: Option<ValueRef>,
pub llretptr: Cell<Option<ValueRef>>,
pub entry_bcx: RefCell<Option<&'a Block<'a>>>,
pub alloca_insert_pt: Cell<Option<ValueRef>>,
pub llreturn: Cell<Option<BasicBlockRef>>,
pub personality: Cell<Option<ValueRef>>,
pub caller_expects_out_pointer: bool,
pub llargs: RefCell<NodeMap<LvalueDatum>>,
pub lllocals: RefCell<NodeMap<LvalueDatum>>,
pub llupvars: RefCell<NodeMap<ValueRef>>,
pub id: NodeId,
pub param_substs: &'a param_substs,
pub span: Option<Span>,
pub block_arena: &'a TypedArena<Block<'a>>,
pub ccx: &'a CrateContext,
pub debug_context: FunctionDebugContext,
pub scopes: RefCell<Vec<CleanupScope<'a>>>,
}Fields
llfn | |
llenv | |
llretptr | |
entry_bcx | |
alloca_insert_pt | |
llreturn | |
personality | |
caller_expects_out_pointer | |
llargs | |
lllocals | |
llupvars | |
id | |
param_substs | |
span | |
block_arena | |
ccx | |
debug_context | |
scopes |
Methods
impl<'a> FunctionContext<'a>
fn arg_pos(&self, arg: uint) -> uint
fn out_arg_pos(&self) -> uint
fn env_arg_pos(&self) -> uint
fn cleanup(&self)
fn get_llreturn(&self) -> BasicBlockRef
fn new_block(&'a self, is_lpad: bool, name: &str, opt_node_id: Option<NodeId>) -> &'a Block<'a>
fn new_id_block(&'a self, name: &str, node_id: NodeId) -> &'a Block<'a>
fn new_temp_block(&'a self, name: &str) -> &'a Block<'a>
fn join_blocks(&'a self, id: NodeId, in_cxs: &[&'a Block<'a>]) -> &'a Block<'a>
Trait Implementations
impl<'a> CleanupMethods<'a> for FunctionContext<'a>
fn push_ast_cleanup_scope(&self, id: NodeId)
Invoked when we start to trans the code contained within a new cleanup scope.
fn push_loop_cleanup_scope(&self, id: NodeId, exits: [&'a Block<'a>, ..EXIT_MAX])
fn push_custom_cleanup_scope(&self) -> CustomScopeIndex
fn pop_and_trans_ast_cleanup_scope(&self, bcx: &'a Block<'a>, cleanup_scope: NodeId) -> &'a Block<'a>
Removes the cleanup scope for id cleanup_scope, which
must be at the top of the cleanup stack, and generates the
code to do its cleanups for normal exit.
fn pop_loop_cleanup_scope(&self, cleanup_scope: NodeId)
Removes the loop cleanup scope for id cleanup_scope, which
must be at the top of the cleanup stack. Does not generate
any cleanup code, since loop scopes should exit by
branching to a block generated by normal_exit_block.
fn pop_custom_cleanup_scope(&self, custom_scope: CustomScopeIndex)
Removes the top cleanup scope from the stack without
executing its cleanups. The top cleanup scope must
be the temporary scope custom_scope.
fn pop_and_trans_custom_cleanup_scope(&self, bcx: &'a Block<'a>, custom_scope: CustomScopeIndex) -> &'a Block<'a>
Removes the top cleanup scope from the stack, which must be a temporary scope, and generates the code to do its cleanups for normal exit.
fn top_loop_scope(&self) -> NodeId
Returns the id of the top-most loop scope
fn normal_exit_block(&'a self, cleanup_scope: NodeId, exit: uint) -> BasicBlockRef
Returns a block to branch to which will perform all pending
cleanups and then break/continue (depending on exit) out
of the loop with id cleanup_scope
fn return_exit_block(&'a self) -> BasicBlockRef
Returns a block to branch to which will perform all pending cleanups and then return from this function
fn schedule_drop_mem(&self, cleanup_scope: ScopeId, val: ValueRef, ty: t)
Schedules a (deep) drop of val, which is a pointer to an
instance of ty
fn schedule_drop_immediate(&self, cleanup_scope: ScopeId, val: ValueRef, ty: t)
Schedules a (deep) drop of val, which is an instance of ty
fn schedule_free_value(&self, cleanup_scope: ScopeId, val: ValueRef, heap: Heap, content_ty: t)
Schedules a call to free(val). Note that this is a shallow
operation.
fn schedule_clean(&self, cleanup_scope: ScopeId, cleanup: Box<Cleanup>)
fn schedule_clean_in_ast_scope(&self, cleanup_scope: NodeId, cleanup: Box<Cleanup>)
Schedules a cleanup to occur upon exit from cleanup_scope.
If cleanup_scope is not provided, then the cleanup is scheduled
in the topmost scope, which must be a temporary scope.
fn schedule_clean_in_custom_scope(&self, custom_scope: CustomScopeIndex, cleanup: Box<Cleanup>)
Schedules a cleanup to occur in the top-most scope, which must be a temporary scope.
fn needs_invoke(&self) -> bool
Returns true if there are pending cleanups that should execute on failure.
fn get_landing_pad(&'a self) -> BasicBlockRef
Returns a basic block to branch to in the event of a failure.
This block will run the failure cleanups and eventually
invoke the LLVM Resume instruction.
impl<'a> CleanupHelperMethods<'a> for FunctionContext<'a>
fn top_ast_scope(&self) -> Option<NodeId>
Returns the id of the current top-most AST scope, if any.
fn top_nonempty_cleanup_scope(&self) -> Option<uint>
fn is_valid_to_pop_custom_scope(&self, custom_scope: CustomScopeIndex) -> bool
fn is_valid_custom_scope(&self, custom_scope: CustomScopeIndex) -> bool
fn trans_scope_cleanups(&self, bcx: &'a Block<'a>, scope: &CleanupScope) -> &'a Block<'a>
Generates the cleanups for scope into bcx
fn scopes_len(&self) -> uint
fn push_scope(&self, scope: CleanupScope<'a>)
fn pop_scope(&self) -> CleanupScope<'a>
fn top_scope<R>(&self, f: |&CleanupScope<'a>| -> R) -> R
fn trans_cleanups_to_exit_scope(&'a self, label: EarlyExitLabel) -> BasicBlockRef
Used when the caller wishes to jump to an early exit, such
as a return, break, continue, or unwind. This function will
generate all cleanups between the top of the stack and the
exit label and return a basic block that the caller can
branch to.
For example, if the current stack of cleanups were as follows:
AST 22 Custom 1 AST 23 Loop 23 Custom 2 AST 24
and the label specifies a break from Loop 23, then this
function would generate a series of basic blocks as follows:
Cleanup(AST 24) -> Cleanup(Custom 2) -> break_blk
where break_blk is the block specified in Loop 23 as
the target for breaks. The return value would be the first
basic block in that sequence (Cleanup(AST 24)). The
caller could then branch to Cleanup(AST 24) and it will
perform all cleanups and finally branch to the break_blk.
fn get_or_create_landing_pad(&'a self) -> BasicBlockRef
Creates a landing pad for the top scope, if one does not
exist. The landing pad will perform all cleanups necessary
for an unwind and then resume to continue error
propagation:
landing_pad -> ... cleanups ... -> [resume]
(The cleanups and resume instruction are created by
trans_cleanups_to_exit_scope(), not in this function
itself.)