interpreter

package
v0.0.0-...-fbe25eb Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Interpret

func Interpret(program parser.Program, bitmap BitmapContext) error

func PrintFunctions

func PrintFunctions() string

Types

type BitmapContext

type BitmapContext interface {
	GetPixel(x int, y int) lang.Color
	SetPixel(x int, y int, color lang.Color)
	SourceWidth() int
	SourceHeight() int
	TargetWidth() int
	TargetHeight() int
	Convolute(x, y, width, height int, kernel []lang.Number) lang.Color
	MapRed(x, y, width, height int, kernel []lang.Number) []lang.Number
	MapGreen(x, y, width, height int, kernel []lang.Number) []lang.Number
	MapBlue(x, y, width, height int, kernel []lang.Number) []lang.Number
	MapAlpha(x, y, width, height int, kernel []lang.Number) []lang.Number
	Blt(x, y, width, height int)
	ResizeTarget(width, height int)
	Flip() int // return imageID for Recall()
	Recall(imageID int) error
	SetClipRect(rect image.Rectangle)
	ClipRect() image.Rectangle
	Log(message string)
	InterpolatePixel(x float32, y float32) *lang.Color
}

BitmapContext is the surface the ylang interpreter works on.

type Boolean

type Boolean lang.Boolean

func (Boolean) Add

func (b Boolean) Add(other Value) (Value, error)

func (Boolean) At

func (b Boolean) At(bitmap BitmapContext) (Value, error)

func (Boolean) Compare

func (b Boolean) Compare(other Value) (Value, error)

func (Boolean) Concat

func (b Boolean) Concat(val Value) (Value, error)

func (Boolean) Div

func (b Boolean) Div(other Value) (Value, error)

func (Boolean) In

func (b Boolean) In(other Value) (Value, error)

func (Boolean) Index

func (b Boolean) Index(index Value) (Value, error)

func (Boolean) IndexAssign

func (b Boolean) IndexAssign(index Value, val Value) error

func (Boolean) IndexRange

func (b Boolean) IndexRange(lower, upper Value) (Value, error)

func (Boolean) Iterate

func (b Boolean) Iterate(visit func(Value) error) error

func (Boolean) Mod

func (b Boolean) Mod(other Value) (Value, error)

func (Boolean) Mul

func (b Boolean) Mul(other Value) (Value, error)

func (Boolean) Neg

func (b Boolean) Neg() (Value, error)

func (Boolean) Not

func (b Boolean) Not() (Value, error)

func (Boolean) PrintStr

func (b Boolean) PrintStr() string

func (Boolean) Property

func (b Boolean) Property(ident string) (Value, error)

func (Boolean) RuntimeTypeName

func (b Boolean) RuntimeTypeName() string

func (Boolean) Sub

func (b Boolean) Sub(other Value) (Value, error)

type Circle

type Circle struct {
	Center Point
	Radius Number
}

func (Circle) Add

func (c Circle) Add(other Value) (Value, error)

func (Circle) At

func (c Circle) At(bitmap BitmapContext) (Value, error)

func (Circle) Compare

func (c Circle) Compare(other Value) (Value, error)

func (Circle) Concat

func (c Circle) Concat(val Value) (Value, error)

func (Circle) Div

func (c Circle) Div(other Value) (Value, error)

func (Circle) In

func (c Circle) In(other Value) (Value, error)

func (Circle) Index

func (c Circle) Index(index Value) (Value, error)

func (Circle) IndexAssign

func (c Circle) IndexAssign(index Value, val Value) error

func (Circle) IndexRange

func (c Circle) IndexRange(lower, upper Value) (Value, error)

func (Circle) Iterate

func (c Circle) Iterate(visit func(Value) error) error

func (Circle) Mod

func (c Circle) Mod(other Value) (Value, error)

func (Circle) Mul

func (c Circle) Mul(other Value) (Value, error)

func (Circle) Neg

func (c Circle) Neg() (Value, error)

func (Circle) Not

func (c Circle) Not() (Value, error)

func (Circle) PrintStr

func (c Circle) PrintStr() string

func (Circle) Property

