예제 #1
0
 public override bool Reduce(IVariableMap<Expression> Map, ref Expression Reduced)
 {
     // Only possible way to reduce a variable is to replace it with its value.
     Expression possible = null;
     if (Map.Lookup(this.Index, ref possible))
     {
         VariableExpression ve = possible as VariableExpression;
         if (ve != null)
         {
             if (ve.Index == this.Index)
             {
                 return false;
             }
         }
         Reduced = possible;
         return true;
     }
     return false;
 }
예제 #2
0
 /// <summary>
 /// Looks up or "dereferences" a variable with the given index in the specified stack.
 /// </summary>
 public static Expression Lookup(int Index, IVariableMap<Expression> Map)
 {
     Expression res = null;
     if (Map.Lookup(Index, ref res))
     {
         return res.Substitute(Map);
     }
     else
     {
         return Expression.Variable(Index);
     }
 }