hti.nim 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #
  2. #
  3. # Nim's Runtime Library
  4. # (c) Copyright 2012 Andreas Rumpf
  5. #
  6. # See the file "copying.txt", included in this
  7. # distribution, for details about the copyright.
  8. #
  9. type
  10. # This should be the same as ast.TTypeKind
  11. # many enum fields are not used at runtime
  12. TNimKind = enum
  13. tyNone,
  14. tyBool,
  15. tyChar,
  16. tyEmpty,
  17. tyArrayConstr,
  18. tyNil,
  19. tyUntyped,
  20. tyTyped,
  21. tyTypeDesc,
  22. tyGenericInvocation, # ``T[a, b]`` for types to invoke
  23. tyGenericBody, # ``T[a, b, body]`` last parameter is the body
  24. tyGenericInst, # ``T[a, b, realInstance]`` instantiated generic type
  25. tyGenericParam, # ``a`` in the example
  26. tyDistinct, # distinct type
  27. tyEnum,
  28. tyOrdinal,
  29. tyArray,
  30. tyObject,
  31. tyTuple, # WARNING: The compiler uses tyTuple for pure objects!
  32. tySet,
  33. tyRange,
  34. tyPtr,
  35. tyRef,
  36. tyVar,
  37. tySequence,
  38. tyProc,
  39. tyPointer,
  40. tyOpenArray,
  41. tyString,
  42. tyCstring,
  43. tyForward,
  44. tyInt,
  45. tyInt8,
  46. tyInt16,
  47. tyInt32,
  48. tyInt64,
  49. tyFloat,
  50. tyFloat32,
  51. tyFloat64,
  52. tyFloat128,
  53. tyUInt,
  54. tyUInt8,
  55. tyUInt16,
  56. tyUInt32,
  57. tyUInt64,
  58. tyOwned, tyUnused1, tyUnused2,
  59. tyVarargsHidden,
  60. tyUncheckedArray,
  61. tyProxyHidden,
  62. tyBuiltInTypeClassHidden,
  63. tyUserTypeClassHidden,
  64. tyUserTypeClassInstHidden,
  65. tyCompositeTypeClassHidden,
  66. tyInferredHidden,
  67. tyAndHidden, tyOrHidden, tyNotHidden,
  68. tyAnythingHidden,
  69. tyStaticHidden,
  70. tyFromExprHidden,
  71. tyOptDeprecated,
  72. tyVoidHidden
  73. TNimNodeKind = enum nkNone, nkSlot, nkList, nkCase
  74. TNimNode {.compilerproc.} = object
  75. kind: TNimNodeKind
  76. offset: int
  77. typ: ptr TNimType
  78. name: cstring
  79. len: int
  80. sons: ptr array[0x7fff, ptr TNimNode]
  81. TNimTypeFlag = enum
  82. ntfNoRefs = 0, # type contains no tyRef, tySequence, tyString
  83. ntfAcyclic = 1, # type cannot form a cycle
  84. ntfEnumHole = 2 # enum has holes and thus `$` for them needs the slow
  85. # version
  86. TNimType {.compilerproc.} = object
  87. when defined(gcHooks):
  88. head*: pointer
  89. size*: int
  90. align*: int
  91. kind: TNimKind
  92. flags: set[TNimTypeFlag]
  93. base*: ptr TNimType
  94. node: ptr TNimNode # valid for tyRecord, tyObject, tyTuple, tyEnum
  95. finalizer*: pointer # the finalizer for the type
  96. marker*: proc (p: pointer, op: int) {.nimcall, benign, tags: [], raises: [].} # marker proc for GC
  97. deepcopy: proc (p: pointer): pointer {.nimcall, benign, tags: [], raises: [].}
  98. when defined(nimSeqsV2):
  99. typeInfoV2*: pointer
  100. when defined(nimTypeNames):
  101. name: cstring
  102. nextType: ptr TNimType
  103. instances: int # count the number of instances
  104. sizes: int # sizes of all instances in bytes
  105. when defined(gcHooks):
  106. type
  107. PNimType* = ptr TNimType
  108. else:
  109. type
  110. PNimType = ptr TNimType
  111. when defined(nimTypeNames):
  112. # Declare this variable only once in system.nim
  113. when declared(ThisIsSystem):
  114. var nimTypeRoot {.compilerproc.}: PNimType
  115. else:
  116. var nimTypeRoot {.importc.}: PNimType
  117. # node.len may be the ``first`` element of a set