elliptic.Kernel.Contract module

class elliptic.Kernel.Contract.DSLContract(dsl_impl, expr=None)[source]

Bases: typing.Generic

Defines the contract of the DSL.

The DSL contract is the set of operations that the DSL supports, plus a base operation. Each operation should create an Expression instance and call append_tree with the created expression.

Parameters
  • dsl_impl (~DSLImplementationSubclass) – DSL Implementation object.

  • expr (Optional[Expression]) – Current DSL operation. If set to None, will be set to the next operation done when calling append_tree.

dsl_impl

DSL Implementation object.

expr

Current DSL operation.

Base()[source]

Base operation. Called by default from ELLIPTIc before any other operation.

Return type

~DSLContractSubclass

append_tree(expr)[source]

Inserts the given expression to the expression tree and returns a new DSLContract bounded to the given expression.

Return type

~DSLContractSubclass

class elliptic.Kernel.Contract.DSLImplementation[source]

Bases: abc.ABC

Abstract class that defines a DSL Implementation. Should be used to connect the corresponding Context Delegates.

abstract base_delegate()[source]

Returns the context delegate for the DSL base context handling.

The base context delegate could be used, for example, to declare variables and initialize dependencies for the generated code.

Return type

Type[ContextDelegate]