expr

package
v1.1.23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BitWidth added in v1.1.23

func BitWidth(e Expr, mapping schema.RegisterMap) (uint, bool)

BitWidth returns the minimum number of bits required to store any evaluation of this expression. In addition, it provides an indicator as to whether or not any evaluation could result in a negative value.

func Eval added in v1.1.23

func Eval(state []big.Int, exprs []Expr) []big.Int

Eval evaluates a set of zero or more expressions producing a set of zero or more values.

func RegistersRead added in v1.1.23

func RegistersRead(exprs ...Expr) []schema.RegisterId

RegistersRead determines the (unique) set of registers read by any expression in the given set of expressions.

func String

func String(e Expr, mapping schema.RegisterMap) string

String provides a generic facility for converting an expression into a suitable string.

Types

type Add

type Add struct {
	Exprs []Expr
}

Add represents an expresion which adds one or more terms together.

func (*Add) Eval

func (p *Add) Eval(env []big.Int) big.Int

Eval implementation for the Expr interface.

func (*Add) Polynomial

func (p *Add) Polynomial() agnostic.Polynomial

Polynomial implementation for the Expr interface.

func (*Add) RegistersRead

func (p *Add) RegistersRead() bit.Set

RegistersRead implementation for the Expr interface.

func (*Add) String

func (p *Add) String(mapping schema.RegisterMap) string

func (*Add) ValueRange

func (p *Add) ValueRange(mapping schema.RegisterMap) math.Interval

ValueRange implementation for the Expr interface.

type Const

type Const struct {
	Label    string
	Constant big.Int
	Base     uint
}

Const represents a constant value within an expresion.

func (*Const) Eval

func (p *Const) Eval([]big.Int) big.Int

Eval implementation for the Expr interface.

func (*Const) Polynomial

func (p *Const) Polynomial() agnostic.Polynomial

Polynomial implementation for the Expr interface.

func (*Const) RegistersRead

func (p *Const) RegistersRead() bit.Set

RegistersRead implementation for the Expr interface.

func (*Const) String

func (p *Const) String(mapping schema.RegisterMap) string

func (*Const) ValueRange

func (p *Const) ValueRange(mapping schema.RegisterMap) math.Interval

ValueRange implementation for the Expr interface.

type Expr

type Expr interface {
	// Evaluate this expression in a given environment producing a given value.
	Eval([]big.Int) big.Int
	// Polynomial returns this expression flatterned into a polynomial form.
	Polynomial() agnostic.Polynomial
	// RegistersRead returns the set of registers read by this expression
	RegistersRead() bit.Set
	// String returns a string representation of this expression in a given base.
	String(mapping schema.RegisterMap) string
	// ValueRange returns the interval of values that this term can evaluate to.
	// For terms accessing registers, this is determined by the declared width of
	// the register.
	ValueRange(mapping schema.RegisterMap) math.Interval
}

Expr represents an arbitrary expression used within an instruction.

type Mul

type Mul struct {
	Exprs []Expr
}

Mul represents an expresion which computes the product of one or more terms.

func (*Mul) Eval

func (p *Mul) Eval(env []big.Int) big.Int

Eval implementation for the Expr interface.

func (*Mul) Polynomial

func (p *Mul) Polynomial() agnostic.Polynomial

Polynomial implementation for the Expr interface.

func (*Mul) RegistersRead

func (p *Mul) RegistersRead() bit.Set

RegistersRead implementation for the Expr interface.

func (*Mul) String

func (p *Mul) String(mapping schema.RegisterMap) string

func (*Mul) ValueRange

func (p *Mul) ValueRange(mapping schema.RegisterMap) math.Interval

ValueRange implementation for the Expr interface.

type RegAccess

type RegAccess struct {
	Register io.RegisterId
}

RegAccess represents a register access within an expresion.

func (*RegAccess) Eval

func (p *RegAccess) Eval(env []big.Int) big.Int

Eval implementation for the Expr interface.

func (*RegAccess) Polynomial

func (p *RegAccess) Polynomial() agnostic.Polynomial

Polynomial implementation for the Expr interface.

func (*RegAccess) RegistersRead

func (p *RegAccess) RegistersRead() bit.Set

RegistersRead implementation for the Expr interface.

func (*RegAccess) String

func (p *RegAccess) String(mapping schema.RegisterMap) string

func (*RegAccess) ValueRange

func (p *RegAccess) ValueRange(mapping schema.RegisterMap) math.Interval

ValueRange implementation for the Expr interface.

type Sub

type Sub struct {
	Exprs []Expr
}

Sub represents an expresion which subtracts zero or more terms from a given term.

func (*Sub) Eval

func (p *Sub) Eval(env []big.Int) big.Int

Eval implementation for the Expr interface.

func (*Sub) Polynomial

func (p *Sub) Polynomial() agnostic.Polynomial

Polynomial implementation for the Expr interface.

func (*Sub) RegistersRead

func (p *Sub) RegistersRead() bit.Set

RegistersRead implementation for the Expr interface.

func (*Sub) String

func (p *Sub) String(mapping schema.RegisterMap) string

func (*Sub) ValueRange

func (p *Sub) ValueRange(mapping schema.RegisterMap) math.Interval

ValueRange implementation for the Expr interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL