PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/Dependencies/boo/src/Boo.Lang.Compiler/TypeSystem/InternalField.cs

https://github.com/w4x/boolangstudio
C# | 181 lines | 134 code | 21 blank | 26 comment | 2 complexity | 64aad39c4ba52f89123b6458239212f6 MD5 | raw file
Possible License(s): GPL-2.0
  1. #region license
  2. // Copyright (c) 2004, Rodrigo B. de Oliveira (rbo@acm.org)
  3. // All rights reserved.
  4. //
  5. // Redistribution and use in source and binary forms, with or without modification,
  6. // are permitted provided that the following conditions are met:
  7. //
  8. // * Redistributions of source code must retain the above copyright notice,
  9. // this list of conditions and the following disclaimer.
  10. // * Redistributions in binary form must reproduce the above copyright notice,
  11. // this list of conditions and the following disclaimer in the documentation
  12. // and/or other materials provided with the distribution.
  13. // * Neither the name of Rodrigo B. de Oliveira nor the names of its
  14. // contributors may be used to endorse or promote products derived from this
  15. // software without specific prior written permission.
  16. //
  17. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  18. // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
  21. // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  23. // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  24. // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  25. // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26. // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. #endregion
  28. namespace Boo.Lang.Compiler.TypeSystem
  29. {
  30. using Boo.Lang.Compiler.Ast;
  31. public class InternalField : IInternalEntity, IField
  32. {
  33. Field _field;
  34. object _staticValue;
  35. public InternalField(Field field)
  36. {
  37. _field = field;
  38. }
  39. public string Name
  40. {
  41. get
  42. {
  43. return _field.Name;
  44. }
  45. }
  46. public string FullName
  47. {
  48. get
  49. {
  50. return _field.DeclaringType.FullName + "." + _field.Name;
  51. }
  52. }
  53. public bool IsStatic
  54. {
  55. get
  56. {
  57. return _field.IsStatic;
  58. }
  59. }
  60. public bool IsPublic
  61. {
  62. get
  63. {
  64. return _field.IsPublic;
  65. }
  66. }
  67. public bool IsProtected
  68. {
  69. get
  70. {
  71. return _field.IsProtected;
  72. }
  73. }
  74. public bool IsPrivate
  75. {
  76. get
  77. {
  78. return _field.IsPrivate;
  79. }
  80. }
  81. public bool IsInternal
  82. {
  83. get
  84. {
  85. return _field.IsInternal;
  86. }
  87. }
  88. public EntityType EntityType
  89. {
  90. get
  91. {
  92. return EntityType.Field;
  93. }
  94. }
  95. public IType Type
  96. {
  97. get
  98. {
  99. return null != _field.Type
  100. ? TypeSystemServices.GetType(_field.Type)
  101. : Unknown.Default;
  102. }
  103. }
  104. public IType DeclaringType
  105. {
  106. get
  107. {
  108. return (IType)TypeSystemServices.GetEntity(_field.ParentNode);
  109. }
  110. }
  111. public bool IsLiteral
  112. {
  113. get
  114. {
  115. //return IsStatic && IsInitOnly && TypeSystemServices.IsPrimitiveTypeOrString(Type);
  116. return null != _staticValue;
  117. }
  118. }
  119. public bool IsInitOnly
  120. {
  121. get
  122. {
  123. return _field.IsFinal;
  124. }
  125. }
  126. public object StaticValue
  127. {
  128. get
  129. {
  130. return _staticValue;
  131. }
  132. set
  133. {
  134. _staticValue = value;
  135. }
  136. }
  137. public Node Node
  138. {
  139. get
  140. {
  141. return _field;
  142. }
  143. }
  144. public Field Field
  145. {
  146. get
  147. {
  148. return _field;
  149. }
  150. }
  151. override public string ToString()
  152. {
  153. return FullName;
  154. }
  155. public bool IsDuckTyped
  156. {
  157. get { return false; }
  158. }
  159. }
  160. }