本文整理汇总了C#中mdr类的典型用法代码示例。如果您正苦于以下问题:C# mdr类的具体用法?C# mdr怎么用?C# mdr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
mdr类属于命名空间,在下文中一共展示了mdr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: valueOf
// ECMA-262 section 15.6.4.3
private static void valueOf(ref mdr.CallFrame callFrame)
{
Debug.WriteLine("Calling JSBoolean.valueOf");
if (callFrame.This.ValueType != mdr.ValueTypes.Boolean)
throw new Exception("Boolean.prototype.valueOf is not generic");
callFrame.Return.Set(callFrame.This.ToBoolean());
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:8,代码来源:JSBoolean.cs
示例2: CreateFunction
public static void CreateFunction(ref mdr.CallFrame callFrame, int funcDefIndex, mdr.DObject context, ref Stack stack)
{
//Debug.WriteLine("calling Exec.CreateFunction");
var funcDef = ((JSFunctionMetadata)callFrame.Function.Metadata).SubFunctions[funcDefIndex];
var func = new mdr.DFunction(funcDef, context);
stack.Items[stack.Sp++].Set(func); ;
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:7,代码来源:Stack.cs
示例3: Construct
public virtual mdr.DObject Construct(mdr.DFunction func)
{
if (_construct != null)
return _construct(func);
else
return base.Construct(func);
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:7,代码来源:JSBuiltinFunctionImp.cs
示例4: 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
示例5: CallProperty
public static bool CallProperty(mdr.DObject input, string propName, out mdr.DValue output)
{
if (input != null)
{
var propDesc = input.GetPropertyDescriptor(propName);
var prop = new mdr.DValue();
propDesc.Get(input, ref prop);
mdr.DFunction func = null;
if (prop.ValueType == mdr.ValueTypes.Function)
{
func = prop.AsDFunction();
//if (toString != null)
//{
mdr.CallFrame callFrame = new mdr.CallFrame();
callFrame.This = (input);
callFrame.Function = func;
func.Call(ref callFrame);
if (ValueTypesHelper.IsPrimitive(callFrame.Return.ValueType))
{
output = callFrame.Return;
return true;
}
}
}
output = new mdr.DValue();
output.SetUndefined();
return false;
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:28,代码来源:Internals.cs
示例6: JSTypedArrayBase
public JSTypedArrayBase(mdr.DObject prototype, string arrayname, int typesize)
: base(prototype, arrayname)
{
TypeSize = typesize;
TargetPrototype.DefineOwnProperty("length", new mdr.DProperty() {
TargetValueType = mdr.ValueTypes.Int32,
OnGetDValue = (mdr.DObject This, ref mdr.DValue v) => {
v.Set((This as DTypedArray).ByteLength / TypeSize);
},
OnSetDValue = (mdr.DObject This, ref mdr.DValue v) => { /* do nothing */ },
OnSetInt = (mdr.DObject This, int v) => { /* do nothing */ },
});
TargetPrototype.DefineOwnProperty("byteLength", new mdr.DProperty() {
TargetValueType = mdr.ValueTypes.Int32,
OnGetDValue = (mdr.DObject This, ref mdr.DValue v) => {
v.Set((This as DTypedArray).ByteLength);
},
OnSetDValue = (mdr.DObject This, ref mdr.DValue v) => { /* do nothing */ },
OnSetInt = (mdr.DObject This, int v) => { /* do nothing */ },
});
// Constants
this.DefineOwnProperty("BYTES_PER_ELEMENT", TypeSize, mdr.PropertyDescriptor.Attributes.NotConfigurable | mdr.PropertyDescriptor.Attributes.NotWritable | mdr.PropertyDescriptor.Attributes.NotEnumerable | mdr.PropertyDescriptor.Attributes.Data);
TargetPrototype.DefineOwnProperty("BYTES_PER_ELEMENT", TypeSize, mdr.PropertyDescriptor.Attributes.NotConfigurable | mdr.PropertyDescriptor.Attributes.NotWritable | mdr.PropertyDescriptor.Attributes.NotEnumerable | mdr.PropertyDescriptor.Attributes.Data);
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:27,代码来源:JSTypedArrayBase.cs
示例7: Init
internal static void Init(mdr.DObject obj)
{
obj.SetField("global", obj);
//obj.SetField("null", mdr.Runtime.Instance.DefaultDNull);
obj.DefineOwnProperty("undefined", mdr.Runtime.Instance.DefaultDUndefined, mdr.PropertyDescriptor.Attributes.Data | mdr.PropertyDescriptor.Attributes.NotWritable | mdr.PropertyDescriptor.Attributes.NotEnumerable | mdr.PropertyDescriptor.Attributes.NotConfigurable);
obj.DefineOwnProperty("NaN", double.NaN, mdr.PropertyDescriptor.Attributes.Data | mdr.PropertyDescriptor.Attributes.NotWritable | mdr.PropertyDescriptor.Attributes.NotEnumerable | mdr.PropertyDescriptor.Attributes.NotConfigurable);
obj.DefineOwnProperty("Infinity", double.PositiveInfinity, mdr.PropertyDescriptor.Attributes.Data | mdr.PropertyDescriptor.Attributes.NotWritable | mdr.PropertyDescriptor.Attributes.NotEnumerable | mdr.PropertyDescriptor.Attributes.NotConfigurable);
obj.SetField("Object", new JSObject());
obj.SetField("Function", new JSFunction());
obj.SetField("Array", new JSArray());
obj.SetField("ArrayBuffer", new JSArrayBuffer());
obj.SetField("Int8Array", new JSInt8Array());
obj.SetField("Uint8Array", new JSUint8Array());
obj.SetField("Int16Array", new JSInt16Array());
obj.SetField("Uint16Array", new JSUint16Array());
obj.SetField("Int32Array", new JSInt32Array());
obj.SetField("Uint32Array", new JSUint32Array());
obj.SetField("Float32Array", new JSFloat32Array());
obj.SetField("Float64Array", new JSFloat64Array());
obj.SetField("Math", new JSMath());
obj.SetField("String", new JSString());
obj.SetField("Number", new JSNumber());
obj.SetField("Date", new JSDate());
obj.SetField("Boolean", new JSBoolean());
obj.SetField("Error", new JSError());
obj.SetField("RegExp", new JSRegExp());
obj.SetField("eval", BuiltinEval);
AddStandardMethods(obj);
AddExtendedMethods(obj);
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:35,代码来源:JSGlobalObject.cs
示例8: JSBuiltinFunctionImp
public JSBuiltinFunctionImp(mdr.DFuncImpInstance.JittedMethod m, Constructor c)
: base(null, null) //base(m.Method.Name, null, null)
{
Name = m.Method.Name;
_method = m;
_construct = c;
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:7,代码来源:JSBuiltinFunctionImp.cs
示例9: 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
示例10: 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;
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:34,代码来源:JSFunctionArguments.cs
示例11: GetEventHandlerAttr
public static string GetEventHandlerAttr(mdr.DObject obj, string name)
{
var ehp = obj.GetPropertyDescriptor(name).GetProperty() as EventHandlerProperty;
if (ehp == null)
throw new Exception("Invalid Event " + name);
return GetEventHandlerAttr(obj, ehp.EventType, name);
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:7,代码来源:Element.cs
示例12: CheckUndefined
public static mdr.DObject CheckUndefined(mdr.DObject obj)
{
// In case of calling "item" method on lists, a returned null should be converted to undefined.
if (obj == null)
return mdr.Runtime.Instance.DefaultDUndefined;
else
return obj;
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:8,代码来源:DOMBinder.cs
示例13: DTypedArray
protected DTypedArray(mdr.DObject prototype, DArrayBuffer array, int byteoffset, int bytelength, int typesize)
: base(prototype)
{
ByteOffset_ = byteoffset;
TypeSize_ = typesize;
ByteLength_ = bytelength;
Elements_ = array.Elements_;
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:8,代码来源:DTypedArray.cs
示例14: Add
public void Add(mdr.DFunction f, bool useCapture)
{
if (_listeners == null)
_listeners = new List<mdr.DFunction>();
_listeners.Add(f);
if (useCapture)
_useCaptures.Add(f);
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:8,代码来源:EventListeners.cs
示例15: DArrayBuffer
public DArrayBuffer(mdr.DObject prototype, int bytesize)
: base(prototype)
{
ByteLength_ = Math.Min(bytesize, MaxElementsCount);
Elements_ = new byte[ByteLength_];
for (int i = 0; i < ByteLength_; ++i)
Elements_[i] = 0x00;
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:8,代码来源:DArrayBuffer.cs
示例16: CreateArray
public static void CreateArray(ref mdr.CallFrame callFrame, int resultIndex, int valuesCount)
{
var values = callFrame.Values;
var array = new mdr.DArray(valuesCount);
for (var i = valuesCount - 1; i >= 0; --i)
array.Elements[i] = values[resultIndex + i];
values[resultIndex].Set(array);
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:8,代码来源:ICMethods.cs
示例17: PositionListener
public PositionListener(mdr.DFunction handler, mdr.DFunction errorHandler, PositionListenerOptions options)
{
this._handler = handler;
// TODO: Unused.
/*this._errorHandler = errorHandler;
this._options = options;*/
_callFrame = new mdr.CallFrame();
_callFrame.Function = _handler;
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:9,代码来源:PositionListeners.cs
示例18: ParseNumber
/// <summary>
/// Parse a number. Intended to be used at runtime for string-to-number conversions.
/// </summary>
public static void ParseNumber(string number, ref mdr.DValue dValue)
{
var parser = new JavaScriptParser.SequentialParser(number);
var numericLiteral = parser.ParseNumber();
// Convert to a DValue and return via the ref parameter.
Debug.Assert(numericLiteral is IR.PrimitiveLiteral, "ParseNumber() should yield a PrimitiveLiteral.");
(numericLiteral as IR.PrimitiveLiteral).SetAsDValue(ref dValue);
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:12,代码来源:JSParser.cs
示例19: CustomFillPrototype
static partial void CustomFillPrototype(mdr.DObject prototype)
{
var window = mwr.HTMLRuntime.Instance.GlobalContext;
prototype.DefineOwnProperty("onblur", new mdr.DForwardingProperty(window, "onblur"));
prototype.DefineOwnProperty("onerror", new mdr.DForwardingProperty(window, "onerror"));
prototype.DefineOwnProperty("onfocus", new mdr.DForwardingProperty(window, "onfocus"));
prototype.DefineOwnProperty("onload", new mdr.DForwardingProperty(window, "onload"));
prototype.DefineOwnProperty("onscroll", new mdr.DForwardingProperty(window, "onscroll"));
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:9,代码来源:HTMLBodyElement.cs
示例20: CreateConstantContext
public static mdr.DObject CreateConstantContext(ref mdr.CallFrame callFrame)
{
//return CreateFunctionContext(ref callFrame);
//TODO: the following optimization requires proper support in the code generation as well! For now, we don't do much!
//this function will not change its context, so we can just reuse the outer context
Debug.Assert(((JSFunctionMetadata)callFrame.Function.Metadata).Scope.IsConstContext, "Function {0} will need its own context", ((JSFunctionMetadata)callFrame.Function.Metadata).Declaration);
var context = callFrame.Function.OuterContext;
return context;
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:10,代码来源:JSFunctionContext.cs
注:本文中的mdr类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论