当前位置: 首页>>代码示例>>C#>>正文


C# JSBinaryOperatorExpression类代码示例

本文整理汇总了C#中JSBinaryOperatorExpression的典型用法代码示例。如果您正苦于以下问题:C# JSBinaryOperatorExpression类的具体用法?C# JSBinaryOperatorExpression怎么用?C# JSBinaryOperatorExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JSBinaryOperatorExpression类属于命名空间,在下文中一共展示了JSBinaryOperatorExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VisitNode

        public void VisitNode(JSBinaryOperatorExpression boe)
        {
            var leftType = boe.Left.GetExpectedType(TypeSystem);
            var leftIsEnum = ILBlockTranslator.IsEnum(leftType);
            var rightType = boe.Right.GetExpectedType(TypeSystem);
            var rightIsEnum = ILBlockTranslator.IsEnum(rightType);

            if ((leftIsEnum || rightIsEnum) && LogicalOperators.Contains(boe.Operator)) {
                if (leftIsEnum) {
                    var cast = JSInvocationExpression.InvokeMethod(
                        new JSFakeMethod("valueOf", TypeSystem.Int32, leftType), boe.Left, null, true
                    );

                    boe.ReplaceChild(boe.Left, cast);
                }

                if (rightIsEnum) {
                    var cast = JSInvocationExpression.InvokeMethod(
                        new JSFakeMethod("valueOf", TypeSystem.Int32, rightType), boe.Right, null, true
                    );

                    boe.ReplaceChild(boe.Right, cast);
                }
            }

            VisitChildren(boe);
        }
开发者ID:Caspeco,项目名称:JSIL,代码行数:27,代码来源:IntroduceEnumCasts.cs

示例2: VisitNode

        public void VisitNode(JSBinaryOperatorExpression boe)
        {
            if (boe.Operator == JSOperator.Assignment)
                SeenAssignments.Add(boe);

            VisitChildren(boe);
        }
开发者ID:poizan42,项目名称:JSIL,代码行数:7,代码来源:OptimizeArrayEnumerators.cs

示例3: DeconstructMutationAssignment

        public static JSExpression DeconstructMutationAssignment (
            JSNode parentNode, JSBinaryOperatorExpression boe, TypeSystem typeSystem, TypeReference intermediateType
        ) {
            var assignmentOperator = boe.Operator as JSAssignmentOperator;
            if (assignmentOperator == null)
                return null;

            JSBinaryOperator replacementOperator;
            if (!IntroduceEnumCasts.ReverseCompoundAssignments.TryGetValue(assignmentOperator, out replacementOperator))
                return null;

            var leftType = boe.Left.GetActualType(typeSystem);

            var newBoe = new JSBinaryOperatorExpression(
                JSOperator.Assignment, MakeLhsForAssignment(boe.Left),
                new JSBinaryOperatorExpression(
                    replacementOperator, boe.Left, boe.Right, intermediateType
                ),
                leftType
            );

            var result = ConvertReadExpressionToWriteExpression(newBoe, typeSystem);
            if (parentNode is JSExpressionStatement) {
                return result;
            } else {
                var comma = new JSCommaExpression(
                    newBoe, boe.Left
                );
                return comma;
            }
        }
开发者ID:TukekeSoft,项目名称:JSIL,代码行数:31,代码来源:DecomposeMutationOperators.cs

示例4: IsPropertyAccess

 public bool IsPropertyAccess(
     JSBinaryOperatorExpression boe, out JSPropertyAccess pa
 )
 {
     pa = boe.Left as JSPropertyAccess;
     return pa != null;
 }
开发者ID:nateleroux,项目名称:JSIL,代码行数:7,代码来源:OptimizePropertyMutationAssignments.cs

