MCPcopy Create free account
hub / github.com/explodingcamera/tinywasm / visit_local_tee

Method visit_local_tee

crates/parser/src/visit.rs:232–268  ·  view source on GitHub ↗
(&mut self, idx: u32)

Source from the content-addressed store, hash-verified

230 }
231
232 fn visit_local_tee(&mut self, idx: u32) -> Self::Output {
233 let resolved_idx = self.local_addr_map[idx as usize];
234 if let Some(Some(t)) = self.validator.get_operand_type(0) {
235 let size = operand_size(t);
236 let last = self.instructions.last();
237 let src = match (size, last) {
238 (OperandSize::S32, Some(Instruction::LocalGet32(src))) => Some(*src),
239 (OperandSize::S64, Some(Instruction::LocalGet64(src))) => Some(*src),
240 (OperandSize::S128, Some(Instruction::LocalGet128(src))) => Some(*src),
241 _ => None,
242 };
243
244 if let Some(src) = src {
245 self.instructions.pop();
246 match size {
247 OperandSize::S32 => {
248 self.instructions.push(Instruction::LocalCopy32(src, resolved_idx));
249 self.instructions.push(Instruction::LocalGet32(resolved_idx));
250 }
251 OperandSize::S64 => {
252 self.instructions.push(Instruction::LocalCopy64(src, resolved_idx));
253 self.instructions.push(Instruction::LocalGet64(resolved_idx));
254 }
255 OperandSize::S128 => {
256 self.instructions.push(Instruction::LocalCopy128(src, resolved_idx));
257 self.instructions.push(Instruction::LocalGet128(resolved_idx));
258 }
259 }
260 } else {
261 self.instructions.push(match size {
262 OperandSize::S32 => Instruction::LocalTee32(resolved_idx),
263 OperandSize::S64 => Instruction::LocalTee64(resolved_idx),
264 OperandSize::S128 => Instruction::LocalTee128(resolved_idx),
265 })
266 }
267 }
268 }
269
270 fn visit_block(&mut self, _blockty: wasmparser::BlockType) -> Self::Output {
271 let start_ip = self.instructions.len();

Callers

nothing calls this directly

Calls 4

operand_sizeFunction · 0.85
popMethod · 0.80
lastMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected