Introduce more helpers like Type::isArray.

class Type had methods isArray and isNull, but not methods like isBoolean. This change introduces helpers for the other types that frequently need to be tested for in type specialization code. The change is kept small so that is is obviously correct and easy to push quickly. Making all type tests consistent will have to be achieved incrementally.
Esse commit está contido em:
hermanv
2013-03-31 12:42:41 -07:00
commit de Sara Golemon
commit 2a75bbce25
2 arquivos alterados com 26 adições e 10 exclusões
@@ -2020,15 +2020,15 @@ void HhbcTranslator::emitCastArray() {
push(src);
} else if (fromType.isNull()) {
push(m_tb->genDefConst(HphpArray::GetStaticEmptyArray()));
} else if (fromType.equals(Type::Bool)) {
} else if (fromType.isBool()) {
push(m_tb->gen(ConvBoolToArr, src));
} else if (fromType.equals(Type::Dbl)) {
} else if (fromType.isDbl()) {
push(m_tb->gen(ConvDblToArr, src));
} else if (fromType.equals(Type::Int)) {
} else if (fromType.isInt()) {
push(m_tb->gen(ConvIntToArr, src));
} else if (fromType.isString()) {
push(m_tb->gen(ConvStrToArr, src));
} else if (fromType.subtypeOf(Type::Obj)) {
} else if (fromType.isObj()) {
push(m_tb->gen(ConvObjToArr, src));
} else {
push(m_tb->gen(ConvGenToArr, src));
@@ -2044,19 +2044,19 @@ void HhbcTranslator::emitCastBool() {
void HhbcTranslator::emitCastDouble() {
SSATmp* src = popC();
Type fromType = src->getType();
if (fromType.equals(Type::Dbl)) {
if (fromType.isDbl()) {
push(src);
} else if (fromType.isNull()) {
push(m_tb->genDefConst(0.0));
} else if (fromType.isArray()) {
push(m_tb->gen(ConvArrToDbl, src));
} else if (fromType.equals(Type::Bool)) {
} else if (fromType.isBool()) {
push(m_tb->gen(ConvBoolToDbl, src));
} else if (fromType.equals(Type::Int)) {
} else if (fromType.isInt()) {
push(m_tb->gen(ConvIntToDbl, src));
} else if (fromType.isString()) {
push(m_tb->gen(ConvStrToDbl, src));
} else if (fromType.subtypeOf(Type::Obj)) {
} else if (fromType.isObj()) {
spillStack(); // may throw
push(m_tb->gen(ConvObjToDbl, src));
} else {
+18 -2
Ver Arquivo
@@ -1161,14 +1161,30 @@ public:
return subtypeOf(Arr);
}
bool isString() const {
return subtypeOf(Str);
bool isBool() const {
return subtypeOf(Bool);
}
bool isDbl() const {
return subtypeOf(Dbl);
}
bool isInt() const {
return subtypeOf(Int);
}
bool isNull() const {
return subtypeOf(Null);
}
bool isObj() const {
return subtypeOf(Obj);
}
bool isString() const {
return subtypeOf(Str);
}
Type innerType() const {
assert(isBoxed());
return Type(m_bits >> kBoxShift);