Class: FishExecutor

FishExecutor(source, initialStackopt)

Executes a ><> program

Constructor

new FishExecutor(source, initialStackopt)

Creates a new FishExecutor
Parameters:
Name Type Attributes Description
source String Source code for the program to execute
initialStack Array.<Number> <optional>
Initial stack for the program. Defaults to an empty list
Source:

Members

(readonly) advances :Integer

Number of advances the program has made
Type:
  • Integer
Source:

(readonly) error :Error

The error the program threw, if any. Null otherwise
Type:
  • Error
Source:

(readonly) grid :Array.<Array.<String>>

Snapshot of the program's grid
Type:
  • Array.<Array.<String>>
Source:

(readonly) hasStarted :Boolean

Whether or not the program has started
Type:
  • Boolean
Source:

(readonly) hasTerminated :Boolean

Whether or not the program has terminated
Type:
  • Boolean
Source:

(readonly) inputBuffer :Array.<String>

Characters waiting to be read in the input stream
Type:
  • Array.<String>
Source:

instructionPointer :InstructionPointer

The program's instruction pointer. Don't mess with it
Type:
Source:

intervalTime :Integer

Interval (ms) between two advances when running at intervals
Type:
  • Integer
Source:

(readonly) isPaused :Boolean

Whether or not the execution is paused
Type:
  • Boolean
Source:

(readonly) output :String

Output from the program
Type:
  • String
Source:

(readonly) program :FishProgram

The program itself
Type:
Source:

(readonly) stackSnapshot :Array.<Number>

The program's current stack
Type:
  • Array.<Number>
Source:

Methods

giveInput(c)

Gives a character as input to the program
Parameters:
Name Type Description
c String The character to give
Source:
Throws:
If c is not a string or is not exactly one character
Type
Error

offUpdate(func)

Removes a listener for program updates
Parameters:
Name Type Description
func function The listener to remove
Source:

onUpdate(func)

Sets a listener for program updates
Parameters:
Name Type Description
func function Function which is called on every update. Gets this executor as its parameter
Source:

pause()

Pauses the program execution
Source:

resume()

Resumes program execution
Source:

run()

Starts running the program
Source:

step()

Advances the program one step, if the execution is paused
Source: