util

package
v0.0.0-...-c4f0eec Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2014 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Frame

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

Frame represents a single stack frame. It has a reference to the main stack where the actual data resides. Frame is just a convenient wrapper to remember when the Frame started

func NewFrame

func NewFrame(s *Stack) *Frame

NewFrame creates a new Frame instance.

func (*Frame) DeclareVar

func (f *Frame) DeclareVar(v interface{}) int

DeclareVar puts a new variable in the stack, and returns the index where it now resides

func (*Frame) GetLvar

func (f *Frame) GetLvar(i int) interface{}

GetLvar gets the frame local variable at position i

func (*Frame) LastLvarIndex

func (f *Frame) LastLvarIndex() int

LastLvarIndex returns the index of the last element in our stack.

func (*Frame) Mark

func (f *Frame) Mark() int

Mark returns the current mark index

func (*Frame) SetLvar

func (f *Frame) SetLvar(i int, v interface{})

SetLvar sets the frame local variable at position i

func (*Frame) SetMark

func (f *Frame) SetMark(v int)

SetMark sets the offset from which this frame's variables may be stored

type Stack

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

Stack is a simple structure to hold various data

func NewStack

func NewStack(size int) *Stack

NewStack creates a new Stack of initial size `size`.

func (*Stack) BufferSize

func (s *Stack) BufferSize() int

BufferSize returns the length of the underlying buffer

func (*Stack) Cur

func (s *Stack) Cur() int

Cur returns the current stack index. Note that if nothing is stored in the stack, it returns -1

func (*Stack) Extend

func (s *Stack) Extend(extendBy int)

Extend changes the size of the underlying buffer, extending it by `extendBy`

func (*Stack) Get

func (s *Stack) Get(i int) (interface{}, error)

Get returns the element at position `i`

func (*Stack) Grow

func (s *Stack) Grow(min int)

Grow automatically grows the underlying buffer so that it can hold at least `min` elements

func (*Stack) Pop

func (s *Stack) Pop() interface{}

Pop removes and returns the item at the end of the stack

func (*Stack) Push

func (s *Stack) Push(v interface{})

Push adds an element at the end of the stack

func (*Stack) Reset

func (s *Stack) Reset()

Reset clears the contents of the stack and pushes back the cursor as if nothing is in the stack

func (*Stack) Resize

func (s *Stack) Resize(size int)

Resize changes the size of the underlying buffer

func (*Stack) Set

func (s *Stack) Set(i int, v interface{})

Set sets the element at position `i` to `v`. The stack size is automatically adjusted.

func (*Stack) SetCur

func (s *Stack) SetCur(c int)

SetCur sets the current cursor location

func (*Stack) Size

func (s *Stack) Size() int

Size returns the number of elements stored in this stack

func (*Stack) String

func (s *Stack) String() string

String returns the textual representation of the stack

func (*Stack) Top

func (s *Stack) Top() (interface{}, error)

Top returns the element at the top of the stack or an error if stack is empty

Jump to

Keyboard shortcuts

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