protected override bool Walk(UnaryExpression node)
        {
          if (node.NodeType == AstNodeType.Convert && node.Operand is BoundExpression)
          {
            var be = node.Operand as BoundExpression;

            if (!be.Variable.Lift)
            {
              var origbe = be;

              if (be.Variable.Kind == Variable.VariableKind.Local && be.Variable.AssumedValue is BoundExpression)
              {
                var assbe = be.Variable.AssumedValue as BoundExpression;
                if (assbe.Variable.Kind == Variable.VariableKind.Parameter)
                {
                  be = assbe;
                }
              }

              if (be.Variable.Kind == Variable.VariableKind.Parameter
                && be.Type == typeof(object)
                && node.Type != typeof(object))
              {
                Dictionary<Type, int> counts;
                if (!references.TryGetValue(origbe.Variable, out counts))
                {
                  references[origbe.Variable] = counts = new Dictionary<Type, int>();
                }

                if (counts.ContainsKey(node.Type))
                {
                  counts[node.Type]++;
                }
                else
                {
                  counts[node.Type] = 1;
                }
              }
            }
          }
          return base.Walk(node);
        }
                protected override void PostWalk(UnaryExpression node)
                {
                    base.PostWalk(node);

                      if (node.NodeType == AstNodeType.Convert)
                      {
                    var op = node.Operand;
                    if (op.NodeType == AstNodeType.Convert)
                    {
                      var inode = op as UnaryExpression;
                      if (inode.Operand.Type == node.Type)
                      {
                    node.Operand = inode.Operand;
                      }
                    }
                    if (node.Type != typeof(object) &&
                      node.Type != op.Type &&
                      node.Type.IsAssignableFrom(op.Type) &&
                      !(node.Type.IsInterface && op.Type.IsValueType))
                    {
                      node.SetType(op.Type);
                    }
                      }
                }
 protected override bool Walk(UnaryExpression node)
 {
     if (node.NodeType == AstNodeType.Convert && node.Operand is BoundExpression)
       {
     var be = node.Operand as BoundExpression;
     var tv = be.Variable.GetTypedVariable(node.Type);
     if (tv != null)
     {
       be.Variable = tv;
     }
       }
       return base.Walk(node);
 }
Exemple #4
0
 // UnaryExpression
 private void DefaultWalk(UnaryExpression node)
 {
     if (Walk(node)) {
         WalkNode(node.Operand);
     }
     PostWalk(node);
 }
 protected override bool Walk(UnaryExpression node)
 {
   if (node.NodeType == AstNodeType.Convert)
   {
     if (node.Operand is BoundExpression)
     {
       var be = node.Operand as BoundExpression;
       ProcessAssignment(node, be.Variable, false);
     }
   }
   return base.Walk(node);
 }