Reviewers: Yang,
Description:
Issue 2089 Expose value wrapper's inner values
Please review this at https://chromiumcodereview.appspot.com/10091022/
SVN Base: https://v8.googlecode.com/svn/trunk
Affected files:
M src/mirror-debugger.js
M src/runtime.h
M src/runtime.cc
Index: src/mirror-debugger.js
diff --git a/src/mirror-debugger.js b/src/mirror-debugger.js
index
c43dd228ec9d12c73a0d66a4102477649f85862f..e39dc5de8760eba4e14798fc378badb9022ab023
100644
--- a/src/mirror-debugger.js
+++ b/src/mirror-debugger.js
@@ -596,6 +596,22 @@ ObjectMirror.prototype.protoObject = function() {
};
+/**
+ * Return the primitive value if this is object of Boolean, Number or
String type (but not Date).
+ * Otherwise return undefined.
+ */
+ObjectMirror.prototype.primitiveValue = function() {
+ if (!IS_STRING_WRAPPER(this.value_) && !IS_NUMBER_WRAPPER(this.value_)
&& !IS_BOOLEAN_WRAPPER(this.value_)) {
+ return void 0;
+ }
+ var primitiveValue = %DebugGetPrimitiveValue(this.value_);
+ if (IS_UNDEFINED(primitiveValue)) {
+ return void 0;
+ }
+ return MakeMirror(primitiveValue);
+};
+
+
ObjectMirror.prototype.hasNamedInterceptor = function() {
// Get information on interceptors for this object.
var x = %GetInterceptorInfo(this.value_);
@@ -2233,6 +2249,11 @@ JSONProtocolSerializer.prototype.serializeObject_ =
function(mirror, content,
this.serializeReference(mirror.constructorFunction());
content.protoObject = this.serializeReference(mirror.protoObject());
content.prototypeObject =
this.serializeReference(mirror.prototypeObject());
+
+ var primitiveValue = mirror.primitiveValue();
+ if (!IS_UNDEFINED(primitiveValue)) {
+ content.primitiveValue = this.serializeReference(primitiveValue);
+ }
// Add flags to indicate whether there are interceptors.
if (mirror.hasNamedInterceptor()) {
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
3c65d09d2b1dcd06747c54222d65e6e46ef98f41..a20c8ee42401cb89a145b1d238b6a60e7020d618
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -12270,6 +12270,23 @@ RUNTIME_FUNCTION(MaybeObject*,
Runtime_DebugGetPrototype) {
}
+// Returns internal property PrimitiveValue value for standard objects
+// Boolean, Number and String (not for Date). Otherwise returns undefined.
+// args[0]: the object that possibly holds PrimitiveValue property.
+RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPrimitiveValue) {
+ ASSERT(args.length() == 1);
+
+ CONVERT_ARG_CHECKED(JSObject, obj, 0);
+
+ if (!obj->IsJSValue()) {
+ return isolate->heap()->undefined_value();
+ }
+ JSValue* value = JSValue::cast(obj);
+
+ return value->value();
+}
+
+
// Patches script source (should be called upon BeforeCompile event).
RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugSetScriptSource) {
HandleScope scope(isolate);
Index: src/runtime.h
diff --git a/src/runtime.h b/src/runtime.h
index
fe9cfd9b2f3956a807b5bff556a443a7a188f7c9..e73d96776af3c11a74ae136dc28e5798e880df79
100644
--- a/src/runtime.h
+++ b/src/runtime.h
@@ -418,6 +418,7 @@ namespace internal {
F(DebugReferencedBy, 3, 1) \
F(DebugConstructedBy, 2, 1) \
F(DebugGetPrototype, 1, 1) \
+ F(DebugGetPrimitiveValue, 1, 1) \
F(DebugSetScriptSource, 2, 1) \
F(SystemBreak, 0, 1) \
F(DebugDisassembleFunction, 1, 1) \
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev