22 lines
495 B
Nim
22 lines
495 B
Nim
# generic object type
|
|
|
|
import ../config
|
|
|
|
type
|
|
NdObjectKind* = enum
|
|
noInvalid, noString, noClosure, noUpvalue, noList, noTable
|
|
NdObject* = object of RootObj
|
|
kind*: NdObjectKind
|
|
isMarked*: bool
|
|
nextObj*: ptr NdObject
|
|
|
|
var objects*: ptr NdObject
|
|
|
|
template newObject*(obj: ptr NdObject) =
|
|
when assertionsVM:
|
|
if obj.kind == noInvalid:
|
|
raise newException(Defect, "Somewhere an object with invalid object type was created.")
|
|
|
|
obj.nextObj = objects
|
|
objects = obj
|
|
|