01: package spoon.reflect.eval.observer;
02:
03: import spoon.processing.Environment;
04: import spoon.reflect.eval.SymbolicEvaluationStep;
05: import spoon.reflect.eval.SymbolicEvaluator;
06: import spoon.reflect.eval.SymbolicEvaluatorObserver;
07: import spoon.support.reflect.eval.VisitorSymbolicEvaluator;
08:
09: /**
10: * This symbolic evaluator observer is a printer of what happens during the
11: * evaluation. It does not memorize any evaluation data.
12: */
13: public class SymbolicEvaluationPrinter implements
14: SymbolicEvaluatorObserver {
15:
16: private int stepNumber = 0;
17: private int pathNumber = 0;
18: private Environment environment;
19:
20: /**
21: * The default constructor.
22: * @param environment the environment in which the printing of the evaluation messages should be done
23: */
24: public SymbolicEvaluationPrinter(Environment environment) {
25: this .environment = environment;
26: }
27:
28: public void onStartPath(SymbolicEvaluator evaluator) {
29: stepNumber = 0;
30: pathNumber++;
31: environment.reportProgressMessage("-- start dump path "
32: + pathNumber);
33: }
34:
35: public void onExitStep(VisitorSymbolicEvaluator evaluator,
36: SymbolicEvaluationStep step) {
37: environment.reportProgressMessage(++stepNumber + "\t"
38: + step.getKind() + " " + step.getFrame());
39: step.getHeap().dump();
40: }
41:
42: public void onEndPath(SymbolicEvaluator evaluator) {
43: environment.reportProgressMessage("-- end dump path "
44: + pathNumber);
45: }
46:
47: public void onEnterStep(SymbolicEvaluator evaluator,
48: SymbolicEvaluationStep step) {
49: environment.reportProgressMessage((++stepNumber) + "\t"
50: + step.getKind() + " " + step.getFrame());
51: step.getHeap().dump();
52: }
53:
54: }
|