1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//! This module applies a list of [Instruction]s to a typed AST to
//! monomorphize it.

pub(crate) mod code_block;
pub(crate) mod context;
pub(crate) mod declaration;
pub(crate) mod expression;
pub(crate) mod module;
pub(crate) mod node;

use std::sync::RwLock;

use sway_error::handler::{ErrorEmitted, Handler};

use crate::{language::ty, monomorphize::priv_prelude::*, Engines};

/// Uses [Instruction]s to monomorphize a typed AST.
pub(crate) fn apply_instructions(
    engines: &Engines,
    handler: &Handler,
    instructions: Vec<Instruction>,
    module: &mut ty::TyModule,
) -> Result<(), ErrorEmitted> {
    let instructions = RwLock::new(InstructionItems::new(instructions));
    let ctx = InstructContext::from_root(engines, &instructions);

    instruct_root(ctx, handler, module)?;

    Ok(())
}