func (c Circle) Property(ident string) (Value, error)

func (Circle) RuntimeTypeName

func (c Circle) RuntimeTypeName() string

func (Circle) Sub

func (c Circle) Sub(other Value) (Value, error)

type Color

type Color lang.Color

func (Color) Add

func (c Color) Add(other Value) (Value, error)

func (Color) At

func (c Color) At(bitmap BitmapContext) (Value, error)

func (Color) Compare

func (c Color) Compare(other Value) (Value, error)

func (Color) Concat

func (c Color) Concat(val Value) (Value, error)

func (Color) Div

func (c Color) Div(other Value) (Value, error)

func (Color) In

func (c Color) In(other Value) (Value, error)

func (Color) Index

func (c Color) Index(index Value) (Value, error)

func (Color) IndexAssign

func (c Color) IndexAssign(index Value, val Value) error

func (Color) IndexRange

func (c Color) IndexRange(lower, upper Value) (Value, error)

func (Color) Iterate

func (c Color) Iterate(visit func(Value) error) error

func (Color) Mod

func (c Color) Mod(other Value) (Value, error)

func (Color) Mul

func (c Color) Mul(other Value) (Value, error)

func (Color) Neg

func (c Color) Neg() (Value, error)

func (Color) Not

func (c Color) Not() (Value, error)

func (Color) PrintStr

func (c Color) PrintStr() string

func (Color) Property

func (c Color) Property(ident string) (Value, error)

func (Color) RuntimeTypeName

func (c Color) RuntimeTypeName() string

func (Color) Sub

func (c Color) Sub(other Value) (Value, error)

type ColorHsv

type ColorHsv struct {
	H lang.Number
	S lang.Number
	V lang.Number
}

func (ColorHsv) Add

func (hsv ColorHsv) Add(other Value) (Value, error)

func (ColorHsv) At

func (hsv ColorHsv) At(bitmap BitmapContext) (Value, error)

func (ColorHsv) Compare

func (hsv ColorHsv) Compare(other Value) (Value, error)

func (ColorHsv) Concat

func (hsv ColorHsv) Concat(val Value) (Value, error)

func (ColorHsv) Div

func (hsv ColorHsv) Div(other Value) (Value, error)

func (ColorHsv) In

func (hsv ColorHsv) In(other Value) (Value, error)

func (ColorHsv) Index

func (hsv ColorHsv) Index(index Value) (Value, error)

func (ColorHsv) IndexAssign

func (hsv ColorHsv) IndexAssign(index Value, val Value) error

func (ColorHsv) IndexRange

func (hsv ColorHsv) IndexRange(lower, upper Value) (Value, error)

func (ColorHsv) Iterate

func (hsv ColorHsv) Iterate(visit func(Value) error) error

func (ColorHsv) Mod

func (hsv ColorHsv) Mod(other Value) (Value, error)

func (ColorHsv) Mul

func (hsv ColorHsv) Mul(other Value) (Value, error)

func (ColorHsv) Neg

func (hsv ColorHsv) Neg() (Value, error)

func (ColorHsv) Not

func (hsv ColorHsv) Not() (Value, error)

func (ColorHsv) PrintStr

func (hsv ColorHsv) PrintStr() string

func (ColorHsv) Property

func (hsv ColorHsv) Property(ident string) (Value, error)

func (ColorHsv) RuntimeTypeName

func (hsv ColorHsv) RuntimeTypeName() string

func (ColorHsv) Sub

func (hsv ColorHsv) Sub(other Value) (Value, error)

type Function

type Function struct {
	ParameterNames []string
	Body           []parser.Statement
	// contains filtered or unexported fields
}

func (Function) Add

func (f Function) Add(other Value) (Value, error)

func (Function) At

func (f Function) At(bitmap BitmapContext) (Value, error)

func (Function) Compare

func (f Function) Compare(other Value) (Value, error)

func (Function) Concat

func (f Function) Concat(val Value) (Value, error)

func (Function) Div

func (f Function) Div(other Value) (Value, error)

func (Function) In

func (f Function) In(other Value) (Value, error)

func (Function) Index

func (f Function) Index(index Value) (Value, error)

func (Function) IndexAssign

func (f Function) IndexAssign(index Value, val Value) error

func (Function) IndexRange

func (f Function) IndexRange(lower, upper Value) (Value, error)

func (Function) Iterate

func (f Function) Iterate(visit func(Value) error) error

func (Function) Mod

func (f Function) Mod(other Value) (Value, error)

func (Function) Mul

func (f Function) Mul(other Value) (Value, error)

func (Function) Neg

func (f Function) Neg() (Value, error)

func (Function) Not

func (f Function) Not() (Value, error)

func (Function) PrintStr

func (f Function) PrintStr() string

func (Function) Property

func (f Function) Property(ident string) (Value, error)

func (Function) RuntimeTypeName

func (f Function) RuntimeTypeName() string

func (Function) Sub

func (f Function) Sub(other Value) (Value, error)

type FunctionDecl

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

type HashMap

type HashMap map[Value]Value

func (HashMap) Add

func (h HashMap) Add(other Value) (Value, error)

func (HashMap) At

func (h HashMap) At(bitmap BitmapContext) (Value, error)

func (HashMap) Compare

func (h HashMap) Compare(other Value) (Value, error)

func (HashMap) Concat

func (h HashMap) Concat(val Value) (Value, error)

func (HashMap) Div

func (h HashMap) Div(other Value) (Value, error)

func (HashMap) In

func (h HashMap) In(other Value) (Value, error)

func (HashMap) Index

func (h HashMap) Index(index Value) (Value, error)

func (HashMap) IndexAssign

func (h HashMap) IndexAssign(index Value, val Value) error

func (HashMap) IndexRange

func (h HashMap) IndexRange(lower, upper Value) (Value, error)

func (HashMap) Iterate

func (h HashMap) Iterate(visit func(Value) error) error

func (HashMap) Mod

func (h HashMap) Mod(other Value) (Value, error)

func (HashMap) Mul

func (h HashMap) Mul(other Value) (Value, error)

func (HashMap) Neg

func (h HashMap) Neg() (Value, error)

func (HashMap) Not

func (h HashMap) Not() (Value, error)

func (HashMap) PrintStr

func (h HashMap) PrintStr() string

func (HashMap) Property

func (h HashMap) Property(ident string) (Value, error)

func (HashMap) RuntimeTypeName

func (h HashMap) RuntimeTypeName() string

func (HashMap) Sub

func (h HashMap) Sub(other Value) (Value, error)

type Kernel

type Kernel struct {
	Width  int
	Height int
	Values []lang.Number
}

func (Kernel) Add

func (k Kernel) Add(other Value) (Value, error)

func (Kernel) At

func (k Kernel) At(bitmap BitmapContext) (Value, error)

func (Kernel) Compare

func (k Kernel) Compare(other Value) (Value, error)

func (Kernel) Concat

func (k Kernel) Concat(val Value) (Value, error)

func (Kernel) Div

func (k Kernel) Div(other Value) (Value, error)

func (Kernel) In

func (k Kernel) In(other Value) (Value, error)

func (Kernel) Index

func (k Kernel) Index(index Value) (Value, error)

func (Kernel) IndexAssign

func (k Kernel) IndexAssign(index Value, val Value) error

func (Kernel) IndexRange

func (k Kernel) IndexRange(lower, upper Value) (Value, error)

func (Kernel) Iterate

func (k Kernel) Iterate(visit func(Value) error) error

func (Kernel) Mod

func (k Kernel) Mod(other Value) (Value, error)

func (Kernel) Mul

func (k Kernel) Mul(other Value) (Value, error)

func (Kernel) Neg

func (k Kernel) Neg() (Value, error)

func (Kernel) Not

func (k Kernel) Not() (Value, error)

func (Kernel) PrintStr

func (k Kernel) PrintStr() string

func (Kernel) Property

func (k Kernel) Property(ident string) (Value, error)

func (Kernel) RuntimeTypeName

func (k Kernel) RuntimeTypeName() string

func (Kernel) Sub

func (k Kernel) Sub(other Value) (Value, error)

type Line

