-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #981 from hacspec/make-options-extensible
Make options extensible
- Loading branch information
Showing
8 changed files
with
101 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
open Hax_engine.Backend | ||
include T with type BackendOptions.t = Hax_engine.Types.f_star_options | ||
include T with type BackendOptions.t = Hax_engine.Types.f_star_options_for__null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/// This module defines a way to extend externally the CLI of hax, via | ||
/// the `Extension` trait. This trait defines one associated type per | ||
/// extension point. | ||
use crate::prelude::*; | ||
|
||
use clap::{Parser, Subcommand}; | ||
|
||
macro_rules! trait_alias { | ||
($name:ident = $($base:tt)+) => { | ||
pub trait $name: $($base)+ { } | ||
impl<T: $($base)+> $name for T { } | ||
}; | ||
} | ||
|
||
trait_alias!( | ||
ExtensionPoint = | ||
bincode::Decode | ||
+ bincode::Encode | ||
+ std::fmt::Debug | ||
+ for<'a> serde::Deserialize<'a> | ||
+ serde::Serialize | ||
+ JsonSchema | ||
+ Clone | ||
+ for<'a> bincode::BorrowDecode<'a> | ||
); | ||
|
||
trait_alias!(SubcommandExtensionPoint = ExtensionPoint + clap::Subcommand); | ||
trait_alias!(ArgsExtensionPoint = ExtensionPoint + clap::Args); | ||
|
||
#[derive_group(Serializers)] | ||
#[derive(JsonSchema, Parser, Debug, Clone)] | ||
pub struct EmptyArgsExtension {} | ||
|
||
#[derive_group(Serializers)] | ||
#[derive(JsonSchema, Subcommand, Debug, Clone)] | ||
pub enum EmptySubcommandExtension {} | ||
|
||
pub trait Extension { | ||
type Options: ArgsExtensionPoint; | ||
type Command: SubcommandExtensionPoint; | ||
type BackendOptions: ArgsExtensionPoint; | ||
type FStarOptions: ArgsExtensionPoint; | ||
} | ||
|
||
impl Extension for () { | ||
type Options = EmptyArgsExtension; | ||
type Command = EmptySubcommandExtension; | ||
type BackendOptions = EmptyArgsExtension; | ||
type FStarOptions = EmptyArgsExtension; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters