hti.nim 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. tyOpt,
  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. size: int
  88. kind: TNimKind
  89. flags: set[TNimTypeFlag]
  90. base: ptr TNimType
  91. node: ptr TNimNode # valid for tyRecord, tyObject, tyTuple, tyEnum
  92. finalizer: pointer # the finalizer for the type
  93. marker: proc (p: pointer, op: int) {.nimcall, benign.} # marker proc for GC
  94. deepcopy: proc (p: pointer): pointer {.nimcall, benign.}
  95. when defined(nimTypeNames):
  96. name: cstring
  97. nextType: ptr TNimType
  98. instances: int # count the number of instances
  99. sizes: int # sizes of all instances in bytes
  100. PNimType = ptr TNimType
  101. when defined(nimTypeNames):
  102. # Declare this variable only once in system.nim
  103. when declared(ThisIsSystem):
  104. var nimTypeRoot {.compilerProc.}: PNimType
  105. else:
  106. var nimTypeRoot {.importc.}: PNimType
  107. # node.len may be the ``first`` element of a set