(ctx: &mut Context, sdef: &StructDefinition)
| 177 | } |
| 178 | |
| 179 | fn write_struct_def(ctx: &mut Context, sdef: &StructDefinition) -> String { |
| 180 | let mut out = String::new(); |
| 181 | |
| 182 | let shandle = ctx.module.struct_handle_at(sdef.struct_handle); |
| 183 | |
| 184 | push_line!( |
| 185 | out, |
| 186 | format!( |
| 187 | " struct {}{}{} {{", |
| 188 | ctx.module.identifier_at(shandle.name), |
| 189 | write_struct_type_parameters(&shandle.type_parameters), |
| 190 | write_ability_modifiers(shandle.abilities), |
| 191 | ) |
| 192 | ); |
| 193 | |
| 194 | let fields = match &sdef.field_information { |
| 195 | StructFieldInformation::Native => { |
| 196 | push!(out, " }"); |
| 197 | return out; |
| 198 | } |
| 199 | StructFieldInformation::Declared(fields) => fields, |
| 200 | }; |
| 201 | for field in fields { |
| 202 | push_line!( |
| 203 | out, |
| 204 | format!( |
| 205 | " {}: {},", |
| 206 | ctx.module.identifier_at(field.name), |
| 207 | write_signature_token(ctx, &field.signature.0), |
| 208 | ) |
| 209 | ) |
| 210 | } |
| 211 | |
| 212 | push!(out, " }"); |
| 213 | out |
| 214 | } |
| 215 | |
| 216 | fn write_function_def(ctx: &mut Context, fdef: &FunctionDefinition) -> String { |
| 217 | let fhandle = ctx.module.function_handle_at(fdef.function); |
no test coverage detected