在子类化的情况下,V8 instance_type如何工作?专门用于内置的数组

问题描述

我正试图绕过V8中的JSON.stringify仍然如何导致子类数组的方括号表示法(HeapObject::cast(*object).map().instance_type()

在V8代码中,我看到JSON.stringify代码打开了#include <QCoreApplication> #include <QDebug> #include <QMetaType> #include <QRect> #include <QMetaObject> class MyType { public: int _member; }; // needed for getType2() Q_DECLARE_MetaTYPE(MyType); // needed for getType() const int id = qRegisterMetaType<MyType>("MyType"); template <class T> class MyClass { public: int getType() { return QMetaType::type(typeid(T).name()); } int getType2() { return qMetaTypeId<T>(); } }; int main(int argc,char *argv[]) { QCoreApplication a(argc,argv); qDebug() << MyClass<int>().getType(); qDebug() << MyClass<QString>().getType(); qDebug() << MyClass<QRect>().getType(); qDebug() << MyClass<MyType>().getType(); qDebug() << MyClass<int>().getType2(); qDebug() << MyClass<QString>().getType2(); qDebug() << MyClass<QRect>().getType2(); qDebug() << MyClass<MyType>().getType2(); return a.exec(); } (请参见https://github.com/v8/v8/blob/master/src/json/json-stringifier.cc#L539

对我来说,代码看起来像是直接读取表示我的数组子类实例的内部映射的instance_type,这意味着在创建类的实例时,instance_type设置为JS_ARRAY_TYPE在原型中的某个位置链中有一个数组。

我一直在浏览代码库,但无法弄清楚这种情况的发生方式/位置。

任何指针表示赞赏!

TIA, 保罗

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)