From 432e7a7dddf56224297285c9f47f0aa3963eb5b5 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 2 Mar 2021 13:11:21 +0200 Subject: feat(tazjin/rlox): Intern all string constants This is again a step closer to the book, but there are some notable differences: * Only constants encountered by the compiler are interned, all other string operations (well, concatenation) happen with heap objects. * OpReturn will always ensure that a returned string value is newly heap allocated and does not reference the interner. Change-Id: If4f04309446e01b8ff2db51094e9710d465dbc50 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2582 Reviewed-by: tazjin Tested-by: BuildkiteCI --- users/tazjin/rlox/src/bytecode/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'users/tazjin/rlox/src/bytecode/mod.rs') diff --git a/users/tazjin/rlox/src/bytecode/mod.rs b/users/tazjin/rlox/src/bytecode/mod.rs index b3e0966fa071..c6f3a737aef8 100644 --- a/users/tazjin/rlox/src/bytecode/mod.rs +++ b/users/tazjin/rlox/src/bytecode/mod.rs @@ -27,7 +27,7 @@ impl crate::Lox for Interpreter { &mut self, code: String, ) -> Result> { - let chunk = compiler::compile(&code)?; - vm::interpret(chunk).map_err(|e| vec![e]) + let (strings, chunk) = compiler::compile(&code)?; + vm::interpret(strings, chunk).map_err(|e| vec![e]) } } -- cgit 1.4.1