about summary refs log tree commit diff
path: root/users/tazjin/rlox/src/bytecode/value.rs
diff options
context:
space:
mode:
Diffstat (limited to 'users/tazjin/rlox/src/bytecode/value.rs')
-rw-r--r--users/tazjin/rlox/src/bytecode/value.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/users/tazjin/rlox/src/bytecode/value.rs b/users/tazjin/rlox/src/bytecode/value.rs
index c6667a698e..19a4dcc92e 100644
--- a/users/tazjin/rlox/src/bytecode/value.rs
+++ b/users/tazjin/rlox/src/bytecode/value.rs
@@ -1,9 +1,29 @@
+use super::interner::InternedStr;
+
 #[derive(Clone, Debug, PartialEq)]
 pub enum Value {
     Nil,
     Bool(bool),
     Number(f64),
-    String(String),
+    String(LoxString),
+}
+
+#[derive(Clone, Debug, PartialEq)]
+pub enum LoxString {
+    Heap(String),
+    Interned(InternedStr),
+}
+
+impl From<String> for LoxString {
+    fn from(s: String) -> Self {
+        LoxString::Heap(s)
+    }
+}
+
+impl From<InternedStr> for LoxString {
+    fn from(s: InternedStr) -> Self {
+        LoxString::Interned(s)
+    }
 }
 
 impl Value {