Mercurial > hg > CbC > CbC_llvm
comparison include/llvm/Support/YAMLTraits.h @ 83:60c9769439b8 LLVM3.7
LLVM 3.7
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 18 Feb 2015 14:55:36 +0900 |
parents | 54457678186b |
children | afa8332a0e37 |
comparison
equal
deleted
inserted
replaced
78:af83660cff7b | 83:60c9769439b8 |
---|---|
445 virtual bool preflightKey(const char*, bool, bool, bool &, void *&) = 0; | 445 virtual bool preflightKey(const char*, bool, bool, bool &, void *&) = 0; |
446 virtual void postflightKey(void*) = 0; | 446 virtual void postflightKey(void*) = 0; |
447 | 447 |
448 virtual void beginEnumScalar() = 0; | 448 virtual void beginEnumScalar() = 0; |
449 virtual bool matchEnumScalar(const char*, bool) = 0; | 449 virtual bool matchEnumScalar(const char*, bool) = 0; |
450 virtual bool matchEnumFallback() = 0; | |
450 virtual void endEnumScalar() = 0; | 451 virtual void endEnumScalar() = 0; |
451 | 452 |
452 virtual bool beginBitSetScalar(bool &) = 0; | 453 virtual bool beginBitSetScalar(bool &) = 0; |
453 virtual bool bitSetMatch(const char*, bool) = 0; | 454 virtual bool bitSetMatch(const char*, bool) = 0; |
454 virtual void endBitSetScalar() = 0; | 455 virtual void endBitSetScalar() = 0; |
467 // allow anonymous enum values to be used with LLVM_YAML_STRONG_TYPEDEF | 468 // allow anonymous enum values to be used with LLVM_YAML_STRONG_TYPEDEF |
468 template <typename T> | 469 template <typename T> |
469 void enumCase(T &Val, const char* Str, const uint32_t ConstVal) { | 470 void enumCase(T &Val, const char* Str, const uint32_t ConstVal) { |
470 if ( matchEnumScalar(Str, outputting() && Val == static_cast<T>(ConstVal)) ) { | 471 if ( matchEnumScalar(Str, outputting() && Val == static_cast<T>(ConstVal)) ) { |
471 Val = ConstVal; | 472 Val = ConstVal; |
473 } | |
474 } | |
475 | |
476 template <typename FBT, typename T> | |
477 void enumFallback(T &Val) { | |
478 if ( matchEnumFallback() ) { | |
479 // FIXME: Force integral conversion to allow strong typedefs to convert. | |
480 FBT Res = (uint64_t)Val; | |
481 yamlize(*this, Res, true); | |
482 Val = (uint64_t)Res; | |
472 } | 483 } |
473 } | 484 } |
474 | 485 |
475 template <typename T> | 486 template <typename T> |
476 void bitSetCase(T &Val, const char* Str, const T ConstVal) { | 487 void bitSetCase(T &Val, const char* Str, const T ConstVal) { |
530 | 541 |
531 template <typename T> | 542 template <typename T> |
532 void mapOptional(const char* Key, T& Val, const T& Default) { | 543 void mapOptional(const char* Key, T& Val, const T& Default) { |
533 this->processKeyWithDefault(Key, Val, Default, false); | 544 this->processKeyWithDefault(Key, Val, Default, false); |
534 } | 545 } |
535 | 546 |
536 private: | 547 private: |
537 template <typename T> | 548 template <typename T> |
538 void processKeyWithDefault(const char *Key, Optional<T> &Val, | 549 void processKeyWithDefault(const char *Key, Optional<T> &Val, |
539 const Optional<T> &DefaultValue, bool Required) { | 550 const Optional<T> &DefaultValue, bool Required) { |
540 assert(DefaultValue.hasValue() == false && | 551 assert(DefaultValue.hasValue() == false && |
704 struct ScalarTraits<StringRef> { | 715 struct ScalarTraits<StringRef> { |
705 static void output(const StringRef &, void*, llvm::raw_ostream &); | 716 static void output(const StringRef &, void*, llvm::raw_ostream &); |
706 static StringRef input(StringRef, void*, StringRef &); | 717 static StringRef input(StringRef, void*, StringRef &); |
707 static bool mustQuote(StringRef S) { return needsQuotes(S); } | 718 static bool mustQuote(StringRef S) { return needsQuotes(S); } |
708 }; | 719 }; |
709 | 720 |
710 template<> | 721 template<> |
711 struct ScalarTraits<std::string> { | 722 struct ScalarTraits<std::string> { |
712 static void output(const std::string &, void*, llvm::raw_ostream &); | 723 static void output(const std::string &, void*, llvm::raw_ostream &); |
713 static StringRef input(StringRef, void*, std::string &); | 724 static StringRef input(StringRef, void*, std::string &); |
714 static bool mustQuote(StringRef S) { return needsQuotes(S); } | 725 static bool mustQuote(StringRef S) { return needsQuotes(S); } |
897 bool preflightFlowElement(unsigned , void *&) override; | 908 bool preflightFlowElement(unsigned , void *&) override; |
898 void postflightFlowElement(void *) override; | 909 void postflightFlowElement(void *) override; |
899 void endFlowSequence() override; | 910 void endFlowSequence() override; |
900 void beginEnumScalar() override; | 911 void beginEnumScalar() override; |
901 bool matchEnumScalar(const char*, bool) override; | 912 bool matchEnumScalar(const char*, bool) override; |
913 bool matchEnumFallback() override; | |
902 void endEnumScalar() override; | 914 void endEnumScalar() override; |
903 bool beginBitSetScalar(bool &) override; | 915 bool beginBitSetScalar(bool &) override; |
904 bool bitSetMatch(const char *, bool ) override; | 916 bool bitSetMatch(const char *, bool ) override; |
905 void endBitSetScalar() override; | 917 void endBitSetScalar() override; |
906 void scalarString(StringRef &, bool) override; | 918 void scalarString(StringRef &, bool) override; |
941 protected: | 953 protected: |
942 StringRef _value; | 954 StringRef _value; |
943 }; | 955 }; |
944 | 956 |
945 class MapHNode : public HNode { | 957 class MapHNode : public HNode { |
958 virtual void anchor(); | |
959 | |
946 public: | 960 public: |
947 MapHNode(Node *n) : HNode(n) { } | 961 MapHNode(Node *n) : HNode(n) { } |
948 virtual ~MapHNode(); | |
949 | 962 |
950 static inline bool classof(const HNode *n) { | 963 static inline bool classof(const HNode *n) { |
951 return MappingNode::classof(n->_node); | 964 return MappingNode::classof(n->_node); |
952 } | 965 } |
953 static inline bool classof(const MapHNode *) { return true; } | 966 static inline bool classof(const MapHNode *) { return true; } |
954 | 967 |
955 typedef llvm::StringMap<HNode*> NameToNode; | 968 typedef llvm::StringMap<std::unique_ptr<HNode>> NameToNode; |
956 | 969 |
957 bool isValidKey(StringRef key); | 970 bool isValidKey(StringRef key); |
958 | 971 |
959 NameToNode Mapping; | 972 NameToNode Mapping; |
960 llvm::SmallVector<const char*, 6> ValidKeys; | 973 llvm::SmallVector<const char*, 6> ValidKeys; |
961 }; | 974 }; |
962 | 975 |
963 class SequenceHNode : public HNode { | 976 class SequenceHNode : public HNode { |
977 virtual void anchor(); | |
978 | |
964 public: | 979 public: |
965 SequenceHNode(Node *n) : HNode(n) { } | 980 SequenceHNode(Node *n) : HNode(n) { } |
966 virtual ~SequenceHNode(); | |
967 | 981 |
968 static inline bool classof(const HNode *n) { | 982 static inline bool classof(const HNode *n) { |
969 return SequenceNode::classof(n->_node); | 983 return SequenceNode::classof(n->_node); |
970 } | 984 } |
971 static inline bool classof(const SequenceHNode *) { return true; } | 985 static inline bool classof(const SequenceHNode *) { return true; } |
972 | 986 |
973 std::vector<HNode*> Entries; | 987 std::vector<std::unique_ptr<HNode>> Entries; |
974 }; | 988 }; |
975 | 989 |
976 Input::HNode *createHNodes(Node *node); | 990 std::unique_ptr<Input::HNode> createHNodes(Node *node); |
977 void setError(HNode *hnode, const Twine &message); | 991 void setError(HNode *hnode, const Twine &message); |
978 void setError(Node *node, const Twine &message); | 992 void setError(Node *node, const Twine &message); |
979 | 993 |
980 | 994 |
981 public: | 995 public: |
1022 bool preflightFlowElement(unsigned, void *&) override; | 1036 bool preflightFlowElement(unsigned, void *&) override; |
1023 void postflightFlowElement(void *) override; | 1037 void postflightFlowElement(void *) override; |
1024 void endFlowSequence() override; | 1038 void endFlowSequence() override; |
1025 void beginEnumScalar() override; | 1039 void beginEnumScalar() override; |
1026 bool matchEnumScalar(const char*, bool) override; | 1040 bool matchEnumScalar(const char*, bool) override; |
1041 bool matchEnumFallback() override; | |
1027 void endEnumScalar() override; | 1042 void endEnumScalar() override; |
1028 bool beginBitSetScalar(bool &) override; | 1043 bool beginBitSetScalar(bool &) override; |
1029 bool bitSetMatch(const char *, bool ) override; | 1044 bool bitSetMatch(const char *, bool ) override; |
1030 void endBitSetScalar() override; | 1045 void endBitSetScalar() override; |
1031 void scalarString(StringRef &, bool) override; | 1046 void scalarString(StringRef &, bool) override; |