Appearance
| 1 | namespace IR.Values.Call is | |
| 2 | use TypeTyped = Semantic.Types.Typed | |
| 3 | use Semantic.Types.Type | |
| 4 | ||
| 5 | class STATIC: Value, TypeTyped is | |
| 6 | is_state_changing_call: bool => !function.is_store_free | |
| 7 | function: Semantic.Symbols.Function | |
| 8 | arguments: Collections.List[Value] | |
| 9 | type: Type | |
| 10 | ||
| 11 | // The type a static interface member is dispatched through, | |
| 12 | // when it needs the CLR's `constrained.` prefix; null | |
| 13 | // otherwise. A bound type parameter where the call is generic, | |
| 14 | // and the concrete type where the interface is instantiated at | |
| 15 | // one. | |
| 16 | constrained_receiver: Type? | |
| 17 | ||
| 18 | init(function: Semantic.Symbols.Function, arguments: Collections.List[Value], type: Type?, constrained_receiver: Type?) is | |
| 19 | super.init() | |
| 20 | ||
| 21 | self.function = function | |
| 22 | self.arguments = arguments | |
| 23 | self.constrained_receiver = constrained_receiver | |
| 24 | ||
| 25 | if type? then | |
| 26 | self.type = type | |
| 27 | else | |
| 28 | self.type = function.return_type! | |
| 29 | fi | |
| 30 | si | |
| 31 | ||
| 32 | gen(context: IR.CONTEXT) is | |
| 33 | for a in arguments do | |
| 34 | gen(a, context) | |
| 35 | od | |
| 36 | ||
| 37 | let body = context.current_srm_body_emitter! | |
| 38 | if let receiver = constrained_receiver then | |
| 39 | body.constrained(context.resolve_type_token(receiver)) | |
| 40 | fi | |
| 41 | ||
| 42 | body.call(context.resolve_call_target(function)) | |
| 43 | si | |
| 44 | ||
| 45 | to_string() -> string => | |
| 46 | "static-call:[{type}](\"{function.name}\",{arguments})" | |
| 47 | si | |
| 48 | si |