[llvm-rc] Add DIALOG(EX) parsing ability (parser, pt 5/8).

This extends the set of resources parsed by llvm-rc by DIALOG and
DIALOGEX.

Additionally, three optional resource statements specific to these two
resources are added: CAPTION, FONT, and STYLE.

Thanks for Nico Weber for his original work in this area.

Differential Revision: https://reviews.llvm.org/D36905

llvm-svn: 312009
diff --git a/llvm/tools/llvm-rc/ResourceScriptStmt.cpp b/llvm/tools/llvm-rc/ResourceScriptStmt.cpp
index 9f61ce4..cfbd2f8 100644
--- a/llvm/tools/llvm-rc/ResourceScriptStmt.cpp
+++ b/llvm/tools/llvm-rc/ResourceScriptStmt.cpp
@@ -113,6 +113,35 @@
   return OS;
 }
 
+const StringSet<> Control::SupportedCtls = {
+    "LTEXT", "RTEXT", "CTEXT", "PUSHBUTTON", "DEFPUSHBUTTON", "EDITTEXT"};
+
+const StringSet<> Control::CtlsWithTitle = {"LTEXT", "RTEXT", "CTEXT",
+                                            "PUSHBUTTON", "DEFPUSHBUTTON"};
+
+raw_ostream &Control::log(raw_ostream &OS) const {
+  OS << "  Control (" << ID << "): " << Type << ", title: " << Title
+     << ", loc: (" << X << ", " << Y << "), size: [" << Width << ", " << Height
+     << "]";
+  if (Style)
+    OS << ", style: " << *Style;
+  if (ExtStyle)
+    OS << ", ext. style: " << *ExtStyle;
+  if (HelpID)
+    OS << ", help ID: " << *HelpID;
+  return OS << "\n";
+}
+
+raw_ostream &DialogResource::log(raw_ostream &OS) const {
+  OS << "Dialog" << (IsExtended ? "Ex" : "") << " (" << ResName << "): loc: ("
+     << X << ", " << Y << "), size: [" << Width << ", " << Height
+     << "], help ID: " << HelpID << "\n";
+  OptStatements.log(OS);
+  for (auto &Ctl : Controls)
+    Ctl.log(OS);
+  return OS;
+}
+
 raw_ostream &CharacteristicsStmt::log(raw_ostream &OS) const {
   return OS << "Characteristics: " << Value << "\n";
 }
@@ -121,5 +150,17 @@
   return OS << "Version: " << Value << "\n";
 }
 
+raw_ostream &CaptionStmt::log(raw_ostream &OS) const {
+  return OS << "Caption: " << Value << "\n";
+}
+
+raw_ostream &FontStmt::log(raw_ostream &OS) const {
+  return OS << "Font: size = " << Size << ", face = " << Typeface << "\n";
+}
+
+raw_ostream &StyleStmt::log(raw_ostream &OS) const {
+  return OS << "Style: " << Value << "\n";
+}
+
 } // namespace rc
 } // namespace llvm