Ejemplo n.º 1
0
        public void VisitBinaryOperatorExpression(BinaryOperatorExpression node)
        {
            VisitChildren(node);

            // Force certain operations on integers to stay integers afterwards.
            // This allows JavaScript JITs to omit overflow deoptimizations.
            if (!WillConvertOperandsToIntegers(node) && !WillConvertOperandsToIntegers(UnparenthesizedParent(node))) {
                var result = resolver.Resolve(node) as OperatorResolveResult;
                if (result != null && IsIntegerTypeCode(TypeCode(result.Type))) {
                    var temp = new NullReferenceExpression();
                    node.ReplaceWith(temp);
                    temp.ReplaceWith(new BinaryOperatorExpression(node, BinaryOperatorType.BitwiseOr, new PrimitiveExpression(0)));
                }
            }
        }
Ejemplo n.º 2
0
        public override void VisitNullReferenceExpression(NullReferenceExpression e)
        {
            var call = e.Parent as InvocationExpression;
            if (call != null)
            {
                // 解决 null 参数引起的调用不明问题:???? 如何判断有必要
                var ti = e.Annotation<TypeInformation>();
                e.ReplaceWith(e.Clone().CastTo(AstBuilder.ConvertType(ti.ExpectedType)));
            }

            base.VisitNullReferenceExpression(e);
        }