Class: BrainfuckInterpreter

BrainfuckInterpreter()

Class representing a Brainfuck Interpreter.

Constructor

new BrainfuckInterpreter()

Constructor for a Brainfuck Interpreter
Source:

Methods

clearCanvas()

Remove every element in the canvas.
Source:

createCell()

Creates a new MemoryCell object.
Source:
Returns:
MemoryCell a whole new MemoryCell object

decrementPointer()

Handle for the decrement '<' command.
Source:

decrementValue()

Handler for the decrement value '-' command.
Source:

drawMemory()

Draw the state of each this.memory cell in the canvas and renders it.
Source:

endLoop()

Handler for the end loop '[' command.
Source:

incrementPointer()

Handler for the increment '>' command.
Source:

incrementValue()

Handler for the increment value '+' command.
Source:

initGUI(runningMethod)

Set the initial values necessary for the visualization.
Parameters:
Name Type Description
runningMethod RunningMethodEnum Selected runningMethod for the execution. See RunningMethodEnum in utils.js
Source:

initInterpreter()

Set the initial values for the interpreter fields.
Source:

inputCommand(runningMethod)

Handler for the this.input ',' command. Gets one this.input character from the user according to the current runningMethod.
Parameters:
Name Type Description
runningMethod RunningMethodEnum Selected runningMethod for the execution. See RunningMethodEnum in utils.js
Source:

loopsToString()

Creates a string representation of the current state of the loops.
Source:
Returns:
string A string representation of the loops

memoryToString()

Creates a string representation of the current state of the this.memory.
Source:
Returns:
string A string representation of the this.memory

nextCommand(runningMethod)

Get one new command from the user according to the current runningMethod.
Parameters:
Name Type Description
runningMethod RunningMethodEnum Selected runningMethod for the execution. See RunningMethodEnum in utils.js
Source:

outputCommand()

Handler for the output '.' command.
Source:

runCode(runningMethod)

Run a Brainfuck program according to the selected runningMethod. Init all the necessary elements for the interpreter and the canvas.
Parameters:
Name Type Description
runningMethod RunningMethodEnum Selected runningMethod for the execution. See RunningMethodEnum in utils.js
Source:

runCommand(command, runningMethod)

Select the correct handler for the current command of the tape and execute it according to the current runningMethod.
Parameters:
Name Type Description
command char Char indicating the current command. See the supportedCommands list in utils.js
runningMethod RunningMethodEnum Selected runningMethod for the execution. See RunningMethodEnum in utils.js
Source:

startLoop()

Handler for the start loop '[' command.
Source: