eval

package
v0.0.0-...-b83a777 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2017 License: BSD-2-Clause Imports: 26 Imported by: 0

Documentation

Overview

The methodpool is an awful hack for creating Go types with methods.

A type with a method is pulled out of the pool and embedded in a struct created with reflect.StructOf.

These method structs appear first in the struct definition and have no size, so a pointer to them is a pointer to the real value. Each of these method structs from the pool is only used for one new type, so a global map lets us work out the real type of the value.

This imposes two limits on a methodik that should not exist:

  1. methods can only be defined on struct types
  2. only a limited number of method signatures are possible

All of this can be replaced by either reflect.NamedOf (which is https://golang.org/issue/16522), or by generating then compiling Go to a plugin and loading that. Hopefully darwin plugin support will be ready for 1.9, and this can be retired.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvalFile

func EvalFile(path string) error

Types

type MethodPoolRead1

type MethodPoolRead1 struct{}

func (MethodPoolRead1) Read

func (m MethodPoolRead1) Read(b []byte) (n int, err error)

type MethodPoolRead2

type MethodPoolRead2 struct{}

func (MethodPoolRead2) Read

func (m MethodPoolRead2) Read(b []byte) (n int, err error)

type MethodPoolRead3

type MethodPoolRead3 struct{}

func (MethodPoolRead3) Read

func (m MethodPoolRead3) Read(b []byte) (n int, err error)

type MethodPoolWrite1

type MethodPoolWrite1 struct{}

func (MethodPoolWrite1) Write

func (m MethodPoolWrite1) Write(b []byte) (n int, err error)

type MethodPoolWrite2

type MethodPoolWrite2 struct{}

func (MethodPoolWrite2) Write

func (m MethodPoolWrite2) Write(b []byte) (n int, err error)

type MethodPoolWrite3

type MethodPoolWrite3 struct{}

func (MethodPoolWrite3) Write

func (m MethodPoolWrite3) Write(b []byte) (n int, err error)

type Panic

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

func (Panic) Error

func (p Panic) Error() string

type Program

type Program struct {
	Universe *Scope
	Cur      *Scope
	Types    *typecheck.Checker
	Pkgs     map[string]*gowrap.Pkg
	Path     string
	// contains filtered or unexported fields
}

func New

func New(path string) *Program

func (*Program) Alias

func (p *Program) Alias() *environ.Environ

func (*Program) Environ

func (p *Program) Environ() *environ.Environ

func (*Program) Eval

func (p *Program) Eval(s stmt.Stmt, sigint <-chan os.Signal) (res []reflect.Value, err error)

func (*Program) Get

func (p *Program) Get(name string) string

Get is part of the implementation of shell.Params.

func (*Program) Set

func (p *Program) Set(name, value string)

Set is part of the implementation of shell.Params.

type Scope

type Scope struct {
	Parent  *Scope
	VarName string
	Var     reflect.Value

	// Implicit is set if the Scope was created mid block and should be
	// unrolled when block ends.
	Implicit bool

	Label bool
}

func (*Scope) Lookup

func (s *Scope) Lookup(name string) reflect.Value

type UntypedBool

type UntypedBool struct{ Bool bool }

type UntypedComplex

type UntypedComplex struct{ Real, Imag *big.Float }

func (UntypedComplex) String

func (uc UntypedComplex) String() string

type UntypedFloat

type UntypedFloat struct{ *big.Float }

type UntypedInt

type UntypedInt struct{ *big.Int }

type UntypedRune

type UntypedRune struct{ Rune rune }

type UntypedString

type UntypedString struct{ String string }

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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