Mono.CSharp.EmitContext.GetTemporaryLocal C# (CSharp) Method

GetTemporaryLocal() public method

Returns a temporary storage for a variable of type t as a local variable in the current body.
public GetTemporaryLocal ( System.TypeSpec t ) : LocalBuilder
t System.TypeSpec
return System.Reflection.Emit.LocalBuilder
		public LocalBuilder GetTemporaryLocal (TypeSpec t)
		{
			if (temporary_storage != null) {
				object o;
				if (temporary_storage.TryGetValue (t, out o)) {
					if (o is Stack<LocalBuilder>) {
						var s = (Stack<LocalBuilder>) o;
						o = s.Count == 0 ? null : s.Pop ();
					} else {
						temporary_storage.Remove (t);
					}
				}
				if (o != null)
					return (LocalBuilder) o;
			}
			return DeclareLocal (t, false);
		}

Usage Example

        public void Store(EmitContext ec)
        {
            if (builder == null)
            {
                builder = ec.GetTemporaryLocal(type);
            }

            ec.Emit(OpCodes.Stloc, builder);
        }
All Usage Examples Of Mono.CSharp.EmitContext::GetTemporaryLocal