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

FreeTemporaryLocal() public method

public FreeTemporaryLocal ( LocalBuilder b, System.TypeSpec t ) : void
b System.Reflection.Emit.LocalBuilder
t System.TypeSpec
return void
		public void FreeTemporaryLocal (LocalBuilder b, TypeSpec t)
		{
			if (temporary_storage == null) {
				temporary_storage = new Dictionary<TypeSpec, object> (ReferenceEquality<TypeSpec>.Default);
				temporary_storage.Add (t, b);
				return;
			}
			object o;
			
			if (!temporary_storage.TryGetValue (t, out o)) {
				temporary_storage.Add (t, b);
				return;
			}
			var s = o as Stack<LocalBuilder>;
			if (s == null) {
				s = new Stack<LocalBuilder> ();
				s.Push ((LocalBuilder)o);
				temporary_storage [t] = s;
			}
			s.Push (b);
		}

Usage Example

Example #1
0
        public void Emit(EmitContext ec)
        {
            Nullable.Unwrap unwrap;

            if (NullShortCircuit)
            {
                NullOperatorLabel = ec.DefineLabel();
                unwrap            = instance as Nullable.Unwrap;
            }
            else
            {
                unwrap = null;
            }

            if (unwrap != null)
            {
                unwrap.Store(ec);
                unwrap.EmitCheck(ec);
                ec.Emit(OpCodes.Brfalse, NullOperatorLabel);
                unwrap.Emit(ec);
                var tmp = ec.GetTemporaryLocal(unwrap.Type);
                ec.Emit(OpCodes.Stloc, tmp);
                ec.Emit(OpCodes.Ldloca, tmp);
                ec.FreeTemporaryLocal(tmp, unwrap.Type);
                return;
            }

            EmitLoad(ec);

            if (NullShortCircuit)
            {
                ec.Emit(OpCodes.Dup);
                ec.Emit(OpCodes.Brfalse, NullOperatorLabel);
            }

            value_on_stack = true;
        }
All Usage Examples Of Mono.CSharp.EmitContext::FreeTemporaryLocal