示例5: VisitNode

        public void VisitNode(JSBinaryOperatorExpression boe)
        {
            var leftType = boe.Left.GetActualType(TypeSystem);
            var rightType = boe.Right.GetActualType(TypeSystem);

            var leftIsBool = (leftType.FullName == "System.Boolean");
            var rightIsBool = (rightType.FullName == "System.Boolean");

            var leftIsNumeric = TypeUtil.IsNumericOrEnum(leftType);
            var rightIsNumeric = TypeUtil.IsNumericOrEnum(rightType);

            if (
                (leftIsBool != rightIsBool) &&
                (leftIsNumeric || rightIsNumeric) &&
                !(boe.Operator is JSAssignmentOperator)
            ) {
                JSBinaryOperatorExpression replacement;

                if (leftIsBool)
                    replacement = new JSBinaryOperatorExpression(
                        boe.Operator, CastToInteger(boe.Left), boe.Right, boe.ActualType
                    );
                else
                    replacement = new JSBinaryOperatorExpression(
                        boe.Operator, boe.Left, CastToInteger(boe.Right), boe.ActualType
                    );

                ParentNode.ReplaceChild(boe, replacement);
                VisitReplacement(replacement);
            } else {
                VisitChildren(boe);
            }
        }
开发者ID:shreedharcva,项目名称:JSIL,代码行数:33,代码来源:HandleBooleanAsInteger.cs

示例6: IsPropertySetterInvocation

        public static bool IsPropertySetterInvocation(JSNode parentNode, JSBinaryOperatorExpression boe, out JSPropertyAccess pa)
        {
            var isValidParent =
                (parentNode is JSExpressionStatement);

            pa = boe.Left as JSPropertyAccess;

            return (pa != null) &&
                pa.IsWrite &&
                (boe.Operator == JSOperator.Assignment) &&
                isValidParent &&
                CanConvertToInvocation(pa);
        }
开发者ID:snuderl,项目名称:JSIL,代码行数:13,代码来源:ConvertPropertyAccessesToInvocations.cs

示例7: ConvertReadExpressionToWriteExpression

        // Decomposing a compound assignment can leave us with a read expression on the left-hand side
        //  if the compound assignment was targeting a pointer or a reference.
        // We fix this by converting the mundane binary operator expression representing the assignment
        //  into a specialized one that represents a pointer write or reference write.
        private static JSBinaryOperatorExpression ConvertReadExpressionToWriteExpression (
            JSBinaryOperatorExpression boe, TypeSystem typeSystem
        ) {
            var rtpe = boe.Left as JSReadThroughPointerExpression;

            if (rtpe != null)
                return new JSWriteThroughPointerExpression(rtpe.Pointer, boe.Right, boe.ActualType, rtpe.OffsetInBytes);

            var rtre = boe.Left as JSReadThroughReferenceExpression;
            if (rtre != null)
                return new JSWriteThroughReferenceExpression(rtre.Variable, boe.Right);

            return boe;
        }
开发者ID:TukekeSoft,项目名称:JSIL,代码行数:18,代码来源:DecomposeMutationOperators.cs

示例8: MakeUnaryMutation

        private JSBinaryOperatorExpression MakeUnaryMutation (
            JSExpression expressionToMutate, JSBinaryOperator mutationOperator,
            TypeReference type
        ) {
            var newValue = new JSBinaryOperatorExpression(
                mutationOperator, expressionToMutate, JSLiteral.New(1),
                type
            );
            var assignment = new JSBinaryOperatorExpression(
                JSOperator.Assignment,
                MakeLhsForAssignment(expressionToMutate), newValue, type
            );

            return assignment;
        }
开发者ID:BrainSlugs83,项目名称:JSIL,代码行数:15,代码来源:DecomposeMutationOperators.cs

