Make Runfiles.SymlinkEntry implement SkylarkValue.

Fixes #1109

Closes #2126.

--
Reviewed-on: https://github.com/bazelbuild/bazel/pull/2126
MOS_MIGRATED_REVID=140217086
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java b/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java
index 0de1b2d..80d6757 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java
@@ -33,10 +33,11 @@
 import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;
+import com.google.devtools.build.lib.skylarkinterface.SkylarkValue;
+import com.google.devtools.build.lib.syntax.Printer;
 import com.google.devtools.build.lib.util.Preconditions;
 import com.google.devtools.build.lib.vfs.Path;
 import com.google.devtools.build.lib.vfs.PathFragment;
-
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
@@ -49,7 +50,6 @@
 import java.util.Objects;
 import java.util.Set;
 import java.util.TreeSet;
-
 import javax.annotation.Nullable;
 
 /**
@@ -104,7 +104,7 @@
    * An entry in the runfiles map.
    *
    * <p>build-runfiles.cc enforces the following constraints: The PathFragment must not be an
-   * absolute path, nor contain "..".  Overlapping runfiles links are also refused. This is the case
+   * absolute path, nor contain "..". Overlapping runfiles links are also refused. This is the case
    * where you ask to create a link to "foo" and also "foo/bar.txt". I.e. you're asking it to make
    * "foo" both a file (symlink) and a directory.
    *
@@ -129,7 +129,7 @@
   // equals to the third one if they are not the same instance (which they almost never are)
   //
   // Goodnight, prince(ss)?, and sweet dreams.
-  private static final class SymlinkEntry {
+  private static final class SymlinkEntry implements SkylarkValue {
     private final PathFragment path;
     private final Artifact artifact;
 
@@ -145,6 +145,18 @@
     public Artifact getArtifact() {
       return artifact;
     }
+
+    public boolean isImmutable() {
+      return true;
+    }
+
+    public void write(Appendable buffer, char quotationMark) {
+      Printer.append(buffer, "SymlinkEntry(path = ");
+      Printer.write(buffer, getPath().toString(), quotationMark);
+      Printer.append(buffer, ", artifact = ");
+      getArtifact().write(buffer, quotationMark);
+      Printer.append(buffer, ")");
+    }
   }
 
   // It is important to declare this *after* the DUMMY_SYMLINK_EXPANDER to avoid NPEs