Reviewers: Søren Gjesse,

Message:
Hi Sorren

Could you please take a look at this change?

Thanks,
Peter

Description:
Report function source position via JSON protocol

Please review this at http://codereview.chromium.org/341024

Affected files:
   M src/mirror-delay.js


Index: src/mirror-delay.js
diff --git a/src/mirror-delay.js b/src/mirror-delay.js
index  
cde553432149a14b4293eede4d4dc19b5dfef224..33244979ac41e95198d40e1c930921fa31d7fb9f
  
100644
--- a/src/mirror-delay.js
+++ b/src/mirror-delay.js
@@ -849,6 +849,19 @@ FunctionMirror.prototype.script = function() {


  /**
+ * Returns the script source location object for the function. Only makes  
sense
+ * for functions which has a script defined.
+ * @return {Location or undefined} in-script location for the function  
begin
+ */
+FunctionMirror.prototype.sourceLocation = function() {
+  if (this.resolved() && this.script()) {
+    return this.script().locationFromPosition(this.sourcePosition(),
+                                              true);
+  }
+};
+
+
+/**
   * Returns objects constructed by this function.
   * @param {number} opt_max_instances Optional parameter specifying the  
maximum
   *     number of instances to return.
@@ -2119,6 +2132,9 @@ JSONProtocolSerializer.prototype.serializeObject_ =  
function(mirror, content,
      }
      if (mirror.script()) {
        content.script = this.serializeReference(mirror.script());
+      content.scriptId = mirror.script().id();
+
+      serializeLocationFields(mirror.sourceLocation(), content);
      }
    }

@@ -2151,6 +2167,31 @@ JSONProtocolSerializer.prototype.serializeObject_ =  
function(mirror, content,


  /**
+ * Serialize location information to the following JSON format:
+ *
+ *   "position":"<position>",
+ *   "line":"<line>",
+ *   "column":"<column>",
+ *
+ * @param {SourceLocation} location The location to serialize, may be  
undefined.
+ */
+function serializeLocationFields (location, content) {
+  if (!location) {
+    return;
+  }
+  content.sourcePosition = location.position;
+  var line = location.line;
+  if (!IS_UNDEFINED(line)) {
+    content.line = line;
+  }
+  var column = location.column;
+  if (!IS_UNDEFINED(column)) {
+    content.column = column;
+  }
+}
+
+
+/**
   * Serialize property information to the following JSON format for  
building the
   * array of properties.
   *



--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to