MCPcopy Index your code
hub / github.com/RustPython/RustPython / compile_delete

Method compile_delete

crates/codegen/src/compile.rs:2758–2785  ·  view source on GitHub ↗
(&mut self, expression: &ast::Expr)

Source from the content-addressed store, hash-verified

2756 }
2757
2758 fn compile_delete(&mut self, expression: &ast::Expr) -> CompileResult<()> {
2759 match &expression {
2760 ast::Expr::Name(ast::ExprName { id, .. }) => {
2761 self.compile_name(id.as_str(), NameUsage::Delete)?
2762 }
2763 ast::Expr::Attribute(ast::ExprAttribute { value, attr, .. }) => {
2764 self.compile_expression(value)?;
2765 let namei = self.name(attr.as_str());
2766 emit!(self, Instruction::DeleteAttr { namei });
2767 }
2768 ast::Expr::Subscript(ast::ExprSubscript {
2769 value, slice, ctx, ..
2770 }) => {
2771 self.compile_subscript(value, slice, *ctx)?;
2772 }
2773 ast::Expr::Tuple(ast::ExprTuple { elts, .. })
2774 | ast::Expr::List(ast::ExprList { elts, .. }) => {
2775 for element in elts {
2776 self.compile_delete(element)?;
2777 }
2778 }
2779 ast::Expr::BinOp(_) | ast::Expr::UnaryOp(_) => {
2780 return Err(self.error(CodegenErrorType::Delete("expression")));
2781 }
2782 _ => return Err(self.error(CodegenErrorType::Delete(expression.python_name()))),
2783 }
2784 Ok(())
2785 }
2786
2787 fn enter_function(&mut self, name: &str, parameters: &ast::Parameters) -> CompileResult<()> {
2788 // TODO: partition_in_place

Callers 1

compile_statementMethod · 0.80

Calls 8

compile_nameMethod · 0.80
compile_expressionMethod · 0.80
compile_subscriptMethod · 0.80
python_nameMethod · 0.80
ErrClass · 0.50
as_strMethod · 0.45
nameMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected