Example #1
0
        ///<inheritdoc/>
        public ILLocalVariable DeclareVariable(Type type, string name)
        {
            ILLocalVariable variable = base.DeclareVariable(type, name);

            if (LocalVariables == null)
            {
                LocalVariables = new List <ILLocalVariable>();
            }
            LocalVariables.Add(variable);
            return(variable);
        }
 /// <summary>
 /// Indicates that the given temporary variable is no longer needed.
 /// </summary>
 /// <param name="variable"> The temporary variable created using CreateTemporaryVariable(). </param>
 public void ReleaseTemporaryVariable(ILLocalVariable variable)
 {
     if (variable == null)
     {
         throw new ArgumentNullException(nameof(variable));
     }
     if (temporaryVariables == null)
     {
         temporaryVariables = new List <ILLocalVariable>();
     }
     temporaryVariables.Add(variable);
 }
 /// <summary>
 /// Creates temp ILVariab le
 /// </summary>
 public ILLocalVariable CreateTemporaryVariable(Type type)
 {
     if (type == null)
     {
         throw new ArgumentNullException(nameof(type));
     }
     if (temporaryVariables != null)
     {
         for (int i = 0; i < temporaryVariables.Count; i++)
         {
             ILLocalVariable temporary = temporaryVariables[i];
             if (temporary.Type == type)
             {
                 temporaryVariables.RemoveAt(i);
                 return(temporary);
             }
         }
     }
     // Create a new temporary variable
     return(DeclareVariable(type));
 }
 /// <summary>
 /// Pops the value from the top of the stack and stores it in the given local variable.
 /// </summary>
 /// <param name="variable"> The variable to store the value. </param>
 public abstract void StoreVariable(ILLocalVariable variable);
 /// <summary>
 /// Pushes the address of the given variable onto the stack.
 /// </summary>
 /// <param name="variable"> The variable whose address will be pushed. </param>
 public abstract void LoadAddressOfVariable(ILLocalVariable variable);
 /// <summary>
 /// Pushes the value of the given variable onto the stack.
 /// </summary>
 /// <param name="variable"> The variable whose value will be pushed. </param>
 public abstract void LoadVariable(ILLocalVariable variable);
Example #7
0
 ///<inheritdoc/>
 public override void StoreVariable(ILLocalVariable variable)
 {
     Generator.Emit(OpCodes.Stloc, variable.UnderlyingLocal);
 }
Example #8
0
 ///<inheritdoc/>
 public override void LoadAddressOfVariable(ILLocalVariable variable)
 {
     Generator.Emit(OpCodes.Ldloca, variable.UnderlyingLocal);
 }