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


C# mdr.Set方法代码示例

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


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

示例1: Run

 // i0 ? i1 : i2
 public static void Run(ref mdr.DValue i0, ref mdr.DValue i1, ref mdr.DValue i2, ref mdr.DValue result)
 {
     if (Operations.Convert.ToBoolean.Run(ref i0))
         result.Set(ref i1);
     else
         result.Set(ref i2);
 }
开发者ID:reshadi2,项目名称:mcjs,代码行数:8,代码来源:Conditional.cs

示例2: EvalString

        internal static void EvalString(string inputString, ref mdr.DValue result, mdr.DFunction callerFunction = null, mdr.DObject callerContext = null, mdr.DObject thisArg = null)
        {
          var funcMetadata = JSParser.ParseScript(inputString).Expression.Metadata;
          var func = new mdr.DFunction(funcMetadata, null);

          var tempCallFrame = new mdr.CallFrame();
          bool isDirectEval = callerContext != null;

          if (isDirectEval)
          {
            //function will behave as if it was the caller
            Debug.Assert(thisArg != null && callerFunction != null && callerContext != null, "Invalid situation! Direct eval call must have thisArg, callerFunction, callerContext set");
            funcMetadata.Scope.IsProgram = false;
            funcMetadata.Scope.IsEvalFunction = true;
            funcMetadata.ParentFunction = (JSFunctionMetadata)callerFunction.Metadata;
            tempCallFrame.CallerContext = callerContext;
            tempCallFrame.This = thisArg;
          }
          else
          {
            //This will behave just like a program code
            tempCallFrame.CallerContext = mdr.Runtime.Instance.GlobalContext;
            tempCallFrame.This = (mdr.Runtime.Instance.GlobalContext);
          }

          //TODO: find a way to assign a name to this
          //funcMetadata.Name += "_eval"; //After we know the ParentFunction

          tempCallFrame.Function = func;
          tempCallFrame.Signature = mdr.DFunctionSignature.EmptySignature;
          func.Call(ref tempCallFrame);
          result.Set(ref tempCallFrame.Return);
        }
开发者ID:reshadi2,项目名称:mcjs,代码行数:33,代码来源:JSGlobalObject.cs

示例3: Run

 public static void Run(ref mdr.DValue i0, int i1)
 {
     switch (i0.ValueType)
     {
         case mdr.ValueTypes.Double:
             {
                 double oldValue = i0.DoubleValue;
                 double newValue = oldValue + i1;
                 i0.DoubleValue = newValue;
                 //i0.Set(newValue);
                 break;
             }
         case mdr.ValueTypes.Int32:
             {
                 int oldValue = i0.IntValue;
                 int newValue = oldValue + i1;
                 i0.IntValue = newValue;
                 //i0.Set(newValue);
                 break;
             }
         case mdr.ValueTypes.Boolean:
             {
                 int oldValue = i0.BooleanValue ? 1 : 0;
                 int newValue = oldValue + i1;
                 i0.Set(newValue);
                 break;
             }
         default:
             {
                 double oldValue = i0.AsDouble();
                 double newValue = oldValue + i1;
                 i0.Set(newValue);
                 break;
             }
     }
 }
开发者ID:reshadi2,项目名称:mcjs,代码行数:36,代码来源:IncDec.cs

示例4: Execute

 public override void Execute(ref mdr.DValue result, ref mdr.CallFrame callFrame, Interpreter interpreter)
 {
   interpreter.PushLocation(this);
   result.Set(new mdr.DRegExp(Regexp, Options));
   interpreter.PopLocation(this, ref result);
 }
开发者ID:reshadi2,项目名称:mcjs,代码行数:6,代码来源:Interpreter.cs

示例5: Run

 public static void Run(mdr.DArray i0, ref mdr.DValue result) { result.Set(i0); }
开发者ID:reshadi2,项目名称:mcjs,代码行数:1,代码来源:Assign.cs

示例6: AddConst

        //public static mdr.DValue IncDec(ref mdr.DValue i0, int i1)
        //{
        //    var result = new mdr.DValue();
        //    switch (i0.ValueType)
        //    {
        //        case mdr.ValueTypes.Int:
        //            {
        //                int oldValue = i0.IntValue;
        //                int newValue = oldValue + i1;
        //                result.Set(newValue);
        //                break;
        //            }
        //        case mdr.ValueTypes.Boolean:
        //            {
        //                int oldValue = i0.BoolValue ? 1 : 0;
        //                int newValue = oldValue + i1;
        //                result.Set(newValue);
        //                break;
        //            }
        //        default:
        //            {
        //                double oldValue = i0.ToDouble();
        //                double newValue = oldValue + i1;
        //                result.Set(newValue);
        //                break;
        //            }
        //    }
        //    return result;
        //}

        /// <summary>
        /// The following is used for inc/dec that involves DValue. To handle arrays and properties well, we will have a separate object for 
        /// reading the value, and another for setting. To make the inc/dec and assign, etc. uniform, we should consider that on the stack 
        /// we have all the paramertes always for all kinds of values (symbols, arrays, properties, ...)
        /// 
        /// followings:
        ///     dest for writing
        ///     DObject  for setting (for array/property will be a member of the object itself)
        ///     DObject  for reading (for array/property may be a member of the object's prototype)
        /// </summary>
        /// <param name="result">for returing the value that is used in the next instruction.</param>
        /// <param name="dest">For updating the source itself</param>
        /// <param name="i0">the source for reading the value</param>
        /// <param name="i1">1 for inc and -1 for dec</param>
        /// <param name="isPostfix"></param>
        /// <returns></returns>
        public static void AddConst(ref mdr.DValue dest, /*const*/ ref mdr.DValue i0, int i1, bool isPostfix, ref mdr.DValue result)
        {
            switch (i0.ValueType)
            {
                case mdr.ValueTypes.Int32:
                    {
                        int oldValue = i0.IntValue;
                        int newValue = oldValue + i1;
                        dest.Set(newValue);
                        result.Set(isPostfix ? oldValue : newValue);
                        break;
                    }
                case mdr.ValueTypes.Boolean:
                    {
                        int oldValue = i0.BooleanValue ? 1 : 0;
                        int newValue = oldValue + i1;
                        dest.Set(newValue);
                        result.Set(isPostfix ? oldValue : newValue);
                        break;
                    }
                default:
                    {
                        double oldValue = i0.AsDouble();
                        double newValue = oldValue + i1;
                        dest.Set(newValue);
                        result.Set(isPostfix ? oldValue : newValue);
                        break;
                    }
            }
        }
开发者ID:reshadi2,项目名称:mcjs,代码行数:76,代码来源:IncDec.cs


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