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


C# JsExpression.Assign方法代码示例

本文整理汇总了C#中JsExpression.Assign方法的典型用法代码示例。如果您正苦于以下问题:C# JsExpression.Assign方法的具体用法?C# JsExpression.Assign怎么用?C# JsExpression.Assign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JsExpression的用法示例。


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

示例1: TryCharBinaryExpression

 public bool TryCharBinaryExpression(SyntaxKind type, TypeInfo leftSymbol, TypeInfo rightSymbol, JsExpression left, JsExpression right, out JsExpression result)
 {
     if (Equals(leftSymbol.Type, Context.Instance.Char) || Equals(rightSymbol.Type, Context.Instance.Char))
     {
         switch (type)
         {
             case SyntaxKind.SubtractExpression:
             case SyntaxKind.AddExpression:
             case SyntaxKind.MultiplyExpression:
             case SyntaxKind.DivideExpression:
             case SyntaxKind.ModuloExpression:
             case SyntaxKind.BitwiseAndExpression:
             case SyntaxKind.BitwiseOrExpression:
             case SyntaxKind.LessThanExpression:
             case SyntaxKind.LessThanOrEqualExpression:
             case SyntaxKind.GreaterThanExpression:
             case SyntaxKind.GreaterThanOrEqualExpression:
             case SyntaxKind.LeftShiftExpression:
             case SyntaxKind.RightShiftExpression:
             case SyntaxKind.ExclusiveOrExpression:
             case SyntaxKind.AddAssignmentExpression:
             case SyntaxKind.SubtractAssignmentExpression:
             case SyntaxKind.MultiplyAssignmentExpression:
             case SyntaxKind.DivideAssignmentExpression:
             case SyntaxKind.ModuloAssignmentExpression:
                 result = Js.Binary(
                     ToBinaryOperator(type).Value,
                     !Equals(leftSymbol.Type, Context.Instance.Char) || Equals(rightSymbol.Type, Context.Instance.String) ? left : left.Member("charCodeAt").Invoke(Js.Primitive(0)),
                     !Equals(rightSymbol.Type, Context.Instance.Char) || Equals(leftSymbol.Type, Context.Instance.String) ? right : right.Member("charCodeAt").Invoke(Js.Primitive(0))
                 );
                 switch (type)
                 {
                     case SyntaxKind.AddAssignmentExpression:
                     case SyntaxKind.SubtractAssignmentExpression:
                     case SyntaxKind.MultiplyAssignmentExpression:
                     case SyntaxKind.DivideAssignmentExpression:
                     case SyntaxKind.ModuloAssignmentExpression:
                         result = left.Assign(Js.Reference("String").Member("fromCharCode").Invoke(result));
                         break;
                 }
                 return true;
         }                
     }
     result = null;
     return false;
 }
开发者ID:x335,项目名称:WootzJs,代码行数:46,代码来源:Idioms.cs

示例2: TryIntegerDivision

 public bool TryIntegerDivision(SyntaxKind type, TypeInfo leftSymbol, TypeInfo rightSymbol, JsExpression left, JsExpression right, out JsExpression result)
 {
     if ((type == SyntaxKind.DivideExpression || type == SyntaxKind.DivideAssignmentExpression) && 
         IsIntegerType(leftSymbol.ConvertedType) && 
         IsIntegerType(rightSymbol.ConvertedType))
     {
         result = Js.Reference(SpecialNames.Truncate).Invoke(Js.Binary(JsBinaryOperator.Divide, left, right));
         if (type == SyntaxKind.DivideAssignmentExpression)
         {
             result = left.Assign(result);
         }
         return true;
     }
     result = null;
     return false;
 }
开发者ID:x335,项目名称:WootzJs,代码行数:16,代码来源:Idioms.cs

示例3: TryCharUnaryExpression

        public bool TryCharUnaryExpression(SyntaxKind type, TypeInfo operandType, JsExpression operand, out JsExpression result)
        {
            if (Equals(operandType.Type, Context.Instance.Char))
            {
                switch (type)
                {
                    case SyntaxKind.PostDecrementExpression:
                    case SyntaxKind.PostIncrementExpression:
                    {
                        var old = Js.Variable("$old", operand);

                        var op = type == SyntaxKind.PostDecrementExpression ? JsBinaryOperator.Subtract : JsBinaryOperator.Add;
                        result = Js.Binary(
                            op, 
                            old.GetReference().Member("charCodeAt").Invoke(Js.Primitive(0)),
                            Js.Primitive(1)
                        );
                        result = operand.Assign(Js.Reference("String").Member("fromCharCode").Invoke(result));

                        var block = new JsBlockStatement();
                        block.Local(old);
                        block.Express(result);
                        block.Return(old.GetReference());
                        result = Wrap(block);

                        return true;
                    }
                    case SyntaxKind.PreDecrementExpression:
                    case SyntaxKind.PreIncrementExpression:
                    {
                        var op = type == SyntaxKind.PreDecrementExpression ? JsBinaryOperator.Subtract : JsBinaryOperator.Add;
                        result = Js.Binary(
                            op, 
                            operand.Member("charCodeAt").Invoke(Js.Primitive(0)),
                            Js.Primitive(1)
                        );
                        result = operand.Assign(Js.Reference("String").Member("fromCharCode").Invoke(result));
                        return true;
                    }
                }
            }
            result = null;
            return false;
        }
开发者ID:x335,项目名称:WootzJs,代码行数:44,代码来源:Idioms.cs


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