Appearance
| 1 | namespace Semantic.Types is | |
| 2 | use Source.LOCATION; | |
| 3 | ||
| 4 | use Ghul.Pipes; | |
| 5 | ||
| 6 | class FUNCTION: GENERIC is | |
| 7 | is_function: bool => true; | |
| 8 | ||
| 9 | short_description: string => get_short_description(self); | |
| 10 | ||
| 11 | get_short_description(function: GENERIC) -> string static is | |
| 12 | let result = System.Text.StringBuilder(); | |
| 13 | ||
| 14 | let args = function.arguments; | |
| 15 | ||
| 16 | if args.count == 2 then | |
| 17 | result | |
| 18 | .append(args[0]) | |
| 19 | .append(" -> ") | |
| 20 | .append(args[1]); | |
| 21 | elif args.count == 1 then | |
| 22 | result | |
| 23 | .append("() -> ") | |
| 24 | .append(args[0]); | |
| 25 | else | |
| 26 | result.append('('); | |
| 27 | ||
| 28 | (0..args.count-1) |> map(i => args[i]) |> append_to(result); | |
| 29 | ||
| 30 | result | |
| 31 | .append(") -> ") | |
| 32 | .append(args[args.count-1]); | |
| 33 | fi | |
| 34 | ||
| 35 | return result.to_string(); | |
| 36 | si | |
| 37 | ||
| 38 | init( | |
| 39 | location: LOCATION, | |
| 40 | symbol: Symbols.Classy, | |
| 41 | arguments: Collections.List[Type] | |
| 42 | ) is | |
| 43 | super.init(location, symbol, arguments); | |
| 44 | si | |
| 45 | ||
| 46 | get_argument_type_variance(index: int) -> TypeVariance => | |
| 47 | if index == arguments.count - 1 then | |
| 48 | TypeVariance.COVARIANT; | |
| 49 | else | |
| 50 | TypeVariance.CONTRAVARIANT; | |
| 51 | fi; | |
| 52 | ||
| 53 | create( | |
| 54 | location: LOCATION, | |
| 55 | symbol: Symbols.Classy, | |
| 56 | arguments: Collections.List[Type] | |
| 57 | ) -> GENERIC => | |
| 58 | FUNCTION(location, symbol, arguments); | |
| 59 | ||
| 60 | to_string() -> string => get_short_description(self); | |
| 61 | si | |
| 62 | si |