mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-23 23:23:50 +03:00
added compiler options to constructor and factory methods
This commit is contained in:
parent
9bc53eb594
commit
5fdf86f415
@ -83,6 +83,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
|
||||
main_file_path: PathBuf,
|
||||
output_directory: PathBuf,
|
||||
context: AsgContext<'a>,
|
||||
options: Option<CompilerOptions>,
|
||||
) -> Self {
|
||||
Self {
|
||||
program_name: package_name.clone(),
|
||||
@ -92,7 +93,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
|
||||
program_input: Input::new(),
|
||||
asg: None,
|
||||
context,
|
||||
options: CompilerOptions::default(),
|
||||
options: options.unwrap_or(CompilerOptions::default()),
|
||||
file_contents: RefCell::new(IndexMap::new()),
|
||||
_engine: PhantomData,
|
||||
_group: PhantomData,
|
||||
@ -111,8 +112,9 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
|
||||
main_file_path: PathBuf,
|
||||
output_directory: PathBuf,
|
||||
context: AsgContext<'a>,
|
||||
options: Option<CompilerOptions>,
|
||||
) -> Result<Self, CompilerError> {
|
||||
let mut compiler = Self::new(package_name, main_file_path, output_directory, context);
|
||||
let mut compiler = Self::new(package_name, main_file_path, output_directory, context, options);
|
||||
|
||||
compiler.parse_program()?;
|
||||
|
||||
@ -141,8 +143,9 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
|
||||
state_string: &str,
|
||||
state_path: &Path,
|
||||
context: AsgContext<'a>,
|
||||
options: Option<CompilerOptions>,
|
||||
) -> Result<Self, CompilerError> {
|
||||
let mut compiler = Self::new(package_name, main_file_path, output_directory, context);
|
||||
let mut compiler = Self::new(package_name, main_file_path, output_directory, context, options);
|
||||
|
||||
compiler.parse_input(input_string, input_path, state_string, state_path)?;
|
||||
|
||||
|
@ -28,7 +28,7 @@ fn test_parse_program_from_string() {
|
||||
// Parse program from string with compiler.
|
||||
let program_string = include_str!("main.leo");
|
||||
let context = crate::make_test_context();
|
||||
let mut compiler_no_path = EdwardsTestCompiler::new("".to_string(), PathBuf::new(), PathBuf::new(), context);
|
||||
let mut compiler_no_path = EdwardsTestCompiler::new("".to_string(), PathBuf::new(), PathBuf::new(), context, None);
|
||||
|
||||
compiler_no_path.parse_program_from_string(program_string).unwrap();
|
||||
|
||||
@ -37,7 +37,7 @@ fn test_parse_program_from_string() {
|
||||
local.push(MAIN_FILE_NAME);
|
||||
|
||||
let compiler_with_path =
|
||||
EdwardsTestCompiler::parse_program_without_input("".to_string(), local, PathBuf::new(), context).unwrap();
|
||||
EdwardsTestCompiler::parse_program_without_input("".to_string(), local, PathBuf::new(), context, None).unwrap();
|
||||
|
||||
// Compare output bytes.
|
||||
let expected_output = get_output(compiler_no_path);
|
||||
|
@ -71,7 +71,7 @@ fn new_compiler() -> EdwardsTestCompiler {
|
||||
let path = PathBuf::from("/test/src/main.leo");
|
||||
let output_dir = PathBuf::from(TEST_OUTPUT_DIRECTORY);
|
||||
|
||||
EdwardsTestCompiler::new(program_name, path, output_dir, make_test_context())
|
||||
EdwardsTestCompiler::new(program_name, path, output_dir, make_test_context(), None)
|
||||
}
|
||||
|
||||
pub(crate) fn parse_program(program_string: &str) -> Result<EdwardsTestCompiler, CompilerError> {
|
||||
|
@ -81,6 +81,7 @@ impl Command for Build {
|
||||
lib_file_path,
|
||||
output_directory.clone(),
|
||||
thread_leaked_context(),
|
||||
None,
|
||||
)?;
|
||||
tracing::info!("Complete");
|
||||
};
|
||||
@ -114,6 +115,7 @@ impl Command for Build {
|
||||
&state_string,
|
||||
&state_path,
|
||||
thread_leaked_context(),
|
||||
None,
|
||||
)?;
|
||||
|
||||
// Compute the current program checksum
|
||||
|
@ -107,6 +107,7 @@ impl Command for Test {
|
||||
file_path,
|
||||
output_directory.clone(),
|
||||
thread_leaked_context(),
|
||||
None,
|
||||
)?;
|
||||
|
||||
let temporary_program = program;
|
||||
|
Loading…
Reference in New Issue
Block a user