The evaluator evaluates a sequence of directives and generates a list of actions that are later read and executed by the viewer. The evaluation starts with the directive on the first line, which is a jump to the start address of the main
function. The evaluation stops when it encounters a return
directive without a return address. In that case, we have reached the end of main
and the execution shall be finished.
The evaluator works against a stack of values. Each time a value has been evaluated it is pushed on the stack, and each time values are needed to evaluate an expression they are popped from the stack.
Evaluator.h:
#ifndef EVALUATOR_H #define EVALUATOR_H #include <QtWidgets> #include "Error.h" #include "Directive.h" #include "Action.h" #include "Function.h"
The constructor of the Evaluator
class evaluates the directive list with the help of the functions map:
class Evaluator { public: Evaluator(const QList<Directive>& directiveList, ...