MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / emit_fields

Method emit_fields

cranelift/isle/isle/src/codegen.rs:1123–1160  ·  view source on GitHub ↗
(
        &self,
        ctx: &mut BodyContext<W>,
        bindings: &[Option<BindingId>],
        fields: &Fields,
    )

Source from the content-addressed store, hash-verified

1121 }
1122
1123 fn emit_fields<W: Write>(
1124 &self,
1125 ctx: &mut BodyContext<W>,
1126 bindings: &[Option<BindingId>],
1127 fields: &Fields,
1128 ) -> std::fmt::Result {
1129 if !bindings.is_empty() {
1130 ctx.begin_block()?;
1131 let mut skipped_some = false;
1132 for (i, &binding) in bindings.iter().enumerate() {
1133 if let Some(binding) = binding {
1134 let (field_name, field_ty) = match fields {
1135 Fields::Unit => panic!(),
1136 Fields::Struct(fields) => {
1137 let field = &fields.fields[i];
1138 let name = &self.typeenv.syms[field.name.index()];
1139 (Cow::Borrowed(name), field.ty)
1140 }
1141 Fields::Tuple(fields) => (Cow::Owned(format!("{i}")), fields.fields[i].ty),
1142 };
1143 write!(ctx.out, "{}{field_name}: ", &ctx.indent)?;
1144 let (is_ref, _) = self.ty(field_ty);
1145 if is_ref {
1146 ctx.set_ref(binding, true);
1147 write!(ctx.out, "ref ")?;
1148 }
1149 writeln!(ctx.out, "v{},", binding.index())?;
1150 } else {
1151 skipped_some = true;
1152 }
1153 }
1154 if skipped_some {
1155 writeln!(ctx.out, "{}..", &ctx.indent)?;
1156 }
1157 ctx.end_block_without_newline()?;
1158 }
1159 Ok(())
1160 }
1161
1162 fn emit_bool<W: Write>(
1163 &self,

Callers 1

emit_constraintMethod · 0.80

Calls 8

OkFunction · 0.85
begin_blockMethod · 0.80
set_refMethod · 0.80
is_emptyMethod · 0.45
iterMethod · 0.45
indexMethod · 0.45
tyMethod · 0.45

Tested by

no test coverage detected