-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inline generic structural/alias types (#350)
* inline structural/alias invocations even with generic arguments, broken * don't generate in output, could clean up later * update comments * fix generic object constructors * update tdefault output * update trecursiveobj
- Loading branch information
Showing
6 changed files
with
173 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
(.nif24) | ||
,1,tests/nimony/basics/tgenericbinarytree.nim(stmts 5 | ||
(type :int.0.tge0lah6v | ||
(i -1) . 5 | ||
(pragmas 2 | ||
(magic 7 Int)) .) 10,3 | ||
(type ~8 :Node.0.tge0lah6v . ~4 | ||
(typevars 1 | ||
(typevar :T.0.tge0lah6v . . . .)) . 2 | ||
(ref 11 | ||
(at ~7 NodeObj.0.tge0lah6v 1 T.0.tge0lah6v))) 13,4 | ||
(type ~11 :NodeObj.0.tge0lah6v . ~4 | ||
(typevars 1 | ||
(typevar :T.1.tge0lah6v . . . .)) . 2 | ||
(object . ~11,1 | ||
(fld :data.0.tge0lah6v . . 6 T.1.tge0lah6v .) ~11,2 | ||
(fld :left.0.tge0lah6v . . 8,~3 | ||
(ref 11 | ||
(at ~7 NodeObj.0.tge0lah6v ~1,3 T.1.tge0lah6v)) .) ~5,2 | ||
(fld :right.0.tge0lah6v . . 2,~3 | ||
(ref 11 | ||
(at ~7 NodeObj.0.tge0lah6v ~1,3 T.1.tge0lah6v)) .))) 4,8 | ||
(var :x.0.tge0lah6v . . 8,~5 | ||
(ref 11 NodeObj.1.tge0lah6v) 13 | ||
(obj ~5,~5 | ||
(ref 11 NodeObj.1.tge0lah6v) 5 | ||
(kv ~5 data.1.tge0lah6v 2 +123) 16 | ||
(kv ~16 left.1.tge0lah6v 2 | ||
(nil)) 28 | ||
(kv ~28 right.1.tge0lah6v 2 | ||
(nil)))) 7,9 | ||
(asgn ~6 | ||
(dot ~1 x.0.tge0lah6v data.1.tge0lah6v +0) 2 +456) 7,10 | ||
(asgn ~6 | ||
(dot ~1 x.0.tge0lah6v left.1.tge0lah6v +0) 11 | ||
(obj ~6,~7 | ||
(ref 11 NodeObj.1.tge0lah6v) 5 | ||
(kv ~5 data.1.tge0lah6v 2 +123) 16 | ||
(kv ~16 left.1.tge0lah6v 2 | ||
(nil)) 28 | ||
(kv ~28 right.1.tge0lah6v 2 | ||
(nil)))) 8,11 | ||
(asgn ~7 | ||
(dot ~1 x.0.tge0lah6v right.1.tge0lah6v +0) 2 | ||
(nil)) 13,12 | ||
(asgn ~7 | ||
(dot ~5 | ||
(dot ~1 x.0.tge0lah6v left.1.tge0lah6v +0) right.1.tge0lah6v +0) 2 | ||
(nil)) 4,13 | ||
(var :y.0.tge0lah6v . . 8,~10 | ||
(ref 11 NodeObj.1.tge0lah6v) 13 | ||
(obj ~5,~10 | ||
(ref 11 NodeObj.1.tge0lah6v) 5 | ||
(kv ~5 data.1.tge0lah6v 2 +987) 16 | ||
(kv ~16 left.1.tge0lah6v 2 | ||
(nil)) 28 | ||
(kv ~28 right.1.tge0lah6v 2 | ||
(nil)))) 12,14 | ||
(asgn ~6 | ||
(dot ~5 | ||
(dot ~1 x.0.tge0lah6v left.1.tge0lah6v +0) left.1.tge0lah6v +0) 11 | ||
(obj ~11,~11 | ||
(ref 11 NodeObj.1.tge0lah6v) 5 | ||
(kv ~5 data.1.tge0lah6v 2 -123) 17 | ||
(kv ~17 left.1.tge0lah6v 2 y.0.tge0lah6v) 27 | ||
(kv ~27 right.1.tge0lah6v 2 y.0.tge0lah6v))) ,16 | ||
(proc 5 :foo.0.tge0lah6v . . 8 | ||
(typevars 1 | ||
(typevar :T.2.tge0lah6v . . . .)) 11 | ||
(params 1 | ||
(param :data.0 . . 6 T.2.tge0lah6v .)) 12,~13 | ||
(ref 11 | ||
(at ~7 NodeObj.0.tge0lah6v ~7,13 T.2.tge0lah6v)) . . 2,1 | ||
(stmts 7 | ||
(result :result.0 . . 3,~14 | ||
(ref 11 | ||
(at ~7 NodeObj.0.tge0lah6v ~7,13 T.2.tge0lah6v)) .) 7 | ||
(asgn ~7 result.0 9 | ||
(obj ~6,~14 | ||
(ref 11 | ||
(at ~7 NodeObj.0.tge0lah6v ~7,13 T.2.tge0lah6v)) 5 | ||
(kv ~5 data 2 data.0) 17 | ||
(kv ~17 left 2 | ||
(nil)) 29 | ||
(kv ~29 right 2 | ||
(nil)))) 12,1 | ||
(asgn ~6 | ||
(dot ~6 result.0 data.0.tge0lah6v +0) 2 data.0) ~2,~1 | ||
(ret result.0))) 4,19 | ||
(let :a.0.tge0lah6v . . 8,~16 | ||
(ref 11 NodeObj.1.tge0lah6v) 7 | ||
(call ~3 foo.1.tge0lah6v 1 +123)) 2,20 | ||
(asgn ~2 x.0.tge0lah6v 2 a.0.tge0lah6v) 11,19 | ||
(proc :foo.1.tge0lah6v . ~11,~3 . | ||
(at foo.0.tge0lah6v | ||
(i -1)) ,~3 | ||
(params 1 | ||
(param :data.2 . . | ||
(i -1) .)) 1,~16 | ||
(ref 11 NodeObj.1.tge0lah6v) ~11,~3 . ~11,~3 . ~9,~2 | ||
(stmts 7 | ||
(result :result.1 . . 3,~14 | ||
(ref 11 NodeObj.1.tge0lah6v) .) 7 | ||
(asgn ~7 result.1 9 | ||
(obj ~6,~14 | ||
(ref 11 NodeObj.1.tge0lah6v) 5 | ||
(kv ~5 data.1.tge0lah6v 2 data.2) 17 | ||
(kv ~17 left.1.tge0lah6v 2 | ||
(nil)) 29 | ||
(kv ~29 right.1.tge0lah6v 2 | ||
(nil)))) 12,1 | ||
(asgn ~6 | ||
(dot ~6 result.1 data.1.tge0lah6v +0) 2 data.2) ~2,~1 | ||
(ret result.1))) 12,8 | ||
(type :Node.4.tge0lah6v . | ||
(at Node.0.tge0lah6v ~7,~8 | ||
(i -1)) ~2,~5 . ,~5 | ||
(ref 11 NodeObj.1.tge0lah6v)) 23,3 | ||
(type :NodeObj.1.tge0lah6v . | ||
(at NodeObj.0.tge0lah6v ~18,~3 | ||
(i -1)) ~10,1 . ~8,1 | ||
(object . ~11,1 | ||
(fld :data.1.tge0lah6v . . 1,~5 | ||
(i -1) .) ~11,2 | ||
(fld :left.1.tge0lah6v . . 8,~3 | ||
(ref 11 NodeObj.1.tge0lah6v) .) ~5,2 | ||
(fld :right.1.tge0lah6v . . 2,~3 | ||
(ref 11 NodeObj.1.tge0lah6v) .)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
type int* {.magic: Int.} | ||
|
||
type | ||
Node[T] = ref NodeObj[T] | ||
NodeObj[T] = object | ||
data: T | ||
left, right: Node[T] | ||
|
||
var x = Node[int](data: 123, left: nil, right: nil) | ||
x.data = 456 | ||
x.left = Node[int](data: 123, left: nil, right: nil) | ||
x.right = nil | ||
x.left.right = nil | ||
var y = Node[int](data: 987, left: nil, right: nil) | ||
x.left.left = Node[int](data: -123, left: y, right: y) | ||
|
||
proc foo[T](data: T): Node[T] = | ||
result = Node[T](data: data, left: nil, right: nil) | ||
result.data = data | ||
let a = foo(123) | ||
x = a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters