Interning Orchid string literals

This commit is contained in:
2023-08-19 14:35:24 +01:00
parent 0b887ced70
commit 6693d93944
10 changed files with 96 additions and 29 deletions

View File

@@ -4,6 +4,7 @@ use super::instances::{
};
use crate::foreign::cps_box::init_cps;
use crate::foreign::{Atom, Atomic};
use crate::representations::OrcString;
use crate::systems::stl::Binary;
use crate::systems::RuntimeError;
use crate::{ast, define_fn, ConstTree, Interner, Primitive};
@@ -53,9 +54,9 @@ define_fn! {
define_fn! {
WriteStr {
stream: SinkHandle,
string: String
string: OrcString
} => Ok(init_cps(3, IOCmdHandlePack {
cmd: WriteCmd::WStr(string.clone()),
cmd: WriteCmd::WStr(string.get_string()),
handle: *stream,
}))
}

View File

@@ -105,7 +105,7 @@ impl IOHandler<ReadCmd> for (ExprInst, ExprInst) {
ReadResult::RBin(_, Ok(bytes)) =>
call(succ, vec![Binary(Arc::new(bytes)).atom_cls().wrap()]).wrap(),
ReadResult::RStr(_, Ok(text)) =>
call(succ, vec![Literal::Str(text).into()]).wrap(),
call(succ, vec![Literal::Str(text.into()).into()]).wrap(),
}
}
}