From 70c3bf468be393d6bd7c35331cdda5864c9acf83 Mon Sep 17 00:00:00 2001 From: ShaharNaveh <50263213+ShaharNaveh@users.noreply.github.com> Date: Tue, 2 Dec 2025 17:58:13 +0200 Subject: [PATCH 1/2] Move `PrintExpr` to `IntristicFunction1` --- crates/codegen/src/compile.rs | 18 ++++++++++++++++-- crates/compiler-core/src/bytecode.rs | 6 +----- crates/vm/src/frame.rs | 21 +++++++-------------- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/crates/codegen/src/compile.rs b/crates/codegen/src/compile.rs index e8dc269dca..c080593308 100644 --- a/crates/codegen/src/compile.rs +++ b/crates/codegen/src/compile.rs @@ -1056,7 +1056,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)?; } @@ -1065,7 +1072,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 d1482b8c8a..6657bd6ad0 100644 --- a/crates/compiler-core/src/bytecode.rs +++ b/crates/compiler-core/src/bytecode.rs @@ -511,7 +511,7 @@ op_arg_enum!( #[repr(u8)] pub enum IntrinsicFunction1 { // Invalid = 0, - // Print = 1, + Print = 1, /// Import * operation ImportStar = 2, // StopIterationError = 3, @@ -727,8 +727,6 @@ pub enum Instruction { PopJumpIfTrue { target: Arg