This repository has been archived by the owner on Jul 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.nim
76 lines (60 loc) · 1.82 KB
/
types.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# types.nim
# import tables
import json
# pass this object instead of many arguments
# to create the same api.
type Info* = ref object
declName*: string
essentials*: seq[string]
extras*: seq[string]
rawKind*, parentRawKind*: int
import strutils
proc `$`*(info: Info): string =
let x = [info.declName, $info.essentials, $info.extras]
result = "Info: " & x.join(";; ")
import uuids, options
type CsObject* = ref object of RootRef
name*: string
typ*: string
id*: Option[UUID]
parentId*: Option[UUID]
# line*: JsonNode
src*: string
isComplete*: bool
rawKind*, parentRawKind*: int
# type Dummy* = ref object of CsObject
type Module* = object
name*: string
output*: string
proc jsonWithoutSource*(n: JsonNode): JsonNode =
var p = n.deepCopy
p.delete("Source")
result = p
# for constructs in a method body.
type BodyExpr* = ref object of CsObject # RootObj
# name*: string
ttype*: string
method gen*(e: BodyExpr): string {.base.} =
raise newException(Exception, "Not Implemented for " & e.ttype & " " &
e.typ) #& " " & e.name)
# # possibly redundant. haven't yet used:
# type CConstruct* = concept T, Parent
# proc add*(parent: var Parent; item: T; data: AllNeededData)
# proc add*(parent: var Parent; item: T)
# proc extract*(t: typedesc[T]; info: Info): T
# proc newCs*(t: typedesc[T]; a, b, c, d: auto): T
# # proc handle*(t: typedesc[T]; root: var CsRoot; info: Info)
# # will it create a circular dependency? maybe. try.
template fail() =
assert false
template todoimpl* =
const pos = instantiationInfo()
const line = $pos.filename & ":" & $pos.line
const warningMsg = "unimplemented: " & line
when defined(failFast):
{.error: warningMsg.}
elif defined(stopFast):
{.warning: warningMsg.}
fail
else:
{.warning: warningMsg.}