llvm.org GIT mirror llvm / 96c6092
[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 Michael J. Spencer 5 years ago
2 changed file(s) with 26 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
446446
447447 virtual void beginEnumScalar() = 0;
448448 virtual bool matchEnumScalar(const char*, bool) = 0;
449 virtual bool matchEnumFallback() = 0;
449450 virtual void endEnumScalar() = 0;
450451
451452 virtual bool beginBitSetScalar(bool &) = 0;
468469 void enumCase(T &Val, const char* Str, const uint32_t ConstVal) {
469470 if ( matchEnumScalar(Str, outputting() && Val == static_cast(ConstVal)) ) {
470471 Val = ConstVal;
472 }
473 }
474
475 template
476 void enumFallback(T &Val) {
477 if ( matchEnumFallback() ) {
478 FBT Res = Val;
479 yamlize(*this, Res, true);
480 Val = Res;
471481 }
472482 }
473483
898908 void endFlowSequence() override;
899909 void beginEnumScalar() override;
900910 bool matchEnumScalar(const char*, bool) override;
911 bool matchEnumFallback() override;
901912 void endEnumScalar() override;
902913 bool beginBitSetScalar(bool &) override;
903914 bool bitSetMatch(const char *, bool ) override;
10251036 void endFlowSequence() override;
10261037 void beginEnumScalar() override;
10271038 bool matchEnumScalar(const char*, bool) override;
1039 bool matchEnumFallback() override;
10281040 void endEnumScalar() override;
10291041 bool beginBitSetScalar(bool &) override;
10301042 bool bitSetMatch(const char *, bool ) override;
230230 }
231231 }
232232 return false;
233 }
234
235 bool Input::matchEnumFallback() {
236 if (ScalarMatchFound)
237 return false;
238 ScalarMatchFound = true;
239 return true;
233240 }
234241
235242 void Input::endEnumScalar() {
507514 return false;
508515 }
509516
517 bool Output::matchEnumFallback() {
518 if (EnumerationMatchFound)
519 return false;
520 EnumerationMatchFound = true;
521 return true;
522 }
523
510524 void Output::endEnumScalar() {
511525 if (!EnumerationMatchFound)
512526 llvm_unreachable("bad runtime enum value");