type Line struct {
	Point1 Point
	Point2 Point
}

func (Line) Add

func (l Line) Add(other Value) (Value, error)

func (Line) At

func (l Line) At(bitmap BitmapContext) (Value, error)

func (Line) Compare

func (l Line) Compare(other Value) (Value, error)

func (Line) Concat

func (l Line) Concat(val Value) (Value, error)

func (Line) Div

func (l Line) Div(other Value) (Value, error)

func (Line) In

func (l Line) In(other Value) (Value, error)

func (Line) Index

func (l Line) Index(index Value) (Value, error)

func (Line) IndexAssign

func (l Line) IndexAssign(index Value, val Value) error

func (Line) IndexRange

func (l Line) IndexRange(lower, upper Value) (Value, error)

func (Line) Iterate

func (l Line) Iterate(visit func(Value) error) error

func (Line) Mod

func (l Line) Mod(other Value) (Value, error)

func (Line) Mul

func (l Line) Mul(other Value) (Value, error)

func (Line) Neg

func (l Line) Neg() (Value, error)

func (Line) Not

func (l Line) Not() (Value, error)

func (Line) PrintStr

func (l Line) PrintStr() string

func (Line) Property

func (l Line) Property(ident string) (Value, error)

func (Line) RuntimeTypeName

func (l Line) RuntimeTypeName() string

func (Line) Sub

func (l Line) Sub(other Value) (Value, error)

type List

type List struct {
	Elements []Value
}

func (List) Add

func (l List) Add(other Value) (Value, error)

func (List) At

func (l List) At(bitmap BitmapContext) (Value, error)

func (List) Compare

func (l List) Compare(other Value) (Value, error)

func (List) Concat

func (l List) Concat(val Value) (Value, error)

func (List) Div

func (l List) Div(other Value) (Value, error)

func (List) In

func (l List) In(other Value) (Value, error)

func (List) Index

func (l List) Index(index Value) (Value, error)

func (List) IndexAssign

func (l List) IndexAssign(index Value, val Value) error

func (List) IndexRange

func (l List) IndexRange(lower, upper Value) (Value, error)

func (List) Iterate

func (l List) Iterate(visit func(Value) error) error

func (List) Mod

func (l List) Mod(other Value) (Value, error)

func (List) Mul

func (l List) Mul(other Value) (Value, error)

func (List) Neg

func (l List) Neg() (Value, error)

func (List) Not

func (l List) Not() (Value, error)

func (List) PrintStr

func (l List) PrintStr() string

func (List) Property

func (l List) Property(ident string) (Value, error)

func (List) RuntimeTypeName

func (l List) RuntimeTypeName() string

func (List) Sub

func (l List) Sub(other Value) (Value, error)

type Nilval

type Nilval lang.Nil

func (Nilval) Add

func (n Nilval) Add(other Value) (Value, error)

func (Nilval) At

func (n Nilval) At(bitmap BitmapContext) (Value, error)

func (Nilval) Compare

func (n Nilval) Compare(other Value) (Value, error)

func (Nilval) Concat

func (n Nilval) Concat(val Value) (Value, error)

func (Nilval) Div

func (n Nilval) Div(other Value) (Value, error)

func (Nilval) In

func (n Nilval) In(other Value) (Value, error)

func (Nilval) Index

func (n Nilval) Index(index Value) (Value, error)

func (Nilval) IndexAssign

func (n Nilval) IndexAssign(index Value, val Value) error

func (Nilval) IndexRange

func (n Nilval) IndexRange(lower, upper Value) (Value, error)

func (Nilval) Iterate

func (n Nilval) Iterate(visit func(Value) error) error

func (Nilval) Mod

func (n Nilval) Mod(other Value) (Value, error)

func (Nilval) Mul

func (n Nilval) Mul(other Value) (Value, error)

func (Nilval) Neg

func (n Nilval) Neg() (Value, error)

func (Nilval) Not

func (n Nilval) Not() (Value, error)

func (Nilval) PrintStr

func (n Nilval) PrintStr() string

func (Nilval) Property

func (n Nilval) Property(ident string) (Value, error)

