mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-26 05:25:47 +00:00
Add a (progn)-like construct for (actions). Implemented as a DAG list.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60658 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -802,11 +802,8 @@ void WalkCase(Init* Case, F1 TestCallback, F2 StatementCallback) {
|
|||||||
/// CheckForSuperfluousOptions() to walk the 'case' DAG.
|
/// CheckForSuperfluousOptions() to walk the 'case' DAG.
|
||||||
class ExtractOptionNames {
|
class ExtractOptionNames {
|
||||||
llvm::StringSet<>& OptionNames_;
|
llvm::StringSet<>& OptionNames_;
|
||||||
public:
|
|
||||||
ExtractOptionNames(llvm::StringSet<>& OptionNames) : OptionNames_(OptionNames)
|
|
||||||
{}
|
|
||||||
|
|
||||||
void operator()(const Init* Statement) {
|
void processDag(const Init* Statement) {
|
||||||
const DagInit& Stmt = InitPtrToDag(Statement);
|
const DagInit& Stmt = InitPtrToDag(Statement);
|
||||||
const std::string& ActionName = Stmt.getOperator()->getAsString();
|
const std::string& ActionName = Stmt.getOperator()->getAsString();
|
||||||
if (ActionName == "forward" || ActionName == "forward_as" ||
|
if (ActionName == "forward" || ActionName == "forward_as" ||
|
||||||
@@ -819,10 +816,26 @@ public:
|
|||||||
}
|
}
|
||||||
else if (ActionName == "and" || ActionName == "or") {
|
else if (ActionName == "and" || ActionName == "or") {
|
||||||
for (unsigned i = 0, NumArgs = Stmt.getNumArgs(); i < NumArgs; ++i) {
|
for (unsigned i = 0, NumArgs = Stmt.getNumArgs(); i < NumArgs; ++i) {
|
||||||
this->operator()(Stmt.getArg(i));
|
this->processDag(Stmt.getArg(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
ExtractOptionNames(llvm::StringSet<>& OptionNames) : OptionNames_(OptionNames)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void operator()(const Init* Statement) {
|
||||||
|
if (typeid(*Statement) == typeid(ListInit)) {
|
||||||
|
const ListInit& DagList = *static_cast<const ListInit*>(Statement);
|
||||||
|
for (ListInit::const_iterator B = DagList.begin(), E = DagList.end();
|
||||||
|
B != E; ++B)
|
||||||
|
this->processDag(*B);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this->processDag(Statement);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// CheckForSuperfluousOptions - Check that there are no side
|
/// CheckForSuperfluousOptions - Check that there are no side
|
||||||
@@ -1185,12 +1198,9 @@ void EmitForwardOptionPropertyHandlingCode (const OptionDescription& D,
|
|||||||
/// EmitCaseConstructHandler().
|
/// EmitCaseConstructHandler().
|
||||||
class EmitActionHandler {
|
class EmitActionHandler {
|
||||||
const OptionDescriptions& OptDescs;
|
const OptionDescriptions& OptDescs;
|
||||||
public:
|
|
||||||
EmitActionHandler(const OptionDescriptions& OD)
|
|
||||||
: OptDescs(OD) {}
|
|
||||||
|
|
||||||
void operator()(const Init* Statement, const char* IndentLevel,
|
void processActionDag(const Init* Statement, const char* IndentLevel,
|
||||||
std::ostream& O) const
|
std::ostream& O) const
|
||||||
{
|
{
|
||||||
const DagInit& Dag = InitPtrToDag(Statement);
|
const DagInit& Dag = InitPtrToDag(Statement);
|
||||||
const std::string& ActionName = Dag.getOperator()->getAsString();
|
const std::string& ActionName = Dag.getOperator()->getAsString();
|
||||||
@@ -1246,6 +1256,23 @@ class EmitActionHandler {
|
|||||||
throw "Unknown action name: " + ActionName + "!";
|
throw "Unknown action name: " + ActionName + "!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public:
|
||||||
|
EmitActionHandler(const OptionDescriptions& OD)
|
||||||
|
: OptDescs(OD) {}
|
||||||
|
|
||||||
|
void operator()(const Init* Statement, const char* IndentLevel,
|
||||||
|
std::ostream& O) const
|
||||||
|
{
|
||||||
|
if (typeid(*Statement) == typeid(ListInit)) {
|
||||||
|
const ListInit& DagList = *static_cast<const ListInit*>(Statement);
|
||||||
|
for (ListInit::const_iterator B = DagList.begin(), E = DagList.end();
|
||||||
|
B != E; ++B)
|
||||||
|
this->processActionDag(*B, IndentLevel, O);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this->processActionDag(Statement, IndentLevel, O);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// EmitGenerateActionMethod - Emit one of two versions of the
|
// EmitGenerateActionMethod - Emit one of two versions of the
|
||||||
|
Reference in New Issue
Block a user