示例9: VisitNode

        public void VisitNode (JSBinaryOperatorExpression boe) {
            JSPropertyAccess pa;
            JSAssignmentOperator assignmentOperator;
            JSBinaryOperator newOperator;

            if (
                IsPropertyAccess(boe, out pa) &&
                ((assignmentOperator = boe.Operator as JSAssignmentOperator) != null) &&
                IntroduceEnumCasts.ReverseCompoundAssignments.TryGetValue(assignmentOperator, out newOperator)
            ) {
                // FIXME: Terrible hack
                var type = pa.GetActualType(TypeSystem);
                var tempVariable = TemporaryVariable.ForFunction(
                    Stack.Last() as JSFunctionExpression, type
                );
                var replacement = new JSCommaExpression(
                    new JSBinaryOperatorExpression(
                        JSOperator.Assignment, tempVariable,
                        new JSBinaryOperatorExpression(
                            newOperator,
                            new JSPropertyAccess(
                                pa.ThisReference, pa.Property, false,
                                pa.TypeQualified, 
                                pa.OriginalType, pa.OriginalMethod, 
                                pa.IsVirtualCall
                            ), 
                            boe.Right, boe.GetActualType(TypeSystem)
                        ), type
                    ),
                    new JSBinaryOperatorExpression(
                        JSOperator.Assignment, 
                        new JSPropertyAccess(
                            pa.ThisReference, pa.Property, true, 
                            pa.TypeQualified,
                            pa.OriginalType, pa.OriginalMethod, 
                            pa.IsVirtualCall
                        ), tempVariable, type
                    ),
                    tempVariable
                );

                ParentNode.ReplaceChild(boe, replacement);
                VisitReplacement(replacement);
            } else {
                VisitChildren(boe);
            }
        }
开发者ID:Don191,项目名称:JSIL,代码行数:47,代码来源:OptimizePropertyMutationAssignments.cs

示例10: MakeUnaryMutation

        public static JSBinaryOperatorExpression MakeUnaryMutation (
            JSExpression expressionToMutate, JSBinaryOperator mutationOperator,
            TypeReference type, TypeSystem typeSystem
        ) {
            var newValue = new JSBinaryOperatorExpression(
                mutationOperator, expressionToMutate, JSLiteral.New(1),
                type
            );
            var assignment = new JSBinaryOperatorExpression(
                JSOperator.Assignment,
                MakeLhsForAssignment(expressionToMutate), newValue, type
            );

            assignment = ConvertReadExpressionToWriteExpression(assignment, typeSystem);

            return assignment;
        }
开发者ID:TukekeSoft,项目名称:JSIL,代码行数:17,代码来源:DecomposeMutationOperators.cs

示例11: VisitNode

        public void VisitNode(JSBinaryOperatorExpression boe)
        {
            var resultType = boe.GetActualType(TypeSystem);
            var resultIsIntegral = TypeUtil.Is32BitIntegral(resultType);

            JSExpression replacement;

            if (
                resultIsIntegral &&
                ((replacement = DeconstructMutationAssignment(boe, TypeSystem, resultType)) != null)
            ) {
                ParentNode.ReplaceChild(boe, replacement);
                VisitReplacement(replacement);
                return;
            }

            VisitChildren(boe);
        }
开发者ID:poizan42,项目名称:JSIL,代码行数:18,代码来源:DecomposeMutationOperators.cs

示例12: VisitNode

        public void VisitNode(JSUnaryOperatorExpression uoe)
        {
            var isBoolean = TypeUtil.IsBoolean(uoe.GetActualType(TypeSystem));

            if (isBoolean) {
                if (uoe.Operator == JSOperator.IsTrue) {
                    ParentNode.ReplaceChild(
                        uoe, uoe.Expression
                    );

                    VisitReplacement(uoe.Expression);
                    return;
                } else if (uoe.Operator == JSOperator.LogicalNot) {
                    var nestedUoe = uoe.Expression as JSUnaryOperatorExpression;
                    var boe = uoe.Expression as JSBinaryOperatorExpression;

                    JSBinaryOperator newOperator;
                    if ((boe != null) &&
                        InvertedOperators.TryGetValue(boe.Operator, out newOperator)
                    ) {
                        var newBoe = new JSBinaryOperatorExpression(
                            newOperator, boe.Left, boe.Right, boe.ActualType
                        );

                        ParentNode.ReplaceChild(uoe, newBoe);
                        VisitReplacement(newBoe);

                        return;
                    } else if (
                        (nestedUoe != null) &&
                        (nestedUoe.Operator == JSOperator.LogicalNot)
                    ) {
                        var nestedExpression = nestedUoe.Expression;

                        ParentNode.ReplaceChild(uoe, nestedExpression);
                        VisitReplacement(nestedExpression);

                        return;
                    }
                }
            }

            VisitChildren(uoe);
        }
