Identify direct children of yield expressions

We want to be able to recognize them without knowing their
context.
Esse commit está contido em:
mwilliams
2013-07-17 07:21:37 -07:00
commit de Sara Golemon
commit db130c83e1
6 arquivos alterados com 17 adições e 0 exclusões
+5
Ver Arquivo
@@ -36,6 +36,7 @@
#include "hphp/compiler/expression/expression.h"
#include "hphp/compiler/expression/include_expression.h"
#include "hphp/compiler/expression/closure_expression.h"
#include "hphp/compiler/expression/yield_expression.h"
#include "hphp/compiler/statement/statement.h"
#include "hphp/compiler/statement/statement_list.h"
#include "hphp/compiler/statement/catch_statement.h"
@@ -2115,6 +2116,7 @@ int AliasManager::collectAliasInfoRecur(ConstructPtr cs, bool unused) {
}
cs->clearVisited();
cs->clearChildOfYield();
StatementPtr s = dpc(Statement, cs);
if (s) {
@@ -2405,6 +2407,9 @@ int AliasManager::collectAliasInfoRecur(ConstructPtr cs, bool unused) {
// expressions. TODO: revisit this later
m_inlineAsExpr = false;
break;
case Expression::KindOfYieldExpression:
spc(YieldExpression, e)->getValueExpression()->setChildOfYield();
break;
case Expression::KindOfUnaryOpExpression:
if (Option::EnableEval > Option::NoEval && spc(UnaryOpExpression, e)->
getOp() == T_EVAL) {
+5
Ver Arquivo
@@ -166,6 +166,10 @@ public:
void clearKilled() { m_flags.killed = false; }
bool isKilled() const { return m_flags.killed; }
void setChildOfYield() { m_flags.childOfYield = true; }
void clearChildOfYield() { m_flags.childOfYield = false; }
bool isChildOfYield() const { return m_flags.childOfYield; }
BlockScopeRawPtr getScope() const { return m_blockScope; }
void setBlockScope(BlockScopeRawPtr scope) { m_blockScope = scope; }
FileScopeRawPtr getFileScope() const {
@@ -295,6 +299,7 @@ private:
unsigned killed : 1;
unsigned refCounted : 2; // high bit indicates whether its valid
unsigned inited : 2; // high bit indicates whether its valid
unsigned childOfYield : 1; // parent node is yield
} m_flags;
};
protected:
+1
Ver Arquivo
@@ -70,6 +70,7 @@ ExpressionPtr Expression::replaceValue(ExpressionPtr rep) {
rep->clearContext(AssignmentRHS);
rep = el;
}
if (isChildOfYield()) rep->setChildOfYield();
if (rep->is(KindOfSimpleVariable) && !is(KindOfSimpleVariable)) {
static_pointer_cast<SimpleVariable>(rep)->setAlwaysStash();
}
@@ -50,6 +50,7 @@ void YieldExpression::analyzeProgram(AnalysisResultPtr ar) {
if (m_keyExp) {
m_keyExp->analyzeProgram(ar);
}
m_valExp->setChildOfYield();
m_valExp->analyzeProgram(ar);
if (m_label == -1) {
setLabel(getFunctionScope()->allocYieldLabel());
@@ -0,0 +1,5 @@
<?php
function test() {
list($a, $b) = yield wait_forva(result(1), result(2));
}