本文整理汇总了C#中mdr.AsDObject方法的典型用法代码示例。如果您正苦于以下问题:C# mdr.AsDObject方法的具体用法?C# mdr.AsDObject怎么用?C# mdr.AsDObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mdr
的用法示例。
在下文中一共展示了mdr.AsDObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToString
public static string ToString(ref mdr.DValue arg)
{
//TODO: it seems eventually, this is the right implementation, but for now, we use the special implementation
//mdr.DValue output;
//if (Operations.Internals.CallToStringProperty(Operations.Convert.ToObject.Run(ref arg), out output))
// return output.AsString();
//else
// return Operations.Convert.ToString.Run(ref arg);
string s;
if (!mdr.ValueTypesHelper.IsObject(arg.ValueType))
{
s = Operations.Convert.ToString.Run(ref arg);
}
else
{
var argObj = arg.AsDObject(); //TODO: should we call ToObject(arg) here instead?!
var toString = argObj.GetField("toString");
if (toString.ValueType == mdr.ValueTypes.Function)
{
var cf = new mdr.CallFrame();
cf.Function = toString.AsDFunction();
cf.Signature = mdr.DFunctionSignature.EmptySignature;
cf.This = argObj;
cf.Arguments = null;
cf.Function.Call(ref cf);
s = Operations.Convert.ToString.Run(ref cf.Return);
}
else
{
s = arg.AsString();
}
}
return s;
}
示例2: Execute
public override void Execute(ref mdr.DValue result, ref mdr.CallFrame callFrame, Interpreter interpreter)
{
interpreter.PushLocation(this);
Container.Execute(ref result, ref callFrame, interpreter);
var obj = result.AsDObject();
AssignFieldId();
Value.Execute(ref result, ref callFrame, interpreter);
obj.SetFieldByFieldId(FieldId, ref result);
//interpreter.PopLocation(this, ref result, obj);
interpreter.PopLocation(this, ref result);
}
示例3: CallToStringProperty
/// <summary>
/// if the toString property of the input is a callable, calls it and sets the result in the output
/// </summary>
/// <param name="input">input</param>
/// <param name="output">The return value of toString property</param>
/// <returns>true if toString is callable and returns a primitive value, otherwise return false</returns>
public static bool CallToStringProperty(ref mdr.DValue input, out mdr.DValue output)
{
return CallToStringProperty(input.AsDObject(), out output);
}
示例4: DefaultValue
/// <summary>
/// ECMA-262, 8.12.8: Implements [[DefaultValue]] for JS objects
/// </summary>
/// <param name="input"></param>
/// <param name="output"></param>
/// <param name="stringHint">Specifies whether the hint is string or number. Default is number.</param>
public static void DefaultValue(ref mdr.DValue input, out mdr.DValue output, bool stringHint = false)
{
Debug.Assert(ValueTypesHelper.IsObject(input.ValueType));
DefaultValue(input.AsDObject(), out output, stringHint);
}