Arquivos
hhvm/hphp/compiler/analysis/dictionary.cpp
T
Jordan Delong 363d1bb20f Code move src/ -> hphp/
This change is mostly for FB internal organizational reasons.
Building is not effected beyond the fact that the target now
lands in hphp/hhvm/hhvm rather than src/hhvm/hhvm.
2013-02-11 02:10:41 -08:00

79 linhas
2.6 KiB
C++

/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#include <compiler/analysis/alias_manager.h>
#include <compiler/analysis/dictionary.h>
#include <compiler/expression/expression.h>
#include <compiler/statement/statement.h>
#include <compiler/statement/method_statement.h>
#include <compiler/statement/statement_list.h>
using namespace HPHP;
using std::vector;
///////////////////////////////////////////////////////////////////////////////
Dictionary::Dictionary(AliasManager &am) : m_am(am) {
m_idMap.push_back(ExpressionPtr());
}
void Dictionary::build(MethodStatementPtr m) {
if (StatementPtr s = m->getStmts()) {
build(s);
}
}
void Dictionary::build(StatementPtr stmt) {
for (int i = 0, n = stmt->getKidCount(); i < n; i++) {
if (ConstructPtr kid = stmt->getNthKid(i)) {
if (StatementPtr s = boost::dynamic_pointer_cast<Statement>(kid)) {
if (FunctionWalker::SkipRecurse(s)) continue;
build(s);
} else {
ExpressionPtr e = boost::dynamic_pointer_cast<Expression>(kid);
build(e);
}
}
}
}
void Dictionary::build(ExpressionPtr e) {
for (int i = 0, n = e->getKidCount(); i < n; i++) {
if (ExpressionPtr kid = e->getNthExpr(i)) {
build(kid);
}
}
visit(e);
}
void Dictionary::record(ExpressionPtr e) {
e->setCanonID(m_idMap.size());
m_idMap.push_back(e);
}
void Dictionary::beginBlock(ControlBlock *b) {
ControlFlowGraph *g = m_am.graph();
always_assert(g);
m_width = g->bitWidth();
m_altered = b->getRow(DataFlow::Altered);
m_available = g->rowExists(DataFlow::Available) ?
b->getRow(DataFlow::Available) : 0;
m_anticipated = g->rowExists(DataFlow::Anticipated) ?
b->getRow(DataFlow::Anticipated) : 0;
}