[Swift-commit] r6516 - branches/faster/src/org/griphyn/vdl/engine

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Fri May 24 18:16:26 CDT 2013


Author: hategan
Date: 2013-05-24 18:16:26 -0500 (Fri, 24 May 2013)
New Revision: 6516

Modified:
   branches/faster/src/org/griphyn/vdl/engine/Karajan.java
   branches/faster/src/org/griphyn/vdl/engine/VariableScope.java
   branches/faster/src/org/griphyn/vdl/engine/Warnings.java
Log:
added warning types (not user-controllable at this time) and made shadowing warnings disabled by default

Modified: branches/faster/src/org/griphyn/vdl/engine/Karajan.java
===================================================================
--- branches/faster/src/org/griphyn/vdl/engine/Karajan.java	2013-05-24 22:51:14 UTC (rev 6515)
+++ branches/faster/src/org/griphyn/vdl/engine/Karajan.java	2013-05-24 23:16:26 UTC (rev 6516)
@@ -61,7 +61,6 @@
 import org.globus.swift.language.TypesDocument.Types.Type;
 import org.globus.swift.language.Variable.Mapping;
 import org.globus.swift.language.Variable.Mapping.Param;
-import org.globus.swift.language.impl.FunctionImpl;
 import org.griphyn.vdl.engine.VariableScope.EnclosureType;
 import org.griphyn.vdl.engine.VariableScope.WriteType;
 import org.griphyn.vdl.karajan.CompilationException;
@@ -727,7 +726,8 @@
 			ProcedureSignature proc = proceduresMap.get(procName);
 			
 			if (proc.isDeprecated()) {
-			    Warnings.warn(call, "Procedure " + procName + " is deprecated");
+			    Warnings.warn(Warnings.Type.DEPRECATION, 
+			        call, "Procedure " + procName + " is deprecated");
 			}
 			
 			StringTemplate callST;
@@ -1651,7 +1651,8 @@
         /* Functions have only one output parameter */
         st.setAttribute("datatype", funcSignature.getOutputArray(0).getType());
         if (funcSignature.isDeprecated()) {
-            Warnings.warn(c, "Function " + name + " is deprecated");
+            Warnings.warn(Warnings.Type.DEPRECATION, 
+                c, "Function " + name + " is deprecated");
         }
         
         return st;
@@ -1664,7 +1665,8 @@
         }
         else {
             // the @var shortcut for filename(var) is not deprecated
-            Warnings.warn("The @ syntax for function invocation is deprecated");
+            Warnings.warn(Warnings.Type.DEPRECATION, 
+                "The @ syntax for function invocation is deprecated");
         }
         ProcedureSignature funcSignature = functionsMap.get(name);
         if (funcSignature == null) {
@@ -1676,7 +1678,8 @@
         st.setAttribute("datatype", funcSignature.getOutputArray(0).getType());
         
         if (funcSignature.isDeprecated()) {
-            Warnings.warn(f, "Function " + name + " is deprecated");
+            Warnings.warn(Warnings.Type.DEPRECATION, 
+                f, "Function " + name + " is deprecated");
         }
     
         return st;

Modified: branches/faster/src/org/griphyn/vdl/engine/VariableScope.java
===================================================================
--- branches/faster/src/org/griphyn/vdl/engine/VariableScope.java	2013-05-24 22:51:14 UTC (rev 6515)
+++ branches/faster/src/org/griphyn/vdl/engine/VariableScope.java	2013-05-24 23:16:26 UTC (rev 6516)
@@ -327,8 +327,9 @@
 		// by the above if? in which case isVariableDefined should
 		// be replaced by is locally defined test.
 		if(parentScope != null && parentScope.isVariableDefined(name)) {
-		    Warnings.warn(context + " " + name + ", on line " + CompilerUtils.getLine(src)
-			+ ", shadows variable of same name on line " + parentScope.getDeclarationLine(name));
+		    Warnings.warn(Warnings.Type.SHADOWING,  
+		        context + " " + name + ", on line " + CompilerUtils.getLine(src)
+		        + ", shadows variable of same name on line " + parentScope.getDeclarationLine(name));
 		}
 
 		if (global && this != rootScope) {
@@ -484,7 +485,7 @@
 		    case CONDITION:
 		        if (parentScope.isVariableWriteable(name, WriteType.PARTIAL)) {
 		            if (getTopmostLoopToDeclaration(name) != null) {
-		                Warnings.warn("Variable " + name + ", defined on line " + 
+		                Warnings.warn(Warnings.Type.DATAFLOW, "Variable " + name + ", defined on line " + 
 		                    getDeclarationLine(name) + ", might have multiple conflicting writers");
 		            }
 		            return true;

Modified: branches/faster/src/org/griphyn/vdl/engine/Warnings.java
===================================================================
--- branches/faster/src/org/griphyn/vdl/engine/Warnings.java	2013-05-24 22:51:14 UTC (rev 6515)
+++ branches/faster/src/org/griphyn/vdl/engine/Warnings.java	2013-05-24 23:16:26 UTC (rev 6516)
@@ -9,33 +9,49 @@
  */
 package org.griphyn.vdl.engine;
 
+import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.log4j.Logger;
 import org.apache.xmlbeans.XmlObject;
-import org.w3c.dom.Node;
 
 public class Warnings {
     public static final Logger logger = Logger.getLogger(Warnings.class);
     
+    public static enum Type {
+        DEPRECATION, 
+        SHADOWING, 
+        DATAFLOW
+    }
+    
     private static Set<String> warnings = new HashSet<String>();
+    private static EnumSet<Type> enabledWarnings = EnumSet.noneOf(Type.class);
     
-    public static void warn(XmlObject obj, String msg) {
-        if (!warnings.contains(msg)) {
-            warnings.add(msg);
-            msg = "Warning: " + msg + ", at " + CompilerUtils.getLine(obj.getDomNode());
-            logger.info(msg);
-            System.err.println(msg);
+    static {
+        enabledWarnings.add(Type.DEPRECATION);
+        enabledWarnings.add(Type.DATAFLOW);
+    }
+    
+    public static void warn(Type type, XmlObject obj, String msg) {
+        if (enabledWarnings.contains(type)) {
+            if (!warnings.contains(msg)) {
+                warnings.add(msg);
+                msg = "Warning: " + msg + ", at " + CompilerUtils.getLine(obj.getDomNode());
+                logger.info(msg);
+                System.err.println(msg);
+            }
         }
     }
     
-    public static void warn(String msg) {
-        if (!warnings.contains(msg)) {
-            warnings.add(msg);
-            msg = "Warning: " + msg;
-            logger.info(msg);
-            System.err.println(msg);
+    public static void warn(Type type, String msg) {
+        if (enabledWarnings.contains(type)) {
+            if (!warnings.contains(msg)) {
+                warnings.add(msg);
+                msg = "Warning: " + msg;
+                logger.info(msg);
+                System.err.println(msg);
+            }
         }
     }
 }




More information about the Swift-commit mailing list