How to get variable name of an object in c++ level?

30 views
Skip to first unread message

L TY

unread,
Oct 26, 2020, 7:04:00 AM10/26/20
to v8-dev
Hello,

I need to get the variable name of an object name in c++ level.
For example
```
var a = "test";
```
I need to get the string "a" from the internal Handle<Object> representation of `a`.

Anyone has idea how to do it?

Yang Guo

unread,
Oct 26, 2020, 7:06:51 AM10/26/20
to v8-...@googlegroups.com
There is no simple way. The object itself does not know that it has been assigned to the variable "a". Also, semantics here seems fuzzy:

var a = "test";
var b = a;

What's the name?

However, you could figure out some of this if you collect a heap snapshot and see what the retaining paths of that object are.

Yang



--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/cbb4c7c5-e2a6-4880-ac77-694db70fa6f9n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages