-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.nim
105 lines (85 loc) · 2.71 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
type GenLang* = enum glNim, glCSharp
template fail() =
assert false
# TODO: change code, so eachone has a distinction of real progress.
template todoimplAdd* =
const pos = instantiationInfo()
const line = $pos.filename & ":" & $pos.line
const warningMsg = "unimplemented(" & "add" & "): " & line
when defined(failFastAdd):
{.error: warningMsg.}
elif defined(stopFastAdd):
{.warning: warningMsg.}
fail
else:
{.warning: warningMsg.}
template todoimplGen* =
const pos = instantiationInfo()
const line = $pos.filename & ":" & $pos.line
const warningMsg = "unimplemented(" & "gen" & "): " & line
when defined(failFastGen):
{.error: warningMsg.}
elif defined(stopFastGen):
{.warning: warningMsg.}
fail
else:
{.warning: warningMsg.}
template todoimpl*(area:string = "") =
const pos = instantiationInfo()
const line = $pos.filename & ":" & $pos.line
const warningMsg = "unimplemented(" & area & "): " & line
when defined(failFast):
{.error: warningMsg.}
elif defined(stopFast):
{.warning: warningMsg.}
fail
else:
{.warning: warningMsg.}
import json
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 CsIdentifier* = ref object of CsObject
type BodyExpr* = ref object of CsObject
ident*:CsIdentifier
ttype*: string
type TypeNameDef* = ref object of BodyExpr # CsObject
method genCs*(e: CsObject): string {.base.} =
echo "--> in genCs*(e: BodyExpr): string {.base.} ="
assert false, e.typ & " does not implement genCs() - fix missing impl"
method genNim*(e: CsObject): string {.base.} =
raise newException(Exception, "Not Implemented for " &
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.