1 package spoon.reflect.eval; 2 3 import java.util.ArrayList ; 4 import java.util.HashMap ; 5 import java.util.List ; 6 import java.util.Map ; 7 import java.util.Map.Entry; 8 9 import spoon.reflect.code.CtAbstractInvocation; 10 import spoon.reflect.reference.CtExecutableReference; 11 import spoon.reflect.reference.CtVariableReference; 12 13 16 public class SymbolicStackFrame { 17 18 21 public SymbolicStackFrame(SymbolicStackFrame frame) { 22 for (Entry<CtVariableReference, SymbolicInstance> e : frame.variables 23 .entrySet()) { 24 SymbolicInstance<?> i = e.getValue(); 25 variables.put(e.getKey(), i == null ? null : i.getClone()); 26 } 27 target = frame.target == null ? null : frame.target.getClone(); 28 result = frame.result == null ? null : frame.result.getClone(); 29 invocation = frame.invocation; 30 executable = frame.executable; 31 if (frame.arguments != null) { 32 arguments = new ArrayList <SymbolicInstance>(); 33 for (SymbolicInstance i : frame.arguments) { 34 arguments.add(i.getClone()); 35 } 36 } 37 } 38 39 42 @Override 43 public boolean equals(Object obj) { 44 SymbolicStackFrame f = (SymbolicStackFrame) obj; 45 return (target == null ? target == f.target : target.equals(f.target)) 46 && invocation == f.invocation 47 && executable.equals(f.executable) 48 && variables.equals(f.variables); 49 } 50 51 private Map <CtVariableReference, SymbolicInstance> variables = new HashMap <CtVariableReference, SymbolicInstance>(); 52 53 private SymbolicInstance target; 54 55 private CtAbstractInvocation invocation; 56 57 private CtExecutableReference executable; 58 59 62 public CtAbstractInvocation getInvocation() { 63 return invocation; 64 } 65 66 69 public SymbolicInstance getThis() { 70 return target; 71 } 72 73 76 public Map <CtVariableReference, SymbolicInstance> getVariables() { 77 return variables; 78 } 79 80 List <SymbolicInstance> arguments; 81 82 85 public List <SymbolicInstance> getArguments() { 86 return arguments; 87 } 88 89 101 public SymbolicStackFrame(CtAbstractInvocation invocation, 102 SymbolicInstance instance, CtExecutableReference executable, 103 List <SymbolicInstance> arguments, 104 Map <CtVariableReference, SymbolicInstance> variables) { 105 super(); 106 this.variables = variables; 107 this.target = instance; 108 this.invocation = invocation; 109 this.executable = executable; 110 this.arguments = arguments; 111 } 112 113 116 @Override 117 public String toString() { 118 return "" + executable.getSimpleName() + " on " + target + " variables=" 119 + variables + " arguments=" + arguments +" result="+result; 120 } 121 122 125 public CtExecutableReference getExecutable() { 126 return executable; 127 } 128 129 private SymbolicInstance result=null; 130 131 134 public SymbolicInstance getResult() { 135 return result; 136 } 137 138 141 public void setResult(SymbolicInstance result) { 142 this.result = result; 143 } 144 145 146 147 } 148 | Popular Tags |