func (Nilval) RuntimeTypeName

func (n Nilval) RuntimeTypeName() string

func (Nilval) Sub

func (n Nilval) Sub(other Value) (Value, error)

type Number

type Number lang.Number

func (Number) Add

func (n Number) Add(other Value) (Value, error)

func (Number) At

func (n Number) At(bitmap BitmapContext) (Value, error)

func (Number) Compare

func (n Number) Compare(other Value) (Value, error)

func (Number) Concat

func (n Number) Concat(val Value) (Value, error)

func (Number) Div

func (n Number) Div(other Value) (Value, error)

func (Number) In

func (n Number) In(other Value) (Value, error)

func (Number) Index

func (n Number) Index(index Value) (Value, error)

func (Number) IndexAssign

func (n Number) IndexAssign(index Value, val Value) error

func (Number) IndexRange

func (n Number) IndexRange(lower, upper Value) (Value, error)

func (Number) Iterate

func (n Number) Iterate(visit func(Value) error) error

func (Number) Mod

func (n Number) Mod(other Value) (Value, error)

func (Number) Mul

func (n Number) Mul(other Value) (Value, error)

func (Number) Neg

func (n Number) Neg() (Value, error)

func (Number) Not

func (n Number) Not() (Value, error)

func (Number) PrintStr

func (n Number) PrintStr() string

func (Number) Property

func (n Number) Property(ident string) (Value, error)

func (Number) RuntimeTypeName

func (n Number) RuntimeTypeName() string

func (Number) Sub

func (n Number) Sub(other Value) (Value, error)

type Point

type Point image.Point

func (Point) Add

func (p Point) Add(other Value) (Value, error)

func (Point) At

func (p Point) At(bitmap BitmapContext) (Value, error)

func (Point) Compare

func (p Point) Compare(other Value) (Value, error)

func (Point) Concat

func (p Point) Concat(val Value) (Value, error)

func (Point) Div

func (p Point) Div(other Value) (Value, error)

func (Point) In

func (p Point) In(other Value) (Value, error)

func (Point) Index

func (p Point) Index(index Value) (Value, error)

func (Point) IndexAssign

func (p Point) IndexAssign(index Value, val Value) error

func (Point) IndexRange

func (p Point) IndexRange(lower, upper Value) (Value, error)

func (Point) Iterate

func (p Point) Iterate(visit func(Value) error) error

func (Point) Mod

func (p Point) Mod(other Value) (Value, error)

func (Point) Mul

func (p Point) Mul(other Value) (Value, error)

func (Point) Neg

func (p Point) Neg() (Value, error)

func (Point) Not

func (p Point) Not() (Value, error)

func (Point) PrintStr

func (p Point) PrintStr() string

func (Point) Property

func (p Point) Property(ident string) (Value, error)

func (Point) RuntimeTypeName

func (p Point) RuntimeTypeName() string

func (Point) Sub

func (p Point) Sub(other Value) (Value, error)

type Polygon

type Polygon struct {
	Vertices []Point
}

func (Polygon) Add

func (p Polygon) Add(other Value) (Value, error)

func (Polygon) At

func (p Polygon) At(bitmap BitmapContext) (Value, error)

func (Polygon) Compare

func (p Polygon) Compare(other Value) (Value, error)

func (Polygon) Concat

func (p Polygon) Concat(val Value) (Value, error)

func (Polygon) Div

func (p Polygon) Div(other Value) (Value, error)

func (Polygon) In

func (p Polygon) In(other Value) (Value, error)

func (Polygon) Index

func (p Polygon) Index(index Value) (Value, error)

func (Polygon) IndexAssign

func (p Polygon) IndexAssign(index Value, val Value) error

func (Polygon) IndexRange

func (p Polygon) IndexRange(lower, upper Value) (Value, error)

func (Polygon) Iterate

func (p Polygon) Iterate(visit func(Value) error) error

func (Polygon) Mod

func (p Polygon) Mod(other Value) (Value, error)

func (Polygon) Mul

func (p Polygon) Mul(other Value) (Value, error)

func (Polygon) Neg

func (p Polygon) Neg() (Value, error)

