tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

DecoratorEmitter.h (2748B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #ifndef frontend_DecoratorEmitter_h
      6 #define frontend_DecoratorEmitter_h
      7 
      8 #include "mozilla/Attributes.h"
      9 
     10 #include "frontend/ParseNode.h"
     11 
     12 #include "js/AllocPolicy.h"
     13 #include "js/Vector.h"
     14 
     15 namespace js::frontend {
     16 
     17 struct BytecodeEmitter;
     18 
     19 class MOZ_STACK_CLASS DecoratorEmitter {
     20 private:
     21  BytecodeEmitter* bce_;
     22 
     23 public:
     24  enum Kind { Method, Getter, Setter, Field, Accessor, Class };
     25 
     26  explicit DecoratorEmitter(BytecodeEmitter* bce);
     27 
     28  [[nodiscard]] bool emitApplyDecoratorsToElementDefinition(
     29      Kind kind, ParseNode* key, ListNode* decorators, bool isStatic);
     30 
     31  [[nodiscard]] bool emitApplyDecoratorsToFieldDefinition(ParseNode* key,
     32                                                          ListNode* decorators,
     33                                                          bool isStatic);
     34 
     35  [[nodiscard]] bool emitApplyDecoratorsToAccessorDefinition(
     36      ParseNode* key, ListNode* decorators, bool isStatic);
     37 
     38  [[nodiscard]] bool emitApplyDecoratorsToClassDefinition(ParseNode* key,
     39                                                          ListNode* decorators);
     40 
     41  [[nodiscard]] bool emitInitializeFieldOrAccessor();
     42 
     43  [[nodiscard]] bool emitCreateAddInitializerFunction(
     44      FunctionNode* addInitializerFunction, TaggedParserAtomIndex initializers);
     45 
     46  [[nodiscard]] bool emitCallExtraInitializers(
     47      TaggedParserAtomIndex extraInitializers);
     48 
     49 private:
     50  [[nodiscard]] bool emitPropertyKey(ParseNode* key);
     51 
     52  [[nodiscard]] bool emitDecorationState();
     53 
     54  [[nodiscard]] bool emitUpdateDecorationState();
     55 
     56  [[nodiscard]] bool emitCallDecoratorForElement(Kind kind, ParseNode* key,
     57                                                 bool isStatic,
     58                                                 ParseNode* decorator);
     59 
     60  [[nodiscard]] bool emitCreateDecoratorAccessObject();
     61 
     62  [[nodiscard]] bool emitCheckIsUndefined();
     63 
     64  [[nodiscard]] bool emitCreateAddInitializerFunction();
     65 
     66  [[nodiscard]] bool emitCreateDecoratorContextObject(Kind kind, ParseNode* key,
     67                                                      bool isStatic,
     68                                                      TokenPos pos);
     69 
     70  [[nodiscard]] bool emitHandleNewValueField(TaggedParserAtomIndex atom,
     71                                             int8_t offset);
     72 
     73  using DecoratorsVector = js::Vector<ParseNode*, 2, js::SystemAllocPolicy>;
     74 
     75  [[nodiscard]] bool reverseDecoratorsToApplicationOrder(
     76      const ListNode* decorators, DecoratorsVector& vec) const;
     77 };
     78 
     79 } /* namespace js::frontend */
     80 
     81 #endif /* frontend_DecoratorEmitter_h */