Typeof和Expression * in V8 [英] Typeof and Expression* in V8
问题描述
我正在试验V8引擎。
在V8(full-codegen-x64.cc)中存在比较类型的函数:
In V8 (full-codegen-x64.cc) exists this function for comparing types:
void FullCodeGenerator::EmitLiteralCompareTypeof(Expression* expr,
Expression* sub_expr,
Handle<String> check)
因此,如果例如:
typeof Obj == "object"
然后 sub_expr 是具有typeof Obj且检查是对象的表达式对象。
如果可能,如何从Expression对象获取JSObject? - 不可能a syntax of syntax Andreas Rossberg)
How can I get a JSObject from an Expression object, if possible? - not possible (You can't. An Expression is a piece of syntax Andreas Rossberg)
在void FullCodeGenerator :: EmitLiteralCompareTypeof 我们可以检查if:
In void FullCodeGenerator::EmitLiteralCompareTypeof we can check if :
Obj is function __ CmpObjectType(rax, JS_FUNCTION_TYPE, rdx);
Obj is proxy function __ CmpInstanceType(rdx, JS_FUNCTION_PROXY_TYPE);
Obj is proxy __ CmpObjectType(rax, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE, rdx);
and etc...
只是例如如果我们将使用此代码: p>
Just for example if we will use this code:
__ CmpObjectType(rax, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE, rdx);
__ j(equal, if_true);
then
typeof Proxy_Obj == 'string' ---> true
V8如何知道?是否 - V8运行代码?
推荐答案
表达式是一段语法,JSObject是一个运行时对象。他们与对方绝对没有关系。
You can't. An Expression is a piece of syntax, a JSObject is a runtime object. They have absolutely nothing to do with each other.
这篇关于Typeof和Expression * in V8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!