func (Polygon) Not

func (p Polygon) Not() (Value, error)

func (Polygon) PrintStr

func (p Polygon) PrintStr() string

func (Polygon) Property

func (p Polygon) Property(ident string) (Value, error)

func (Polygon) RuntimeTypeName

func (p Polygon) RuntimeTypeName() string

func (Polygon) Sub

func (p Polygon) Sub(other Value) (Value, error)

type Rect

type Rect image.Rectangle

func (Rect) Add

func (rc Rect) Add(other Value) (Value, error)

func (Rect) At

func (rc Rect) At(bitmap BitmapContext) (Value, error)

func (Rect) Compare

func (rc Rect) Compare(other Value) (Value, error)

func (Rect) Concat

func (rc Rect) Concat(val Value) (Value, error)

func (Rect) Div

func (rc Rect) Div(other Value) (Value, error)

func (Rect) In

func (rc Rect) In(other Value) (Value, error)

func (Rect) Index

func (rc Rect) Index(index Value) (Value, error)

func (Rect) IndexAssign

func (rc Rect) IndexAssign(index Value, val Value) error

func (Rect) IndexRange

func (rc Rect) IndexRange(lower, upper Value) (Value, error)

func (Rect) Iterate

func (rc Rect) Iterate(visit func(Value) error) error

func (Rect) Mod

func (rc Rect) Mod(other Value) (Value, error)

func (Rect) Mul

func (rc Rect) Mul(other Value) (Value, error)

func (Rect) Neg

func (rc Rect) Neg() (Value, error)

func (Rect) Not

func (rc Rect) Not() (Value, error)

func (Rect) PrintStr

func (rc Rect) PrintStr() string

func (Rect) Property

func (rc Rect) Property(ident string) (Value, error)

func (Rect) RuntimeTypeName

func (rc Rect) RuntimeTypeName() string

func (Rect) Sub

func (rc Rect) Sub(other Value) (Value, error)

type Str

type Str lang.Str

func (Str) Add

func (s Str) Add(other Value) (Value, error)

func (Str) At

func (s Str) At(bitmap BitmapContext) (Value, error)

func (Str) Compare

func (s Str) Compare(other Value) (Value, error)

func (Str) Concat

func (s Str) Concat(val Value) (Value, error)

func (Str) Div

func (s Str) Div(other Value) (Value, error)

func (Str) In

func (s Str) In(other Value) (Value, error)

func (Str) Index

func (s Str) Index(index Value) (Value, error)

func (Str) IndexAssign

func (s Str) IndexAssign(index Value, val Value) error

func (Str) IndexRange

func (s Str) IndexRange(lower, upper Value) (Value, error)

func (Str) Iterate

func (s Str) Iterate(visit func(Value) error) error

func (Str) Mod

func (s Str) Mod(other Value) (Value, error)

func (Str) Mul

func (s Str) Mul(other Value) (Value, error)

func (Str) Neg

func (s Str) Neg() (Value, error)

func (Str) Not

func (s Str) Not() (Value, error)

func (Str) PrintStr

func (s Str) PrintStr() string

func (Str) Property

func (s Str) Property(ident string) (Value, error)

func (Str) RuntimeTypeName

func (s Str) RuntimeTypeName() string

func (Str) Sub

func (s Str) Sub(other Value) (Value, error)

type Value

type Value interface {
	Compare(other Value) (Value, error)
	Add(other Value) (Value, error)
	Sub(other Value) (Value, error)
	Mul(other Value) (Value, error)
	Div(other Value) (Value, error)
	Mod(other Value) (Value, error)
	In(other Value) (Value, error)
	Neg() (Value, error)
	Not() (Value, error)
	At(bitmap BitmapContext) (Value, error)
	Property(ident string) (Value, error)
	PrintStr() string
	Iterate(visit func(Value) error) error
	Index(index Value) (Value, error)
	IndexRange(lower, upper Value) (Value, error)
	IndexAssign(index Value, val Value) error
	RuntimeTypeName() string
	Concat(val Value) (Value, error)
}

Value represents a ylang value at runtime

Jump to

Keyboard shortcuts

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