22
33import java .util .ArrayList ;
44import java .util .List ;
5+ import java .util .stream .Collectors ;
56
67import liquidjava .api .CommandLineLauncher ;
78import liquidjava .processor .VCImplication ;
89import liquidjava .rj_language .Predicate ;
910import liquidjava .rj_language .ast .BinaryExpression ;
1011import liquidjava .rj_language .ast .Expression ;
1112import liquidjava .rj_language .ast .GroupExpression ;
13+ import liquidjava .smt .Counterexample ;
1214import liquidjava .utils .Utils ;
1315import spoon .reflect .cu .SourcePosition ;
1416import spoon .reflect .reference .CtTypeReference ;
@@ -29,6 +31,7 @@ public final class DebugLog {
2931
3032 private static final String SMT_TAG = Colors .BLUE + "[SMT]" + Colors .RESET ;
3133 private static final String SMT_CHECK = Colors .SALMON + "[SMT CHECK]" + Colors .RESET ;
34+ private static final String SMP_TAG = Colors .YELLOW + "[SMP]" + Colors .RESET ;
3235
3336 private DebugLog () {
3437 }
@@ -123,6 +126,18 @@ public static void smtStart(VCImplication chain, Predicate extraPremise, Predica
123126 System .out .println (SMT_TAG + " " + formatConclusion (conclusion ));
124127 }
125128
129+ /**
130+ * Print the simplifier input and output side by side. This keeps the raw expression visible in debug traces while
131+ * callers continue using the simplified expression for user-facing diagnostics.
132+ */
133+ public static void simplification (Expression input , Expression output ) {
134+ if (!enabled ()) {
135+ return ;
136+ }
137+ System .out .println (SMP_TAG + " Before simplification: " + Colors .YELLOW + input + Colors .RESET );
138+ System .out .println (SMP_TAG + " After simplification: " + Colors .BOLD_YELLOW + output + Colors .RESET );
139+ }
140+
126141 private static String plainLabel (VCImplication node ) {
127142 return node .getName () + " : " + simpleType (node .getType ());
128143 }
@@ -215,14 +230,14 @@ public static void smtUnsat() {
215230 if (!enabled ()) {
216231 return ;
217232 }
218- System .out .println (SMT_TAG + " result : " + Colors .GREEN + "UNSAT (subtype holds)" + Colors .RESET );
233+ System .out .println (SMT_TAG + " Result : " + Colors .GREEN + "UNSAT (subtype holds)" + Colors .RESET );
219234 }
220235
221236 public static void smtSat (Object counterexample ) {
222237 if (!enabled ()) {
223238 return ;
224239 }
225- String header = SMT_TAG + " result : " + Colors .RED + "SAT (subtype fails)" + Colors .RESET ;
240+ String header = SMT_TAG + " Result : " + Colors .RED + "SAT (subtype fails)" + Colors .RESET ;
226241 String pretty = formatCounterexample (counterexample );
227242 if (pretty == null ) {
228243 System .out .println (header );
@@ -266,7 +281,7 @@ public static void smtUnknown() {
266281 if (!enabled ()) {
267282 return ;
268283 }
269- System .out .println (SMT_TAG + " result : " + Colors .YELLOW + "UNKNOWN (treated as OK)" + Colors .RESET );
284+ System .out .println (SMT_TAG + " Result : " + Colors .YELLOW + "UNKNOWN (treated as OK)" + Colors .RESET );
270285 }
271286
272287 /**
@@ -292,7 +307,7 @@ public static void smtError(String message) {
292307 if (!enabled ()) {
293308 return ;
294309 }
295- System .out .println (SMT_TAG + " result : " + Colors .RED + "ERROR" + Colors .RESET + " — "
310+ System .out .println (SMT_TAG + " Result : " + Colors .RED + "ERROR" + Colors .RESET + " — "
296311 + (message == null ? "(no message)" : message ));
297312 }
298313}
0 commit comments