Appearance
| 1 | namespace IR.Values.Call is | |
| 2 | use TypeTyped = Semantic.Types.Typed | |
| 3 | use Semantic.Types.Type | |
| 4 | ||
| 5 | class INNATE: Value, TypeTyped is | |
| 6 | function: Semantic.Symbols.InnateFunction | |
| 7 | from: Value? | |
| 8 | arguments: Collections.List[Value] | |
| 9 | type: Type | |
| 10 | is_lowered: bool | |
| 11 | ||
| 12 | actual_operation: string? public | |
| 13 | ||
| 14 | innate_name: string => function.innate_name | |
| 15 | type_name: string => innate_name.substring(0, innate_name.index_of('.')) | |
| 16 | op_name: string => innate_name.substring(innate_name.index_of('.') + 1) | |
| 17 | ||
| 18 | init( | |
| 19 | function: Semantic.Symbols.InnateFunction, | |
| 20 | from: Value?, | |
| 21 | arguments: Collections.List[Value], | |
| 22 | type: Type?) is | |
| 23 | super.init() | |
| 24 | ||
| 25 | self.function = function | |
| 26 | self.from = from | |
| 27 | self.arguments = arguments | |
| 28 | ||
| 29 | if type? then | |
| 30 | self.type = type | |
| 31 | else | |
| 32 | self.type = function.return_type! | |
| 33 | fi | |
| 34 | si | |
| 35 | ||
| 36 | lower() -> Value is | |
| 37 | assert !is_lowered else "innate operation is already lowered: {self}" | |
| 38 | ||
| 39 | is_lowered = true | |
| 40 | ||
| 41 | let result = IR.Values.BLOCK(type) | |
| 42 | ||
| 43 | IoC.CONTAINER.instance.innate_operation_generator.lower(self, result) | |
| 44 | ||
| 45 | return result | |
| 46 | si | |
| 47 | ||
| 48 | gen(context: CONTEXT) is | |
| 49 | if !is_lowered then | |
| 50 | lower().gen(context) | |
| 51 | fi | |
| 52 | si | |
| 53 | ||
| 54 | to_string() -> string => | |
| 55 | "innate:[{type}](\"{function.name}\",{from},{arguments})" | |
| 56 | si | |
| 57 | si |