Documentation ¶
Index ¶
- Variables
- func Btoi(b bool) int
- func Itob(i int32) bool
- func LoadConfigs(path string) error
- type Interpreter
- type Pixel
- type Stack
- func (stack *Stack) Clear() *Stack
- func (stack *Stack) Cycle() *Stack
- func (stack *Stack) GetItemAt(i int) (int32, error)
- func (stack *Stack) IsEmpty() bool
- func (stack *Stack) Output() bool
- func (stack *Stack) Peek() int32
- func (stack *Stack) Pop() (int32, error)
- func (stack *Stack) Push(val int32) error
- func (stack *Stack) RCycle() *Stack
- func (stack *Stack) Reverse() *Stack
- func (stack *Stack) Size() int
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrorFileExtension = errors.New("error: target image must be .png") ErrorOpenImage = errors.New("error: unable to open specified image") ErrorRandomGenerator = errors.New("error: trying to generate a random number with n <= 0") ErrorDecodeImage = errors.New("error: unable to decode specified image") ErrorOutOfBounds = errors.New("error: out of bounds") ErrorInvalidHex = errors.New("error: invalid hex format") ErrorLoadConfig = errors.New("error: unable to load config file") ErrorCloseFile = errors.New("error: unable to close the file") ErrorInputScanning = errors.New("error: problems reading input") ErrorOpenFile = errors.New("error: unable to open specified file") ErrorWriteFile = errors.New("error: error on writing on opened file") ErrorReadFile = errors.New("error: error on reading opened file") ErrorInvalidString = errors.New("error: invalid string into the stack") ErrorFileAlreadyOpen = errors.New("error: trying to open multiple files") ErrorMissingStartLoop = errors.New("error: missing start loop") ErrorMissingEndLoop = errors.New("error: missing end loop") ErrorNoSpaceString = errors.New("error: not enough space in to stack to push the string") )
* Interpreter's throwable errors
View Source
var ( ErrorPop = errors.New("error: trying to pop an empty stack") ErrorFullStack = errors.New("error: trying to push in a full stack") ErrorInvalidStackIndex = errors.New("error: invalid stack index") ErrorInvalidMaxSize = errors.New("error: invalid max stack size") )
View Source
var OPERATIONS = map[string]*Pixel{
"INPUT_INT": {R: 255, G: 255, B: 255},
"OUTPUT_INT": {R: 0, G: 0, B: 1},
"SUM": {R: 0, G: 206, B: 209},
"SUB": {R: 255, G: 165, B: 0},
"DIV": {R: 138, G: 43, B: 226},
"MUL": {R: 139, G: 0, B: 0},
"MOD": {R: 255, G: 218, B: 185},
"RND": {R: 0, G: 128, B: 0},
"AND": {R: 236, G: 243, B: 220},
"OR": {R: 183, G: 198, B: 230},
"XOR": {R: 245, G: 227, B: 215},
"NAND": {R: 225, G: 211, B: 239},
"NOT": {R: 255, G: 154, B: 162},
"BAND": {R: 138, G: 163, B: 153},
"BOR": {R: 125, G: 132, B: 178},
"BXOR": {R: 143, G: 166, B: 203},
"BNOT": {R: 219, G: 244, B: 167},
"LSHIFT": {R: 45, G: 106, B: 125},
"RSHIFT": {R: 67, G: 157, B: 186},
"INPUT_ASCII": {R: 227, G: 227, B: 227},
"OUTPUT_ASCII": {R: 75, G: 75, B: 75},
"POP": {R: 204, G: 158, B: 6},
"SWAP": {R: 255, G: 189, B: 74},
"CYCLE": {R: 227, G: 127, B: 157},
"RCYCLE": {R: 233, G: 148, B: 174},
"DUP": {R: 0, G: 105, B: 148},
"REVERSE": {R: 165, G: 165, B: 141},
"QUIT": {R: 183, G: 228, B: 199},
"OUTPUT": {R: 155, G: 34, B: 66},
"WHILE": {R: 46, G: 26, B: 71},
"WHILE_END": {R: 104, G: 71, B: 141},
"FILE_OPEN": {R: 145, G: 246, B: 139},
"FILE_CLOSE": {R: 47, G: 237, B: 35},
}
* A map of all interpreter's operations
Functions ¶
func LoadConfigs ¶ added in v2.1.1
Loads configs from the given config file and overrides standard operations color codes with the custom ones
Types ¶
type Interpreter ¶
type Interpreter struct {
// contains filtered or unexported fields
}
Interpreter structure
func NewInterpreter ¶
func NewInterpreter(debug bool, maxSize int, instructionSize int) *Interpreter
Interpreter's constructor. Params are flags value from CLI app.
func (*Interpreter) LoadImage ¶
func (i *Interpreter) LoadImage(path string) error
Loads image from OS and puts the stream into the interpreter image reference
func (*Interpreter) Run ¶
func (i *Interpreter) Run() error
* Executes the image interpretation doing Step() while the image program is terminated. * It is responsible to increase the program counter and calling the debugger if the flag is set.
func (*Interpreter) Step ¶
func (i *Interpreter) Step() (bool, string)
Interprets and executes next pixel in the given image
Click to show internal directories.
Click to hide internal directories.