-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_utils.rs
More file actions
29 lines (25 loc) · 1019 Bytes
/
test_utils.rs
File metadata and controls
29 lines (25 loc) · 1019 Bytes
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
use rusty_common::NoPosContainer;
use rusty_linter::core::lint;
use rusty_parser::{UserDefinedTypes, parse};
use crate::instruction_generator::{
Instruction, InstructionGeneratorResult, InstructionPos, generate_instructions,
unwrap_linter_context,
};
pub fn generate_instructions_str_with_types(
input: &str,
) -> (InstructionGeneratorResult, UserDefinedTypes) {
let program = parse(input);
let (linted_program, linter_context) = lint(program).expect("Linter should succeed");
let (linter_names, user_defined_types) = unwrap_linter_context(linter_context);
(
generate_instructions(linted_program, linter_names),
user_defined_types,
)
}
pub fn generate_instructions_str(input: &str) -> Vec<InstructionPos> {
let (instruction_generator_result, _) = generate_instructions_str_with_types(input);
instruction_generator_result.instructions
}
pub fn generate_instructions_str_no_pos(input: &str) -> Vec<Instruction> {
generate_instructions_str(input).no_pos()
}