Skip to content

Create trait for builtins #227

@mimoo

Description

@mimoo

we should standardize how we write builtins by using some trait that looks like this or something:

trait Builtin {
    const sig: &'static str;

    const no_typecheck: bool;

    fn typecheck(
        generics: &GenericParameters,
        vars: &[VarInfo<F, LinearCombination<F>>],
        span: Span,
    ) -> Result<()>;

    fn builtin(
        compiler: &mut CircuitWriter<R1CS<F>>,
        _generics: &GenericParameters,
        vars: &[VarInfo<F, LinearCombination<F>>],
        span: Span,
    ) -> Result<Option<Var<F, LinearCombination<F>>>>;
}

and the typecheck() function could contain all of the actual checks that need to be done.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions