2020-08-27 16:00:44 +03:00
|
|
|
struct App {}
|
2020-07-25 01:02:44 +03:00
|
|
|
|
2020-08-27 16:00:44 +03:00
|
|
|
fn (mut app App) method_one() {}
|
2021-04-20 17:16:35 +03:00
|
|
|
|
|
|
|
fn (mut app App) method_two() int {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
fn (mut app App) method_three(s string) string {
|
|
|
|
return s
|
|
|
|
}
|
2020-07-25 01:02:44 +03:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
$for method in App.methods {
|
2021-04-20 17:16:35 +03:00
|
|
|
$if method.typ is fn (string) string {
|
2022-11-15 16:53:13 +03:00
|
|
|
println('${method.name} IS `fn(string) string`')
|
2020-08-27 16:00:44 +03:00
|
|
|
} $else {
|
2022-11-15 16:53:13 +03:00
|
|
|
println('${method.name} is NOT `fn(string) string`')
|
2020-07-25 01:02:44 +03:00
|
|
|
}
|
2020-09-28 07:13:38 +03:00
|
|
|
$if method.return_type !is int {
|
2022-11-15 16:53:13 +03:00
|
|
|
println('${method.name} does NOT return `int`')
|
2020-08-27 16:00:44 +03:00
|
|
|
} $else {
|
2022-11-15 16:53:13 +03:00
|
|
|
println('${method.name} DOES return `int`')
|
2020-07-25 01:02:44 +03:00
|
|
|
}
|
2020-09-28 07:13:38 +03:00
|
|
|
$if method.args[0].typ !is string {
|
2022-11-15 16:53:13 +03:00
|
|
|
println("${method.name}'s first arg is NOT `string`")
|
2020-08-27 16:00:44 +03:00
|
|
|
} $else {
|
2022-11-15 16:53:13 +03:00
|
|
|
println("${method.name}'s first arg IS `string`")
|
2020-08-27 16:00:44 +03:00
|
|
|
}
|
|
|
|
// TODO: Double inversion, should this even be allowed?
|
2021-04-20 17:16:35 +03:00
|
|
|
$if method.typ is fn () {
|
2022-11-15 16:53:13 +03:00
|
|
|
println('${method.name} IS a void method')
|
2020-08-27 16:00:44 +03:00
|
|
|
} $else {
|
2022-11-15 16:53:13 +03:00
|
|
|
println('${method.name} is NOT a void method')
|
2020-08-27 16:00:44 +03:00
|
|
|
}
|
|
|
|
println('')
|
2020-07-25 01:02:44 +03:00
|
|
|
}
|
|
|
|
}
|