Skip to content

Commit

Permalink
Eliminate int32, uint32, int16, uint16, int8, uint8.
Browse files Browse the repository at this point in the history
This concludes the inttypes replacement.
These replacement have been mostly mechanical
with the use of cxx_replace.
  • Loading branch information
aalexandre authored and sgolemon committed Mar 9, 2013
1 parent c7bb7d8 commit 2617812
Show file tree
Hide file tree
Showing 400 changed files with 4,507 additions and 4,510 deletions.
4 changes: 2 additions & 2 deletions hphp/compiler/analysis/alias_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4146,9 +4146,9 @@ void AliasManager::stringOptsRecur(StatementPtr s) {
case Statement::KindOfBreakStatement:
{
BreakStatementPtr b = spc(BreakStatement, s);
int64 depth = b->getDepth();
int64_t depth = b->getDepth();
if (depth != 1) {
int64 s = m_loopInfo.size() - 1;
int64_t s = m_loopInfo.size() - 1;
if (s >= 0) {
if (!depth || depth > s) depth = s;
while (depth--) {
Expand Down
8 changes: 4 additions & 4 deletions hphp/compiler/analysis/analysis_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ class AnalysisResult : public BlockScope, public FunctionContainer {
/**
* Literal string to String precomputation
*/
std::string getLiteralStringName(int64 hash, int index, bool iproxy = false);
std::string getLitVarStringName(int64 hash, int index, bool iproxy = false);
std::string getLiteralStringName(int64_t hash, int index, bool iproxy = false);
std::string getLitVarStringName(int64_t hash, int index, bool iproxy = false);
int getLiteralStringId(const std::string &s, int &index);

/**
Expand All @@ -290,12 +290,12 @@ class AnalysisResult : public BlockScope, public FunctionContainer {
int m_arrayLitstrKeyMaxSize;
int m_arrayIntegerKeyMaxSize;

std::string getHashedName(int64 hash, int index, const char *prefix,
std::string getHashedName(int64_t hash, int index, const char *prefix,
bool longName = false);
void addNamedLiteralVarString(const std::string &s);
void addNamedScalarVarArray(const std::string &s);
StringToClassScopePtrVecMap getExtensionClasses();
void addInteger(int64 n);
void addInteger(int64_t n);
private:
Package *m_package;
bool m_parseOnDemand;
Expand Down
46 changes: 23 additions & 23 deletions hphp/compiler/analysis/emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,10 @@ static int32_t countStackValues(const std::vector<uchar>& immVec) {
#define DEC_MA std::vector<uchar>
#define DEC_BLA std::vector<Label*>&
#define DEC_SLA std::vector<StrOff>&
#define DEC_IVA int32
#define DEC_HA int32
#define DEC_IA int32
#define DEC_I64A int64
#define DEC_IVA int32_t
#define DEC_HA int32_t
#define DEC_IA int32_t
#define DEC_I64A int64_t
#define DEC_DA double
#define DEC_SA const StringData*
#define DEC_AA ArrayData*
Expand Down Expand Up @@ -786,7 +786,7 @@ bool SymbolicStack::getNotRef() const {
return se.notRef;
}

void SymbolicStack::setInt(int64 v) {
void SymbolicStack::setInt(int64_t v) {
assert(m_symStack.size());
m_symStack.back().intval = v;
}
Expand Down Expand Up @@ -932,7 +932,7 @@ int SymbolicStack::getLoc(int index) const {
return m_symStack[index].intval;
}

int64 SymbolicStack::getInt(int index) const {
int64_t SymbolicStack::getInt(int index) const {
assert(m_symStack.size() > size_t(index));
assert(StackSym::GetSymFlavor(m_symStack[index].sym) == StackSym::I);
return m_symStack[index].intval;
Expand Down Expand Up @@ -1094,7 +1094,7 @@ void MetaInfoBuilder::setForUnit(UnitEmitter& target) const {

vector<Offset> index1;
vector<Offset> index2;
vector<uint8> data;
vector<uint8_t> data;
index1.push_back(entries);

size_t sz1 = (2 + entries) * sizeof(Offset);
Expand All @@ -1114,8 +1114,8 @@ void MetaInfoBuilder::setForUnit(UnitEmitter& target) const {
data.push_back(mi.m_data << 1);
} else {
union {
uint32 val;
uint8 bytes[4];
uint32_t val;
uint8_t bytes[4];
} u;
u.val = (mi.m_data << 1) | 1;
for (int j = 0; j < 4; j++) {
Expand All @@ -1128,7 +1128,7 @@ void MetaInfoBuilder::setForUnit(UnitEmitter& target) const {
index2.push_back(sz1 + sz2 + data.size());

size_t size = sz1 + sz2 + data.size();
uint8* meta = (uint8*)malloc(size);
uint8_t* meta = (uint8_t*)malloc(size);
memcpy(meta, &index1[0], sz1);
memcpy(meta + sz1, &index2[0], sz2);
memcpy(meta + sz1 + sz2, &data[0], data.size());
Expand Down Expand Up @@ -1953,7 +1953,7 @@ bool EmitterVisitor::visitImpl(ConstructPtr node) {
case Statement::KindOfContinueStatement:
case Statement::KindOfBreakStatement: {
BreakStatementPtr bs(static_pointer_cast<BreakStatement>(s));
int64 n = bs->getDepth();
int64_t n = bs->getDepth();
if (n == 1) {
// Plain old "break;" or "continue;"
if (m_contTargets.empty()) {
Expand Down Expand Up @@ -1985,7 +1985,7 @@ bool EmitterVisitor::visitImpl(ConstructPtr node) {
emitConvertToCell(e);
} else {
// Dynamic break/continue with statically known depth.
if (n > (int64)m_contTargets.size()) {
if (n > (int64_t)m_contTargets.size()) {
std::ostringstream msg;
msg << "Cannot break/continue " << n << " levels";
e.String(StringData::GetStaticString(msg.str()));
Expand Down Expand Up @@ -3684,11 +3684,11 @@ bool EmitterVisitor::visitImpl(ConstructPtr node) {
ScalarExpressionPtr sval(
static_pointer_cast<ScalarExpression>(key));
const std::string* s;
int64 i;
int64_t i;
double d;
if (sval->getString(s)) {
StringData* sd = StringData::GetStaticString(*s);
int64 n = 0;
int64_t n = 0;
if (sd->isStrictlyInteger(n)) {
tvKey.m_data.num = n;
tvKey.m_type = KindOfInt64;
Expand Down Expand Up @@ -4101,9 +4101,9 @@ void EmitterVisitor::buildVectorImm(std::vector<uchar>& vectorImm,
encodeIvaToVector(vectorImm, m_evalStack.getLoc(i));
} else if (symFlavor == StackSym::T) {
assert(strid != -1);
encodeToVector<int32>(vectorImm, strid);
encodeToVector<int32_t>(vectorImm, strid);
} else if (symFlavor == StackSym::I) {
encodeToVector<int64>(vectorImm, m_evalStack.getInt(i));
encodeToVector<int64_t>(vectorImm, m_evalStack.getInt(i));
}

++i;
Expand Down Expand Up @@ -4968,7 +4968,7 @@ DataType EmitterVisitor::analyzeSwitch(SwitchStatementPtr sw,
} else {
return KindOfInvalid;
}
int64 n;
int64_t n;
bool isNonZero;
if (t == KindOfInt64) {
n = cval.asInt64Val();
Expand Down Expand Up @@ -5002,8 +5002,8 @@ DataType EmitterVisitor::analyzeSwitch(SwitchStatementPtr sw,
}

if (t == KindOfInt64) {
int64 base = caseMap.begin()->first;
int64 nTargets = caseMap.rbegin()->first - base + 1;
int64_t base = caseMap.begin()->first;
int64_t nTargets = caseMap.rbegin()->first - base + 1;
// Fail if the cases are too sparse
if ((float)caseMap.size() / nTargets < 0.5) {
return KindOfInvalid;
Expand All @@ -5021,8 +5021,8 @@ void EmitterVisitor::emitIntegerSwitch(Emitter& e, SwitchStatementPtr sw,
std::vector<Label>& caseLabels,
Label& done, const SwitchState& state) {
auto& caseMap = state.cases;
int64 base = caseMap.begin()->first;
int64 nTargets = caseMap.rbegin()->first - base + 1;
int64_t base = caseMap.begin()->first;
int64_t nTargets = caseMap.rbegin()->first - base + 1;

// It's on. Map case values to Labels, filling in the blanks as
// appropriate.
Expand Down Expand Up @@ -6913,7 +6913,7 @@ void EmitterVisitor::initScalar(TypedValue& tvVal, ExpressionPtr val) {
tvVal.m_type = KindOfString;
break;
}
int64 i;
int64_t i;
if (sval->getInt(i)) {
tvVal.m_data.num = i;
tvVal.m_type = KindOfInt64;
Expand Down Expand Up @@ -7388,7 +7388,7 @@ static UnitEmitter* emitHHBCVisitor(AnalysisResultPtr ar, FileScopeRawPtr fsp) {
Logger::Error("Unable to open %s for write", fullPath.c_str());
} else {
CodeGenerator cg(&f, CodeGenerator::TextHHBC);
cg.printf("Hash: %llx%016llx\n", md5.q[0], md5.q[1]);
cg.printf("Hash: %" PRIx64 "%016" PRIx64 "\n", md5.q[0], md5.q[1]);
cg.printRaw(unit->toString().c_str());
f.close();
}
Expand Down
16 changes: 8 additions & 8 deletions hphp/compiler/analysis/emitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ class Emitter {
#define MA std::vector<uchar>
#define BLA std::vector<Label*>&
#define SLA std::vector<StrOff>&
#define IVA int32
#define HA int32
#define IA int32
#define I64A int64
#define IVA int32_t
#define HA int32_t
#define IA int32_t
#define I64A int64_t
#define DA double
#define SA const StringData*
#define AA ArrayData*
Expand Down Expand Up @@ -200,7 +200,7 @@ struct SymbolicStack {
DataType dt; // META_DATA_TYPE
} metaData;
const StringData* className;
int64 intval; // used for L and I symbolic flavors
int64_t intval; // used for L and I symbolic flavors

// If intval is an unnamed local temporary, this offset is the start
// of the region we are using it (which we will need to have a
Expand Down Expand Up @@ -237,7 +237,7 @@ struct SymbolicStack {
std::string pretty() const;

void push(char sym);
void setInt(int64 v);
void setInt(int64_t v);
void setString(const StringData* s);
void setKnownCls(const StringData* s, bool nonNull);
void setNotRef();
Expand Down Expand Up @@ -274,7 +274,7 @@ struct SymbolicStack {

ClassBaseType getClsBaseType(int index) const;
int getLoc(int index) const;
int64 getInt(int index) const;
int64_t getInt(int index) const;
Offset getUnnamedLocStart(int index) const;

void pushFDesc();
Expand Down Expand Up @@ -502,7 +502,7 @@ class EmitterVisitor {
typedef std::pair<Id, int> StrCase;
struct SwitchState : private boost::noncopyable {
SwitchState() : nonZeroI(-1), defI(-1) {}
std::map<int64, int> cases; // a map from int (or litstr id) to case index
std::map<int64_t, int> cases; // a map from int (or litstr id) to case index
std::vector<StrCase> caseOrder; // for string switches, a list of the
// <litstr id, case index> in the order
// they appear in the source
Expand Down
8 changes: 4 additions & 4 deletions hphp/compiler/builtin_symbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void BuiltinSymbols::ParseExtClasses(AnalysisResultPtr ar, const char **p,
if (sep) {
fs->setSepExtension();
}
int flags = (int)(int64)(*p++);
int flags = (int)(int64_t)(*p++);
if (flags & ClassInfo::IsAbstract) {
fs->addModifier(T_ABSTRACT);
}
Expand All @@ -209,7 +209,7 @@ void BuiltinSymbols::ParseExtClasses(AnalysisResultPtr ar, const char **p,
p++;
// Parse properties
while (*p) {
int flags = (int)(int64)(*p++);
int flags = (int)(int64_t)(*p++);
ModifierExpressionPtr modifiers(
new ModifierExpression(BlockScopePtr(), LocationPtr()));
if (flags & ClassInfo::IsProtected) {
Expand All @@ -233,7 +233,7 @@ void BuiltinSymbols::ParseExtClasses(AnalysisResultPtr ar, const char **p,
}
p++;

int flags = (int)(int64)(*p++);
int flags = (int)(int64_t)(*p++);
cl->setClassInfoAttribute(flags);
if (flags & ClassInfo::HasDocComment) {
cl->setDocComment(*p++);
Expand Down Expand Up @@ -295,7 +295,7 @@ FunctionScopePtr BuiltinSymbols::ParseExtFunction(AnalysisResultPtr ar,
index++;
}

int flags = (int)(int64)(*p++);
int flags = (int)(int64_t)(*p++);
f->setClassInfoAttribute(flags);
if (flags & ClassInfo::HasDocComment) {
f->setDocComment(*p++);
Expand Down
2 changes: 1 addition & 1 deletion hphp/compiler/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class AsyncFileCacheSaver : public AsyncFunc<AsyncFileCacheSaver> {

struct stat sb;
stat(m_name, &sb);
Logger::Info("%dMB %s saved", (int64)sb.st_size/(1024*1024), m_name);
Logger::Info("%dMB %s saved", (int64_t)sb.st_size/(1024*1024), m_name);
}

private:
Expand Down
6 changes: 3 additions & 3 deletions hphp/compiler/construct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ void Construct::dumpNode(int spc) {
}

std::cout << "-> 0x" << std::hex << std::setfill('0')
<< std::setw(10) << (int64)this << std::dec;
<< std::setw(10) << (int64_t)this << std::dec;

std::cout << " " << name << "(" << type << ") ";
if (id) {
Expand All @@ -322,12 +322,12 @@ void Construct::dumpNode(int spc) {
if (idPtr) {
std::cout << "idp=0x" <<
std::hex << std::setfill('0') << std::setw(10) <<
(int64)idPtr.get() << " ";
(int64_t)idPtr.get() << " ";
}
if (idCsePtr) {
std::cout << "idcsep=0x" <<
std::hex << std::setfill('0') << std::setw(10) <<
(int64)idCsePtr.get() << " ";
(int64_t)idCsePtr.get() << " ";
}

if (value != "") {
Expand Down
4 changes: 2 additions & 2 deletions hphp/compiler/expression/binary_op_expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ ExpressionPtr BinaryOpExpression::simplifyArithmetic(
Variant v2;
if (m_exp1->getScalarValue(v1)) {
if (v1.isInteger()) {
int64 ival1 = v1.toInt64();
int64_t ival1 = v1.toInt64();
// 1 * $a => $a, 0 + $a => $a
if ((ival1 == 1 && m_op == '*') || (ival1 == 0 && m_op == '+')) {
TypePtr actType2 = m_exp2->getActualType();
Expand Down Expand Up @@ -317,7 +317,7 @@ ExpressionPtr BinaryOpExpression::simplifyArithmetic(
}
if (m_exp2->getScalarValue(v2)) {
if (v2.isInteger()) {
int64 ival2 = v2.toInt64();
int64_t ival2 = v2.toInt64();
// $a * 1 => $a, $a + 0 => $a
if ((ival2 == 1 && m_op == '*') || (ival2 == 0 && m_op == '+')) {
TypePtr actType1 = m_exp1->getActualType();
Expand Down
2 changes: 1 addition & 1 deletion hphp/compiler/expression/class_constant_expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ TypePtr ClassConstantExpression::inferTypes(AnalysisResultPtr ar,
}

unsigned ClassConstantExpression::getCanonHash() const {
int64 val =
int64_t val =
hash_string(Util::toLower(m_varName).c_str(), m_varName.size()) -
hash_string(Util::toLower(m_className).c_str(), m_className.size());
return ~unsigned(val) ^ unsigned(val >> 32);
Expand Down
2 changes: 1 addition & 1 deletion hphp/compiler/expression/constant_expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ bool ConstantExpression::getScalarValue(Variant &value) {
}

unsigned ConstantExpression::getCanonHash() const {
int64 val = hash_string(Util::toLower(m_name).c_str(), m_name.size());
int64_t val = hash_string(Util::toLower(m_name).c_str(), m_name.size());
return ~unsigned(val) ^ unsigned(val >> 32);
}

Expand Down
4 changes: 2 additions & 2 deletions hphp/compiler/expression/expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,11 +547,11 @@ void Expression::CheckPassByReference(AnalysisResultPtr ar,
}

unsigned Expression::getCanonHash() const {
int64 val = hash_int64(getKindOf());
int64_t val = hash_int64(getKindOf());
for (int i = getKidCount(); i--; ) {
ExpressionPtr k = getNthExpr(i);
if (k) {
val = hash_int64(val ^ (((int64)k->getKindOf()<<32)+k->getCanonID()));
val = hash_int64(val ^ (((int64_t)k->getKindOf()<<32)+k->getCanonID()));
}
}

Expand Down
Loading

0 comments on commit 2617812

Please sign in to comment.