From f49c18578aae5fd923bfaf6b7c49c98fb90ac439 Mon Sep 17 00:00:00 2001 From: Shahar Naveh <50263213+ShaharNaveh@users.noreply.github.com> Date: Wed, 3 Dec 2025 14:17:36 +0200 Subject: [PATCH] Move `PrintExpr` to `IntristicFunction1` (#6324) --- crates/codegen/src/compile.rs | 18 ++++++++++++++++-- crates/compiler-core/src/bytecode.rs | 5 +---- crates/vm/src/frame.rs | 21 +++++++-------------- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/crates/codegen/src/compile.rs b/crates/codegen/src/compile.rs index 040571ca3..67f5ddd4d 100644 --- a/crates/codegen/src/compile.rs +++ b/crates/codegen/src/compile.rs @@ -1057,7 +1057,14 @@ impl Compiler { for statement in body { if let Stmt::Expr(StmtExpr { value, .. }) = &statement { self.compile_expression(value)?; - emit!(self, Instruction::PrintExpr); + emit!( + self, + Instruction::CallIntrinsic1 { + func: bytecode::IntrinsicFunction1::Print + } + ); + + emit!(self, Instruction::Pop); } else { self.compile_statement(statement)?; } @@ -1066,7 +1073,14 @@ impl Compiler { if let Stmt::Expr(StmtExpr { value, .. }) = &last { self.compile_expression(value)?; emit!(self, Instruction::CopyItem { index: 1_u32 }); - emit!(self, Instruction::PrintExpr); + emit!( + self, + Instruction::CallIntrinsic1 { + func: bytecode::IntrinsicFunction1::Print + } + ); + + emit!(self, Instruction::Pop); } else { self.compile_statement(last)?; self.emit_load_const(ConstantData::None); diff --git a/crates/compiler-core/src/bytecode.rs b/crates/compiler-core/src/bytecode.rs index 18a3572d1..11d2a7b5f 100644 --- a/crates/compiler-core/src/bytecode.rs +++ b/crates/compiler-core/src/bytecode.rs @@ -551,7 +551,7 @@ op_arg_enum!( #[repr(u8)] pub enum IntrinsicFunction1 { // Invalid = 0, - // Print = 1, + Print = 1, /// Import * operation ImportStar = 2, // StopIterationError = 3, @@ -793,7 +793,6 @@ pub enum Instruction { PopJumpIfTrue { target: Arg