Ejemplo n.º 1
0
        private static bool IsSpecialUndefinedCheck(Closure closure)
        {
            // TODO: this optimization should happen during Ast Convertion, not here!
            var body = closure.Function.Body;

            if (body == null)
            {
                return(false);
            }

            var returnStatement = body as ReturnStatement;

            var binaryExpression = returnStatement?.ReturnExpression as BinaryExpression;

            // closure has a following content: x => return left OP right;
            if (
                (binaryExpression?.LeftExpression as LocalReferenceExpression)?.Index == 0 &&
                binaryExpression.OperatorKind == BinaryOperator.NotEqual &&
                binaryExpression.RightExpression == UndefinedLiteral.Instance)
            {
                // got the match!
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
 /// <nodoc />
 public bool Equals(Closure c)
 {
     return(c.Env.Path == Env.Path &&
            c.Function.Name == Function.Name &&
            c.Location == Location);
 }