开发者ID:nateleroux,项目名称:JSIL,代码行数:44,代码来源:SimplifyOperators.cs

示例13: VisitNode

        public void VisitNode (JSWriteThroughPointerExpression wtpe) {
            JSExpression newPointer, offset;

            if (ExtractOffsetFromPointerExpression(wtpe.Left, TypeSystem, out newPointer, out offset)) {
                // HACK: Is this right?
                if (wtpe.OffsetInBytes != null)
                    offset = new JSBinaryOperatorExpression(JSOperator.Add, wtpe.OffsetInBytes, offset, TypeSystem.Int32);

                var replacement = new JSWriteThroughPointerExpression(newPointer, wtpe.Right, wtpe.ActualType, offset);
                ParentNode.ReplaceChild(wtpe, replacement);
                VisitReplacement(replacement);
            } else if (JSPointerExpressionUtil.UnwrapExpression(wtpe.Pointer) is JSBinaryOperatorExpression) {
                var replacement = new JSUntranslatableExpression("Write through confusing pointer " + wtpe.Pointer);
                ParentNode.ReplaceChild(wtpe, replacement);
                VisitReplacement(replacement);
            } else {
                VisitChildren(wtpe);
            }
        }
开发者ID:TukekeSoft,项目名称:JSIL,代码行数:19,代码来源:UnsafeCodeTransforms.cs

示例14: VisitNode

        public void VisitNode (JSBinaryOperatorExpression boe) {
            var isAssignment = boe.Operator == JSOperator.Assignment;
            var leftVar = boe.Left as JSVariable;

            if (
                (leftVar != null) && isAssignment && !leftVar.IsParameter
            ) {
                if (ToDeclare.Contains(leftVar) && !CouldntDeclare.Contains(leftVar) && !SeenAlready.Contains(leftVar)) {
                    var superParent = Stack.Skip(2).FirstOrDefault();
                    if ((superParent != null) && (ParentNode is JSStatement)) {
                        ToDeclare.Remove(leftVar);
                        ToReplace.Add(new KeyValuePair<JSNode, JSNode>(ParentNode, new JSVariableDeclarationStatement(boe)));

                        VisitChildren(boe);
                        return;
                    } else {
                        CouldntDeclare.Add(leftVar);
                    }
                }
            }

            VisitChildren(boe);
        }
开发者ID:GlennSandoval,项目名称:JSIL,代码行数:23,代码来源:IntroduceVariableDeclarations.cs

示例15: DeconstructMutationAssignment

        public static JSBinaryOperatorExpression DeconstructMutationAssignment(
            JSBinaryOperatorExpression boe, TypeSystem typeSystem, TypeReference intermediateType
        )
        {
            var assignmentOperator = boe.Operator as JSAssignmentOperator;
            if (assignmentOperator == null)
                return null;

            JSBinaryOperator replacementOperator;
            if (!IntroduceEnumCasts.ReverseCompoundAssignments.TryGetValue(assignmentOperator, out replacementOperator))
                return null;

            var leftType = boe.Left.GetActualType(typeSystem);

            var newBoe = new JSBinaryOperatorExpression(
                JSOperator.Assignment, boe.Left,
                new JSBinaryOperatorExpression(
                    replacementOperator, boe.Left, boe.Right, intermediateType
                ),
                leftType
            );

            return ConvertReadExpressionToWriteExpression(newBoe, typeSystem);
        }
开发者ID:poizan42,项目名称:JSIL,代码行数:24,代码来源:DecomposeMutationOperators.cs


注:本文中的JSBinaryOperatorExpression类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。