]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/SSAValidationContext.java
Replace System.err and System.out with SLF4J Logging
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / codegen / utils / SSAValidationContext.java
index 923acdba26115c6cd18d2a95d3bc15267a9a5536..22c7c7429432404655b5b55dfbdda47b1afd7ab4 100644 (file)
@@ -12,6 +12,8 @@ import org.simantics.scl.compiler.types.TVar;
 import org.simantics.scl.compiler.types.Type;
 import org.simantics.scl.compiler.types.Types;
 import org.simantics.scl.compiler.types.util.TypeUnparsingContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.map.hash.TObjectIntHashMap;
 import gnu.trove.procedure.TObjectIntProcedure;
@@ -19,6 +21,8 @@ import gnu.trove.set.hash.THashSet;
 
 public class SSAValidationContext {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(SSAValidationContext.class);
+
     public THashSet<BoundVar> validBoundVariables = new THashSet<BoundVar>();
     public THashSet<Cont> validContinuations = new THashSet<Cont>();
     public THashSet<TVar> validTypeVariables = new THashSet<TVar>();
@@ -28,9 +32,10 @@ public class SSAValidationContext {
     public void assertEquals(Object loc, Type a, Type b) {
         if(!Types.equals(a, b)) {
             TypeUnparsingContext tuc = new TypeUnparsingContext();
-            System.err.println(a.toString(tuc) + " != " + b.toString(tuc));
+            String message = a.toString(tuc) + " != " + b.toString(tuc);
+            LOGGER.error(message);
             setErrorMarker(loc);
-            throw new InternalCompilerError();
+            throw new InternalCompilerError(message);
         }
     }
     
@@ -46,9 +51,10 @@ public class SSAValidationContext {
     public void assertEqualsEffect(Object loc, Type a, Type b) {
         if(!Types.equalsEffect(a, b)) {
             TypeUnparsingContext tuc = new TypeUnparsingContext();
-            System.err.println(a.toString(tuc) + " != " + b.toString(tuc));
+            String message = a.toString(tuc) + " != " + b.toString(tuc);
+            LOGGER.error(message);
             setErrorMarker(loc);
-            throw new InternalCompilerError();
+            throw new InternalCompilerError(message);
         }
     }
     
@@ -105,8 +111,8 @@ public class SSAValidationContext {
                 
                 int realCount = val.occurrenceCount();
                 if(realCount != count) {
-                    System.out.println(val + ": " + realCount + " != " + count);
-                    invalidReferenceCounts = true;                    
+                    LOGGER.warn(val + ": " + realCount + " != " + count);
+                    invalidReferenceCounts = true;
                 }
                 return true;
             }