refactor(tvix/value): hide internal string representation
Wraps the string representation in an additional newtype struct with a private field in order to hide the representation from other modules. This is done in order to avoid accidental leakage of the internals outside of value::string. In fact, this caught a mistake in the compiler module which was directly constructing an internal variant. Change-Id: If4b627d3cff7ab9cd50ca1a3ac73245d4dcf7aef Reviewed-on: https://cl.tvl.fyi/c/depot/+/6147 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
a0cbc78a83
commit
2422f2f224
2 changed files with 16 additions and 13 deletions
|
|
@ -4,7 +4,7 @@
|
|||
use crate::chunk::Chunk;
|
||||
use crate::errors::EvalResult;
|
||||
use crate::opcode::OpCode;
|
||||
use crate::value::{NixString, Value};
|
||||
use crate::value::Value;
|
||||
|
||||
use rnix;
|
||||
use rnix::types::{EntryHolder, TokenWrapper, TypedNode, Wrapper};
|
||||
|
|
@ -221,9 +221,9 @@ impl Compiler {
|
|||
let ident = rnix::types::Ident::cast(fragment).unwrap();
|
||||
|
||||
// TODO(tazjin): intern!
|
||||
let idx = self.chunk.add_constant(Value::String(NixString::Heap(
|
||||
ident.as_str().to_string(),
|
||||
)));
|
||||
let idx = self
|
||||
.chunk
|
||||
.add_constant(Value::String(ident.as_str().to_string().into()));
|
||||
self.chunk.add_op(OpCode::OpConstant(idx));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue