eval

package
v0.0.0-...-7dd06bf Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2015 License: BSD-2-Clause Imports: 21 Imported by: 0

Documentation

Overview

Package eval handles evaluation of nodes and consists the runtime of the shell.

Index

Constants

View Source
const (
	Ok exitusSort = iota
	Failure
	Traceback

	// Control flow sorts
	Return
	Break
	Continue
	FlowSortLower = Return
)

Variables

View Source
var BuiltinFnNames []string
View Source
var BuiltinSpecialNames []string

Functions

func HasFailure

func HasFailure(vs []Value) bool

func PrintExituses

func PrintExituses(vs []Value)

Types

type Compiler

type Compiler struct {
	// contains filtered or unexported fields
}

Compiler compiles an Elvish AST into an Op.

func NewCompiler

func NewCompiler(bi staticNS, dataDir string) *Compiler

NewCompiler returns a new compiler.

func (*Compiler) Compile

func (cp *Compiler) Compile(name, text, dir string, n *parse.Chunk) (valuesOp, error)

Compile compiles a ChunkNode into an Op. The supplied name and text are used in diagnostic messages.

type Evaler

type Evaler struct {
	Compiler *Compiler
	// contains filtered or unexported fields
}

Evaler is used to evaluate elvish sources. It maintains runtime context shared among all evalCtx instances.

func NewEvaler

func NewEvaler(st *store.Store, dataDir string) *Evaler

NewEvaler creates a new Evaler.

func (*Evaler) Eval

func (ev *Evaler) Eval(name, text, dir string, n *parse.Chunk) ([]Value, error)

Eval evaluates a chunk node n. The supplied name and text are used in diagnostic messages.

func (*Evaler) Source

func (ev *Evaler) Source(fname string) ([]Value, error)

Source evaluates the content of a file.

func (*Evaler) SourceText

func (ev *Evaler) SourceText(name, src, dir string) ([]Value, error)

SourceText evaluates a chunk of elvish source.

type Op

type Op func(*evalCtx)

Op operates on an evalCtx.

type Type

type Type interface {
	Default() Value
	String() string
}

Type represents the static information of a Value.

type Value

type Value interface {
	Type() Type
	Repr() string
}

Value is the runtime representation of an elvish value.

type Variable

type Variable interface {
	Set(v Value)
	Get() Value
	StaticType() Type
}

Variable is the internal representation of a variable.

Notes

Bugs

  • Possible error of os.Getwd after cd-ing is ignored.

  • mayAssign uses a wrong way to check the equality of two interfaces, which happens to work when all the Type instances are empty structs.

  • We rely on the fact that os.Unsetenv always returns nil.

  • When evaluating closures, async access to global variables and ports can be problematic.

  • valueEq uses reflect.DeepEqual to check the equality of two values, may can become wrong when values get more complex.

Jump to

Keyboard shortcuts

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