diff options
author | Marek Sokolowski <mnbvmar@gmail.com> | 2017-08-18 17:05:47 +0000 |
---|---|---|
committer | Marek Sokolowski <mnbvmar@gmail.com> | 2017-08-18 17:05:47 +0000 |
commit | dbc16476c1b51346cad6a06558b0f2419656e1f8 (patch) | |
tree | f8965bf6f3fba862ce59b976155ac21b988ed4b6 /llvm/tools/llvm-rc/ResourceScriptStmt.cpp | |
parent | ac6a5aab45ef721e92a28e1b0515aa2a514d740b (diff) | |
download | bcm5719-llvm-dbc16476c1b51346cad6a06558b0f2419656e1f8.tar.gz bcm5719-llvm-dbc16476c1b51346cad6a06558b0f2419656e1f8.zip |
[llvm-rc] Add basic RC scripts parsing ability.
As for now, the parser supports a limited set of statements and
resources. This will be extended in the following patches.
Thanks to Nico Weber (thakis) for his original work in this area.
Differential Revision: https://reviews.llvm.org/D36340
llvm-svn: 311175
Diffstat (limited to 'llvm/tools/llvm-rc/ResourceScriptStmt.cpp')
-rw-r--r-- | llvm/tools/llvm-rc/ResourceScriptStmt.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/llvm/tools/llvm-rc/ResourceScriptStmt.cpp b/llvm/tools/llvm-rc/ResourceScriptStmt.cpp new file mode 100644 index 00000000000..af62e532225 --- /dev/null +++ b/llvm/tools/llvm-rc/ResourceScriptStmt.cpp @@ -0,0 +1,60 @@ +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===---------------------------------------------------------------------===// +// +// This implements methods defined in ResourceScriptStmt.h. +// +// Ref: msdn.microsoft.com/en-us/library/windows/desktop/aa380599(v=vs.85).aspx +// +//===---------------------------------------------------------------------===// + +#include "ResourceScriptStmt.h" + +namespace llvm { +namespace rc { + +raw_ostream &operator<<(raw_ostream &OS, const IntOrString &Item) { + if (Item.IsInt) + return OS << Item.Data.Int; + else + return OS << Item.Data.String; +} + +raw_ostream &OptionalStmtList::log(raw_ostream &OS) const { + for (const auto &Stmt : Statements) { + OS << " Option: "; + Stmt->log(OS); + } + return OS; +} + +raw_ostream &LanguageResource::log(raw_ostream &OS) const { + return OS << "Language: " << Lang << ", Sublanguage: " << SubLang << "\n"; +} + +raw_ostream &IconResource::log(raw_ostream &OS) const { + return OS << "Icon (" << ResName << "): " << IconLoc << "\n"; +} + +raw_ostream &StringTableResource::log(raw_ostream &OS) const { + OS << "StringTable:\n"; + OptStatements.log(OS); + for (const auto &String : Table) + OS << " " << String.first << " => " << String.second << "\n"; + return OS; +} + +raw_ostream &CharacteristicsStmt::log(raw_ostream &OS) const { + return OS << "Characteristics: " << Value << "\n"; +} + +raw_ostream &VersionStmt::log(raw_ostream &OS) const { + return OS << "Version: " << Value << "\n"; +} + +} // namespace rc +} // namespace llvm |