NumberPrototype.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using Jint.Runtime;
  2. using Jint.Runtime.Interop;
  3. namespace Jint.Native.Number
  4. {
  5. /// <summary>
  6. /// http://www.ecma-international.org/ecma-262/5.1/#sec-15.7.4
  7. /// </summary>
  8. public sealed class NumberPrototype : NumberInstance
  9. {
  10. private NumberPrototype(Engine engine)
  11. : base(engine)
  12. {
  13. }
  14. public static NumberPrototype CreatePrototypeObject(Engine engine, NumberConstructor numberConstructor)
  15. {
  16. var obj = new NumberPrototype(engine);
  17. obj.Prototype = engine.Object.PrototypeObject;
  18. obj.PrimitiveValue = 0;
  19. obj.FastAddProperty("constructor", numberConstructor, false, false, false);
  20. return obj;
  21. }
  22. public void Configure()
  23. {
  24. FastAddProperty("toString", new ClrFunctionInstance<object, object>(Engine, ToNumberString), false, false, false);
  25. FastAddProperty("toLocaleString", new ClrFunctionInstance<object, object>(Engine, ToLocaleString), false, false, false);
  26. FastAddProperty("valueOf", new ClrFunctionInstance<object, object>(Engine, ValueOf), false, false, false);
  27. FastAddProperty("toFixed", new ClrFunctionInstance<object, object>(Engine, ToFixed), false, false, false);
  28. FastAddProperty("toExponential", new ClrFunctionInstance<object, object>(Engine, ToExponential), false, false, false);
  29. FastAddProperty("toPrecision", new ClrFunctionInstance<object, object>(Engine, ToPrecision), false, false, false);
  30. }
  31. private object ToLocaleString(object thisObj, object[] arguments)
  32. {
  33. throw new System.NotImplementedException();
  34. }
  35. private object ValueOf(object thisObj, object[] arguments)
  36. {
  37. throw new System.NotImplementedException();
  38. }
  39. private object ToFixed(object thisObj, object[] arguments)
  40. {
  41. throw new System.NotImplementedException();
  42. }
  43. private object ToExponential(object thisObj, object[] arguments)
  44. {
  45. throw new System.NotImplementedException();
  46. }
  47. private object ToPrecision(object thisObj, object[] arguments)
  48. {
  49. throw new System.NotImplementedException();
  50. }
  51. private static object ToNumberString(object thisObject, object[] arguments)
  52. {
  53. return TypeConverter.ToString(thisObject);
  54. }
  55. }
  56. }