mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
[YAMLIO] Add support for numeric values in enums.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226942 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
89eab6e7bd
commit
96c609287d
@ -447,6 +447,7 @@ public:
|
||||
|
||||
virtual void beginEnumScalar() = 0;
|
||||
virtual bool matchEnumScalar(const char*, bool) = 0;
|
||||
virtual bool matchEnumFallback() = 0;
|
||||
virtual void endEnumScalar() = 0;
|
||||
|
||||
virtual bool beginBitSetScalar(bool &) = 0;
|
||||
@ -472,6 +473,15 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template <typename FBT, typename T>
|
||||
void enumFallback(T &Val) {
|
||||
if ( matchEnumFallback() ) {
|
||||
FBT Res = Val;
|
||||
yamlize(*this, Res, true);
|
||||
Val = Res;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void bitSetCase(T &Val, const char* Str, const T ConstVal) {
|
||||
if ( bitSetMatch(Str, outputting() && (Val & ConstVal) == ConstVal) ) {
|
||||
@ -899,6 +909,7 @@ private:
|
||||
void endFlowSequence() override;
|
||||
void beginEnumScalar() override;
|
||||
bool matchEnumScalar(const char*, bool) override;
|
||||
bool matchEnumFallback() override;
|
||||
void endEnumScalar() override;
|
||||
bool beginBitSetScalar(bool &) override;
|
||||
bool bitSetMatch(const char *, bool ) override;
|
||||
@ -1026,6 +1037,7 @@ public:
|
||||
void endFlowSequence() override;
|
||||
void beginEnumScalar() override;
|
||||
bool matchEnumScalar(const char*, bool) override;
|
||||
bool matchEnumFallback() override;
|
||||
void endEnumScalar() override;
|
||||
bool beginBitSetScalar(bool &) override;
|
||||
bool bitSetMatch(const char *, bool ) override;
|
||||
|
@ -233,6 +233,13 @@ bool Input::matchEnumScalar(const char *Str, bool) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Input::matchEnumFallback() {
|
||||
if (ScalarMatchFound)
|
||||
return false;
|
||||
ScalarMatchFound = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Input::endEnumScalar() {
|
||||
if (!ScalarMatchFound) {
|
||||
setError(CurrentNode, "unknown enumerated scalar");
|
||||
@ -508,6 +515,13 @@ bool Output::matchEnumScalar(const char *Str, bool Match) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Output::matchEnumFallback() {
|
||||
if (EnumerationMatchFound)
|
||||
return false;
|
||||
EnumerationMatchFound = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Output::endEnumScalar() {
|
||||
if (!EnumerationMatchFound)
|
||||
llvm_unreachable("bad runtime enum value");
|
||||
|
Loading…
Reference in New Issue
Block a user