-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dev/aeddi/bft-fixes
- Loading branch information
Showing
19 changed files
with
195 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Package mirror demonstrates that users can pass realm functions | ||
// as arguments to other realms. | ||
package mirror |
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,3 @@ | ||
module gno.land/r/demo/mirror | ||
|
||
require gno.land/p/demo/avl v0.0.0-latest |
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,33 @@ | ||
package mirror | ||
|
||
import ( | ||
"gno.land/p/demo/avl" | ||
) | ||
|
||
var store avl.Tree | ||
|
||
func Register(pkgpath string, rndr func(string) string) { | ||
if store.Has(pkgpath) { | ||
return | ||
} | ||
|
||
if rndr == nil { | ||
return | ||
} | ||
|
||
store.Set(pkgpath, rndr) | ||
} | ||
|
||
func Render(path string) string { | ||
if raw, ok := store.Get(path); ok { | ||
return raw.(func(string) string)("") | ||
} | ||
|
||
if store.Size() == 0 { | ||
return "None are fair." | ||
} | ||
|
||
return "Mirror, mirror on the wall, which realm's the fairest of them all?" | ||
} | ||
|
||
// Credits to @jeronimoalbi |
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
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
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,17 @@ | ||
package main | ||
|
||
func main() { | ||
for i := 0; i < 10; i++ { | ||
if i == 1 { | ||
_ = func() int { | ||
continue | ||
return 11 | ||
}() | ||
} | ||
println(i) | ||
} | ||
println("wat???") | ||
} | ||
|
||
// Error: | ||
// main/files/for21.gno:7:17: continue statement out of place |
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,17 @@ | ||
package main | ||
|
||
func main() { | ||
for i := 0; i < 10; i++ { | ||
if i == 1 { | ||
_ = func() int { | ||
fallthrough | ||
return 11 | ||
}() | ||
} | ||
println(i) | ||
} | ||
println("wat???") | ||
} | ||
|
||
// Error: | ||
// main/files/for22.gno:7:17: fallthrough statement out of place |
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,17 @@ | ||
package main | ||
|
||
func main() { | ||
for i := 0; i < 10; i++ { | ||
if i == 1 { | ||
_ = func() int { | ||
break | ||
return 11 | ||
}() | ||
} | ||
println(i) | ||
} | ||
println("wat???") | ||
} | ||
|
||
// Error: | ||
// main/files/for23.gno:7:17: break statement out of place |
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,19 @@ | ||
package main | ||
|
||
func main() { | ||
for i := 0; i < 10; i++ { | ||
if i == 1 { | ||
_ = func() int { | ||
if true { | ||
break | ||
} | ||
return 11 | ||
}() | ||
} | ||
println(i) | ||
} | ||
println("wat???") | ||
} | ||
|
||
// Error: | ||
// main/files/for24.gno:8:21: break statement out of place |
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
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