a fully working interpreter?

This commit is contained in:
Taylor 2025-01-15 13:20:51 -06:00
parent e865ba7407
commit 226ed32df6

View File

@ -4,7 +4,7 @@ import Push
exampleState = exampleState =
State State
{ exec = [IntGene 5, FloatGene 3.4, BoolGene True, StringGene "hi"], { exec = [IntGene 5, StateFunc instructionParameterLoad, StateFunc instructionIntAdd],
int = [1, 2, 3], int = [1, 2, 3],
float = [1.2, 1.7], float = [1.2, 1.7],
bool = [True, False], bool = [True, False],
@ -15,7 +15,12 @@ exampleState =
-- intAdd -- intAdd
testResult1 = [3, 3] == int (instructionIntAdd exampleState) testResult1 = [3, 3] == int (instructionIntAdd exampleState)
loaded = loadProgarm [IntGene 6, IntGene 6, StateFunc instructionParameterLoad, StateFunc instructionIntAdd] exampleState -- interpretExec
testResult2 = [6,1,2,3] == int (interpretExec exampleState)
-- This nukes the exec stack, just as an example of how to load at the start.
loadedState = loadProgarm [IntGene 6, IntGene 6, StateFunc instructionParameterLoad, StateFunc instructionIntAdd] emptyState
-- interpretExec -- interpretExec
testResult2 = [7,6,1,2,3] == int (interpretExec loaded) testResult3 = [12] == int (interpretExec loadedState)