本文整理汇总了C#中mdr.AddOwnPropertyDescriptorByFieldId方法的典型用法代码示例。如果您正苦于以下问题:C# mdr.AddOwnPropertyDescriptorByFieldId方法的具体用法?C# mdr.AddOwnPropertyDescriptorByFieldId怎么用?C# mdr.AddOwnPropertyDescriptorByFieldId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mdr
的用法示例。
在下文中一共展示了mdr.AddOwnPropertyDescriptorByFieldId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddSymbolsToContext
private static void AddSymbolsToContext(List<JSSymbol> symbols, mdr.DObject context)
{
//This is called when we are sharing the context, so should be careful not to add fields that are already there
//Technically, this is the generic and safe way to do this.
for (var i = symbols.Count - 1; i >= 0; --i)
{
var symbol = symbols[i];
if (symbol.SymbolType == JSSymbol.SymbolTypes.ClosedOnLocal)
{
var pd = context.Map.GetPropertyDescriptorByFieldId(symbol.FieldId); //TODO: can this be made faster?
if (pd == null)
context.AddOwnPropertyDescriptorByFieldId(symbol.FieldId, PropertyDescriptor.Attributes.Data | PropertyDescriptor.Attributes.NotConfigurable);
}
}
}
示例2: 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;
}
示例3: DeclareVariable
public static void DeclareVariable(mdr.DObject context, string field, int fieldId, ref Stack stack)
{
//we may be looking at a global or this might be second time we call this function with the same context, so following assert will fail (incorrectly)
//Debug.Assert(!context.HasOwnPropertyByFieldId(fieldId), "Cannot redeclare local variable {0}", field);
context.AddOwnPropertyDescriptorByFieldId(fieldId, mdr.PropertyDescriptor.Attributes.Data | mdr.PropertyDescriptor.Attributes.NotConfigurable);
}