Skip to content

Introduce compilation mode#988

Open
Schaeff wants to merge 6 commits intodevelopfrom
add-compiler-mode-flag
Open

Introduce compilation mode#988
Schaeff wants to merge 6 commits intodevelopfrom
add-compiler-mode-flag

Conversation

@Schaeff
Copy link
Copy Markdown
Member

@Schaeff Schaeff commented Sep 1, 2021

zokrates check -i foo.zok --mode lib

Checks the file up to semantics, not requiring an entry point.

let artifacts = check_with_arena(source, location.clone(), resolver, config, &arena)?;

match artifacts {
CompilationArtifacts::Lib => unreachable!(),
Copy link
Copy Markdown
Member

@dark64 dark64 Nov 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be reachable when called from zokrates-js because the config is passed by the caller:

https://github.com/Zokrates/ZoKrates/pull/988/files#diff-31d8ede13068a8e0e79ec05ff89244788c8903841d377659d712b5d2057e9ea6R109

If my understanding is correct, one could set the mode to lib and call compile which would throw here with no clear message.


#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
pub enum CompileMode {
Bin,
Copy link
Copy Markdown
Member

@dark64 dark64 Nov 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use something like this here

#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
pub enum CompileMode {
    #[serde(rename = "bin")]
    Bin,
    #[serde(rename = "lib")]
    Lib
}

so it's a bit cleaner in js: mode: "lib" instead of mode: "Lib". It's also possible to put #[serde(rename_all = "lowercase")] before the enum definition.

We should also update typescript type information file:
https://github.com/Zokrates/ZoKrates/blob/add-compiler-mode-flag/zokrates_js/index.d.ts#L12

export type CompileMode = "bin" | "lib";

export interface CompileConfig {
   allow_unconstrained_variables?: boolean,
   isolate_branches?: boolean,
   mode?: CompileMode
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants