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.arguments = arguments; | |
| 27 | ||
| 28 | if type? then | |
| 29 | self.type = type; | |
| 30 | else | |
| 31 | self.type = function.return_type!; | |
| 32 | fi | |
| 33 | si | |
| 34 | ||
| 35 | lower() -> Value is | |
| 36 | assert !is_lowered else "innate operation is already lowered: {self}"; | |
| 37 | ||
| 38 | is_lowered = true; | |
| 39 | ||
| 40 | let result = IR.Values.BLOCK(type); | |
| 41 | ||
| 42 | IoC.CONTAINER.instance.innate_operation_generator.lower(self, result); | |
| 43 | ||
| 44 | return result; | |
| 45 | si | |
| 46 | ||
| 47 | gen(context: CONTEXT) is | |
| 48 | if !is_lowered then | |
| 49 | lower().gen(context); | |
| 50 | fi | |
| 51 | si | |
| 52 | ||
| 53 | to_string() -> string => | |
| 54 | "innate:[{type}](\"{function.name}\",{from},{arguments})"; | |
| 55 | si | |
| 56 | si |