mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Test monomorphizing string literals
This commit is contained in:
parent
7b80489772
commit
8b73efc2ec
7 changed files with 173 additions and 39 deletions
|
@ -19,29 +19,34 @@ pub struct SpecializedExpr {
|
|||
}
|
||||
|
||||
impl SpecializedExpr {
|
||||
pub fn specialize_expr<'a>(&'a self, input: &'a str) -> SpecializedExprOut {
|
||||
pub fn specialize_expr<'a>(
|
||||
&'a self,
|
||||
input: &'a str,
|
||||
string_interns: &'a mut Interns<'a>,
|
||||
) -> SpecializedExprOut {
|
||||
let mut solved_out = self.solved_expr.solve_expr(input);
|
||||
let mut problems = Vec::new();
|
||||
let mut debug_info: Option<DebugInfo> = None;
|
||||
let mut types_cache = MonoCache::from_subs(&solved_out.subs);
|
||||
let mut types_cache = MonoCache::from_solved_subs(&solved_out.subs);
|
||||
let mut mono_types = MonoTypes::new();
|
||||
let mut mono_exprs = MonoExprs::new();
|
||||
let mut string_interns = Interns::new();
|
||||
|
||||
let mut env = Env::new(
|
||||
self.solved_expr.arena(),
|
||||
&mut solved_out.subs,
|
||||
&mut types_cache,
|
||||
&mut mono_types,
|
||||
&mut mono_exprs,
|
||||
RecordFieldIds::default(),
|
||||
TupleElemIds::default(),
|
||||
&mut string_interns,
|
||||
&mut debug_info,
|
||||
&mut problems,
|
||||
);
|
||||
let mono_expr_id = {
|
||||
let mut env = Env::new(
|
||||
self.solved_expr.arena(),
|
||||
&mut solved_out.subs,
|
||||
&mut types_cache,
|
||||
&mut mono_types,
|
||||
&mut mono_exprs,
|
||||
RecordFieldIds::default(),
|
||||
TupleElemIds::default(),
|
||||
string_interns,
|
||||
&mut debug_info,
|
||||
&mut problems,
|
||||
);
|
||||
|
||||
let mono_expr_id = env.to_mono_expr(solved_out.expr);
|
||||
env.to_mono_expr(solved_out.expr)
|
||||
};
|
||||
|
||||
SpecializedExprOut {
|
||||
mono_expr_id,
|
||||
|
|
|
@ -5,6 +5,7 @@ mod help_parse;
|
|||
mod help_solve;
|
||||
mod help_specialize;
|
||||
|
||||
pub use deindent::trim_and_deindent;
|
||||
pub use help_can::{CanExpr, CanExprOut};
|
||||
pub use help_parse::ParseExpr;
|
||||
pub use help_solve::{SolvedExpr, SolvedExprOut};
|
||||
|
@ -17,7 +18,3 @@ pub fn can_expr<'a>(input: &'a str) -> CanExprOut {
|
|||
pub fn solve_expr<'a>(input: &'a str) -> SolvedExprOut {
|
||||
SolvedExpr::default().solve_expr(input)
|
||||
}
|
||||
|
||||
pub fn specialize_expr<'a>(input: &'a str) -> SpecializedExprOut {
|
||||
SpecializedExpr::default().specialize_expr(input)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue