ivy: robpike.io/ivy/exec Index | Files

package exec

import "robpike.io/ivy/exec"

Index

Package Files

context.go function.go opdef.go operator.go

func NewContext Uses

func NewContext(conf *config.Config) value.Context

NewContext returns a new execution context: the stack and variables, plus the execution configuration.

func Predefined Uses

func Predefined(op string) bool

Predefined reports whether the operator is predefined, a built-in.

type Context Uses

type Context struct {

    // Stack is a stack of symbol tables, one entry per function (op) invocation,
    // plus the 0th one at the base.
    Stack []Symtab
    //  UnaryFn maps the names of unary functions (ops) to their implemenations.
    UnaryFn map[string]*Function
    //  BinaryFn maps the names of binary functions (ops) to their implemenations.
    BinaryFn map[string]*Function
    // Defs is a list of defined ops, in time order.  It is used when saving the
    // Context to a file.
    Defs []OpDef
    // contains filtered or unexported fields
}

Context holds execution context, specifically the binding of names to values and operators. It is the only implementation of ../value/Context, but since it references the value package, there would be a cycle if that package depended on this type definition.

func (*Context) Assign Uses

func (c *Context) Assign(name string, val value.Value)

Assign assigns the variable the value. The variable must be defined either in the current function or globally. Inside a function, new variables become locals.

func (*Context) Binary Uses

func (c *Context) Binary(op string) value.BinaryOp

func (*Context) Config Uses

func (c *Context) Config() *config.Config

func (*Context) Declare Uses

func (c *Context) Declare(name string)

Declare makes the name a variable while parsing the next function.

func (*Context) Define Uses

func (c *Context) Define(fn *Function)

Define defines the function and installs it. It also performs some error checking and adds the function to the sequencing information used by the save method.

func (*Context) DefinedBinary Uses

func (c *Context) DefinedBinary(op string) bool

DefinedBinary reports whether the operator is a known binary.

func (*Context) DefinedOp Uses

func (c *Context) DefinedOp(op string) bool

DefinedOp reports whether the operator is known.

func (*Context) DefinedUnary Uses

func (c *Context) DefinedUnary(op string) bool

DefinedUnary reports whether the operator is a known unary.

func (*Context) Eval Uses

func (c *Context) Eval(exprs []value.Expr) []value.Value

Eval evaluates a list of expressions.

func (*Context) EvalBinary Uses

func (c *Context) EvalBinary(left value.Value, op string, right value.Value) value.Value

EvalBinary evaluates a binary operator, including products.

func (*Context) EvalUnary Uses

func (c *Context) EvalUnary(op string, right value.Value) value.Value

EvalUnary evaluates a unary operator, including reductions and scans.

func (*Context) ForgetAll Uses

func (c *Context) ForgetAll()

ForgetAll forgets the declared variables.

func (*Context) Lookup Uses

func (c *Context) Lookup(name string) value.Value

Lookup returns the value of a symbol.

func (*Context) SetConstants Uses

func (c *Context) SetConstants()

SetConstants re-assigns the fundamental constant values using the current setting of floating-point precision.

func (*Context) Unary Uses

func (c *Context) Unary(op string) value.UnaryOp

func (*Context) UserDefined Uses

func (c *Context) UserDefined(op string, isBinary bool) bool

type Function Uses

type Function struct {
    IsBinary bool
    Name     string
    Left     string
    Right    string
    Body     []value.Expr
}

Function represents a unary or binary user-defined operator.

func (*Function) EvalBinary Uses

func (fn *Function) EvalBinary(context value.Context, left, right value.Value) value.Value

func (*Function) EvalUnary Uses

func (fn *Function) EvalUnary(context value.Context, right value.Value) value.Value

func (*Function) String Uses

func (fn *Function) String() string

type OpDef Uses

type OpDef struct {
    Name     string
    IsBinary bool
}

OpDef is just a record of an op's name and arg count. It is held in execContext.defs to control writing the ops out in the right order during save. See comment above.

type Symtab Uses

type Symtab map[string]value.Value

Symtab is a symbol table, a map of names to values.

Package exec imports 4 packages (graph) and is imported by 6 packages. Updated 2018-03-29. Refresh now. Tools for package owners.