MCPcopy Create free account
hub / github.com/diem/move / write_struct_def

Function write_struct_def

language/move-compiler/src/interface_generator.rs:179–214  ·  view source on GitHub ↗
(ctx: &mut Context, sdef: &StructDefinition)

Source from the content-addressed store, hash-verified

177}
178
179fn 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
216fn write_function_def(ctx: &mut Context, fdef: &FunctionDefinition) -> String {
217 let fhandle = ctx.module.function_handle_at(fdef.function);

Callers 1

write_module_to_stringFunction · 0.85

Calls 1

struct_handle_atMethod · 0.45

Tested by

no test coverage detected