本文整理汇总了C#中mdr.GetField方法的典型用法代码示例。如果您正苦于以下问题:C# mdr.GetField方法的具体用法?C# mdr.GetField怎么用?C# mdr.GetField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mdr
的用法示例。
在下文中一共展示了mdr.GetField方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateArgumentsObject
public static mdr.DArray CreateArgumentsObject(ref mdr.CallFrame callFrame, mdr.DObject context)
{
var metadata = (JSFunctionMetadata)callFrame.Function.Metadata;
Debug.Assert(metadata.Scope.HasArgumentsSymbol, "Invalid situation, created arguments for the wrong scope!");
mdr.DArray arguments = null;
if (metadata.Scope.IsEvalFunction)
{
//Read from context
var tmp = new mdr.DValue();
context.GetField(JSFunctionArguments.Name, ref tmp);
arguments = tmp.AsDArray();
}
else
{
arguments = CreateArgumentsObject(ref callFrame);
var parameters = metadata.FunctionIR.Parameters;
Debug.Assert(arguments.Length >= parameters.Count, "arguments array is not large enough to hold all arguments.");
for (var i = parameters.Count - 1; i >= 0; --i)
{
var symbol = parameters[i].Symbol;
var paramIndex = symbol.ParameterIndex;
Debug.Assert(paramIndex == i, "Invalid situation!, Parameter indexes don't match!");
if (symbol.SymbolType == JSSymbol.SymbolTypes.ClosedOnLocal)
{
var pd = context.AddOwnPropertyDescriptorByFieldId(symbol.FieldId, mdr.PropertyDescriptor.Attributes.Accessor | mdr.PropertyDescriptor.Attributes.NotConfigurable);
context.Fields[pd.Index].Set(new ArgumentAccessor(arguments, paramIndex));
}
}
if (metadata.Scope.HasEval)
context.SetField(JSFunctionArguments.Name, arguments);
}
return arguments;
}
示例2: join
// ECMA-262 section 15.4.4.5
//private StringBuilder join(mdr.DArray array) { return join(array, null); }
private StringBuilder join(mdr.DObject obj, string separator)
{
if (obj == null)
throw new ArgumentException("Object is null!");
if (separator == null)
separator = ",";
StringBuilder strBuilder = new StringBuilder(string.Empty);
var lengthField = obj.GetFieldByFieldId(mdr.Runtime.Instance.LengthFieldId);
var length = Operations.Convert.ToInt32.Run(ref lengthField);
if (length == 0)
return strBuilder;
var element_0 = obj.GetField(0);
if (element_0.ValueType != mdr.ValueTypes.Undefined && element_0.ValueType != mdr.ValueTypes.Null)
strBuilder.Append(Operations.Convert.ToString.Run(ref element_0));
for (int k = 1; k < length; k++)
{
strBuilder.Append(separator);
var element_k = obj.GetField(k);
if (element_k.ValueType != mdr.ValueTypes.Undefined && element_k.ValueType != mdr.ValueTypes.Null)
strBuilder.Append(Operations.Convert.ToString.Run(ref element_k));
}
return strBuilder;
}