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


C# mdr.SetExpectedArgsCount方法代码示例

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


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

示例1: DeclareParameterSymbols

    private void DeclareParameterSymbols(ref mdr.CallFrame callFrame)
    {
      var parameters = _currFuncMetadata.FunctionIR.Parameters;

      //Extend missing arguments
      callFrame.SetExpectedArgsCount(parameters.Count);

      if (_currScope.HasArgumentsSymbol)
      {
        ///In this case, we already read/write from the arguments.Elements[i] for the symbol. 
        ///however, we should always refer to the arguments variable itself since its .Elements 
        ///may be resized and changed
        ///we cannot rely on the argument symbol's variable for this since the progremmer
        ///may write the arguments symbol and we can lose the value, so we keep our own separately

        Arguments = JSFunctionArguments.CreateArgumentsObject(ref callFrame, Context);
        var symbols = _currScope.Symbols;
        for (var i = parameters.Count; i < symbols.Count; ++i) //Hopefully "arguments" is the symbol almost immediately after the parameters
        {
          var symbol = symbols[i];
          if (symbol.SymbolType == JSSymbol.SymbolTypes.Arguments)
          {
            SymbolValues[symbol.ValueIndex].Set(Arguments);
            break;
          }
        }
      }
      else
      {
        Arguments = null;
        var i = parameters.Count;
        if (i > callFrame.PassedArgsCount)
          i = callFrame.PassedArgsCount;
        for (i = i - 1; i >= 0; --i)
        {
          var symbol = parameters[i].Symbol;
          Debug.Assert(symbol.ParameterIndex == i, "Invalid situation!, symbol {0} should be paramter with parameter index {1} instead of {2}", symbol.Name, i, symbol.ParameterIndex);
          if (symbol.SymbolType == JSSymbol.SymbolTypes.ClosedOnLocal)
          {
            var pd = Context.Map.GetPropertyDescriptorByFieldId(symbol.FieldId);
            Debug.Assert(
              pd != null
              && !pd.HasAttributes(mdr.PropertyDescriptor.Attributes.Undefined | mdr.PropertyDescriptor.Attributes.Inherited | mdr.PropertyDescriptor.Attributes.Accessor)
              , "Invalid situation, symbol {0} is not properly added to context", symbol.Name);
            Context.Fields[pd.Index] = callFrame.Arg(i);
            SymbolValues[symbol.ValueIndex].Set(pd);
          }
        }
      }
    }
开发者ID:reshadi2,项目名称:mcjs,代码行数:50,代码来源:Interpreter.cs


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