Reference.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using Jint.Native;
  2. namespace Jint.Runtime.References
  3. {
  4. /// <summary>
  5. /// Represents the Reference Specification Type
  6. /// http://www.ecma-international.org/ecma-262/5.1/#sec-8.7
  7. /// </summary>
  8. public class Reference
  9. {
  10. private readonly JsValue _baseValue;
  11. private readonly string _name;
  12. private readonly bool _strict;
  13. public Reference(JsValue baseValue, string name, bool strict)
  14. {
  15. _baseValue = baseValue;
  16. _name = name;
  17. _strict = strict;
  18. }
  19. public JsValue GetBase()
  20. {
  21. return _baseValue;
  22. }
  23. public string GetReferencedName()
  24. {
  25. return _name;
  26. }
  27. public bool IsStrict()
  28. {
  29. return _strict;
  30. }
  31. public bool HasPrimitiveBase()
  32. {
  33. return _baseValue.IsPrimitive();
  34. }
  35. public bool IsUnresolvableReference()
  36. {
  37. return _baseValue.IsUndefined();
  38. }
  39. public bool IsPropertyReference()
  40. {
  41. // http://www.ecma-international.org/ecma-262/5.1/#sec-8.7
  42. return _baseValue.IsObject() || HasPrimitiveBase();
  43. }
  44. }
  45. }