1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef ECMASCRIPT_TOOLING_BASE_PT_TYPES_H
17 #define ECMASCRIPT_TOOLING_BASE_PT_TYPES_H
18 
19 #include <memory>
20 #include <optional>
21 
22 #include "common/macros.h"
23 
24 #include "tooling/base/pt_json.h"
25 #include "tooling/utils/utils.h"
26 
27 #include "ecmascript/debugger/debugger_api.h"
28 #include "ecmascript/dfx/cpu_profiler/samples_record.h"
29 #include "ecmascript/dfx/hprof/heap_sampling.h"
30 #include "libpandabase/macros.h"
31 
32 using ToolchainUtils = OHOS::ArkCompiler::Toolchain::Utils;
33 
34 namespace panda::ecmascript::tooling {
35 // ========== Base types begin
36 class PtBaseTypes {
37 public:
38     PtBaseTypes() = default;
39     virtual ~PtBaseTypes() = default;
40     virtual std::unique_ptr<PtJson> ToJson() const = 0;
41 
42 private:
43     NO_COPY_SEMANTIC(PtBaseTypes);
44     NO_MOVE_SEMANTIC(PtBaseTypes);
45 
46     friend class ProtocolHandler;
47     friend class DebuggerImpl;
48 };
49 
50 // ========== Debugger types begin
51 // Debugger.BreakpointId
52 using BreakpointId = std::string;
53 struct BreakpointDetails {
ToStringpanda::ecmascript::tooling::BreakpointDetails54     static BreakpointId ToString(const BreakpointDetails &metaData)
55     {
56         return "id:" + std::to_string(metaData.line_) + ":" + std::to_string(metaData.column_) + ":" +
57             metaData.url_;
58     }
59 
ParseBreakpointIdpanda::ecmascript::tooling::BreakpointDetails60     static bool ParseBreakpointId(const BreakpointId &id, BreakpointDetails *metaData)
61     {
62         auto lineStart = id.find(':');
63         if (lineStart == std::string::npos) {
64             return false;
65         }
66         auto columnStart = id.find(':', lineStart + 1);
67         if (columnStart == std::string::npos) {
68             return false;
69         }
70         auto urlStart = id.find(':', columnStart + 1);
71         if (urlStart == std::string::npos) {
72             return false;
73         }
74         std::string lineStr = id.substr(lineStart + 1, columnStart - lineStart - 1);
75         std::string columnStr = id.substr(columnStart + 1, urlStart - columnStart - 1);
76         std::string url = id.substr(urlStart + 1);
77         if (!ToolchainUtils::StrToInt32(lineStr, metaData->line_)) {
78             return false;
79         }
80         if (!ToolchainUtils::StrToInt32(columnStr, metaData->column_)) {
81             return false;
82         }
83         metaData->url_ = url;
84 
85         return true;
86     }
87 
88     int32_t line_ {0};
89     int32_t column_ {0};
90     std::string url_ {};
91 };
92 
93 // Debugger.CallFrameId
94 using CallFrameId = int32_t;
95 
96 // Debugger.BreakpointInfo
97 class BreakpointInfo : public PtBaseTypes {
98 public:
99     BreakpointInfo() = default;
100     ~BreakpointInfo() override = default;
101 
102     static std::unique_ptr<BreakpointInfo> Create(const PtJson &params);
103     std::unique_ptr<PtJson> ToJson() const override;
104 
GetLineNumber() const105     int32_t GetLineNumber() const
106     {
107         return lineNumber_;
108     }
109 
GetColumnNumber() const110     int32_t GetColumnNumber() const
111     {
112         return columnNumber_;
113     }
114 
GetUrl() const115     const std::string &GetUrl() const
116     {
117         return url_;
118     }
119 
GetCondition() const120     const std::string &GetCondition() const
121     {
122         ASSERT(HasCondition());
123         return condition_.value();
124     }
125 
HasCondition() const126     bool HasCondition() const
127     {
128         return condition_.has_value();
129     }
130 
GetUrlRegex() const131     const std::string &GetUrlRegex() const
132     {
133         ASSERT(HasUrlRegex());
134         return urlRegex_.value();
135     }
136 
HasUrlRegex() const137     bool HasUrlRegex() const
138     {
139         return urlRegex_.has_value();
140     }
141 
GetScriptHash() const142     const std::string &GetScriptHash() const
143     {
144         ASSERT(HasScriptHash());
145         return scriptHash_.value();
146     }
147 
HasScriptHash() const148     bool HasScriptHash() const
149     {
150         return scriptHash_.has_value();
151     }
152 
GetRestrictToFunction() const153     bool GetRestrictToFunction() const
154     {
155         return restrictToFunction_.value_or(false);
156     }
157 
HasRestrictToFunction() const158     bool HasRestrictToFunction() const
159     {
160         return restrictToFunction_.has_value();
161     }
162 
163 private:
164     NO_COPY_SEMANTIC(BreakpointInfo);
165     NO_MOVE_SEMANTIC(BreakpointInfo);
166 
167     int32_t lineNumber_ {0};
168     int32_t columnNumber_ {0};
169     std::string url_ {};
170     std::optional<std::string> condition_ {};
171     std::optional<std::string> urlRegex_ {};
172     std::optional<std::string> scriptHash_ {};
173     std::optional<bool> restrictToFunction_ {};
174 };
175 
176 // Runtime.ScriptId
177 using ScriptId = int32_t;
178 
179 // Debugger.BreakpointReturnInfo
180 class BreakpointReturnInfo : public PtBaseTypes {
181 public:
182     BreakpointReturnInfo() = default;
183     ~BreakpointReturnInfo() override = default;
184 
185     static std::unique_ptr<BreakpointReturnInfo> Create(const PtJson &params);
186     std::unique_ptr<PtJson> ToJson() const override;
187 
GetLineNumber() const188     int32_t GetLineNumber() const
189     {
190         return lineNumber_;
191     }
192 
GetColumnNumber() const193     int32_t GetColumnNumber() const
194     {
195         return columnNumber_;
196     }
197 
SetColumnNumber(int32_t column)198     BreakpointReturnInfo &SetColumnNumber(int32_t column)
199     {
200         columnNumber_ = column;
201         return *this;
202     }
203 
SetLineNumber(int32_t line)204     BreakpointReturnInfo &SetLineNumber(int32_t line)
205     {
206         lineNumber_ = line;
207         return *this;
208     }
209 
GetId() const210     std::string GetId() const
211     {
212         return id_;
213     }
214 
SetId(std::string &id)215     BreakpointReturnInfo &SetId(std::string &id)
216     {
217         id_ = id;
218         return *this;
219     }
220 
GetScriptId() const221     ScriptId GetScriptId() const
222     {
223         return scriptId_;
224     }
225 
SetScriptId(ScriptId scriptId)226     BreakpointReturnInfo &SetScriptId(ScriptId scriptId)
227     {
228         scriptId_ = scriptId;
229         return *this;
230     }
231 
232 private:
233     NO_COPY_SEMANTIC(BreakpointReturnInfo);
234     NO_MOVE_SEMANTIC(BreakpointReturnInfo);
235 
236     std::string id_;
237     int32_t lineNumber_ {0};
238     int32_t columnNumber_ {0};
239     ScriptId scriptId_ {0};
240 };
241 
242 // ========== Runtime types begin
243 // Runtime.RemoteObjectId
244 using RemoteObjectId = int32_t;
245 
246 // Runtime.ExecutionContextId
247 using ExecutionContextId = int32_t;
248 
249 // Runtime.UnserializableValue
250 using UnserializableValue = std::string;
251 
252 // Runtime.UniqueDebuggerId
253 using UniqueDebuggerId = int32_t;
254 
255 // Runtime.RemoteObject
256 class RemoteObject : public PtBaseTypes {
257 public:
258     RemoteObject() = default;
259     ~RemoteObject() override = default;
260 
261     static std::unique_ptr<RemoteObject> FromTagged(const EcmaVM *ecmaVm, Local<JSValueRef> tagged);
262     static std::unique_ptr<RemoteObject> Create(const PtJson &params);
263     std::unique_ptr<PtJson> ToJson() const override;
264     static void AppendingHashToDescription(const EcmaVM *ecmaVM, Local<JSValueRef> tagged,
265         std::string &description);
266     static void AppendingSendableDescription(Local<JSValueRef> tagged, std::string &description);
267     static std::string ResolveClassNameToDescription(const EcmaVM *ecmaVM, Local<JSValueRef> tagged);
268     /*
269      * @see {#ObjectType}
270      */
GetType() const271     const std::string &GetType() const
272     {
273         return type_;
274     }
275 
SetType(const std::string &type)276     RemoteObject &SetType(const std::string &type)
277     {
278         type_ = type;
279         return *this;
280     }
281     /*
282      * @see {#ObjectSubType}
283      */
GetSubType() const284     const std::string &GetSubType() const
285     {
286         ASSERT(HasSubType());
287         return subType_.value();
288     }
289 
SetSubType(const std::string &type)290     RemoteObject &SetSubType(const std::string &type)
291     {
292         subType_ = type;
293         return *this;
294     }
295 
HasSubType() const296     bool HasSubType() const
297     {
298         return subType_.has_value();
299     }
300 
GetClassName() const301     const std::string &GetClassName() const
302     {
303         ASSERT(HasClassName());
304         return className_.value();
305     }
306 
SetClassName(const std::string &className)307     RemoteObject &SetClassName(const std::string &className)
308     {
309         className_ = className;
310         return *this;
311     }
312 
HasClassName() const313     bool HasClassName() const
314     {
315         return className_.has_value();
316     }
317 
GetValue() const318     Local<JSValueRef> GetValue() const
319     {
320         return value_.value_or(Local<JSValueRef>());
321     }
322 
SetValue(Local<JSValueRef> value)323     RemoteObject &SetValue(Local<JSValueRef> value)
324     {
325         value_ = value;
326         return *this;
327     }
328 
HasValue() const329     bool HasValue() const
330     {
331         return value_.has_value();
332     }
333 
GetUnserializableValue() const334     const UnserializableValue &GetUnserializableValue() const
335     {
336         ASSERT(HasUnserializableValue());
337         return unserializableValue_.value();
338     }
339 
SetUnserializableValue(const UnserializableValue &unserializableValue)340     RemoteObject &SetUnserializableValue(const UnserializableValue &unserializableValue)
341     {
342         unserializableValue_ = unserializableValue;
343         return *this;
344     }
345 
HasUnserializableValue() const346     bool HasUnserializableValue() const
347     {
348         return unserializableValue_.has_value();
349     }
350 
GetDescription() const351     const std::string &GetDescription() const
352     {
353         ASSERT(HasDescription());
354         return description_.value();
355     }
356 
SetDescription(const std::string &description)357     RemoteObject &SetDescription(const std::string &description)
358     {
359         description_ = description;
360         return *this;
361     }
362 
HasDescription() const363     bool HasDescription() const
364     {
365         return description_.has_value();
366     }
367 
GetObjectId() const368     RemoteObjectId GetObjectId() const
369     {
370         return objectId_.value_or(0);
371     }
372 
SetObjectId(RemoteObjectId objectId)373     RemoteObject &SetObjectId(RemoteObjectId objectId)
374     {
375         objectId_ = objectId;
376         return *this;
377     }
378 
HasObjectId() const379     bool HasObjectId() const
380     {
381         return objectId_.has_value();
382     }
383 
HasPreviewValue() const384     bool HasPreviewValue() const
385     {
386         return previewValue_.has_value();
387     }
388 
GetPreviewValue() const389     const std::string &GetPreviewValue() const
390     {
391         ASSERT(HasPreviewValue());
392         return previewValue_.value();
393     }
394 
SetPreviewValue(const std::string &value)395     RemoteObject &SetPreviewValue(const std::string &value)
396     {
397         previewValue_ = value;
398         return *this;
399     }
400 
401     struct TypeName {
402         static const std::string Object;     // NOLINT (readability-identifier-naming)
403         static const std::string Function;   // NOLINT (readability-identifier-naming)
404         static const std::string Undefined;  // NOLINT (readability-identifier-naming)
405         static const std::string String;     // NOLINT (readability-identifier-naming)
406         static const std::string Number;     // NOLINT (readability-identifier-naming)
407         static const std::string Boolean;    // NOLINT (readability-identifier-naming)
408         static const std::string Symbol;     // NOLINT (readability-identifier-naming)
409         static const std::string Bigint;     // NOLINT (readability-identifier-naming)
410         static const std::string Wasm;       // NOLINT (readability-identifier-naming)
Validpanda::ecmascript::tooling::RemoteObject::TypeName411         static bool Valid(const std::string &type)
412         {
413             return type == Object || type == Function || type == Undefined || type == String || type == Number ||
414                    type == Boolean || type == Symbol || type == Bigint || type == Wasm;
415         }
416     };
417 
418     struct SubTypeName {
419         static const std::string Array;        // NOLINT (readability-identifier-naming)
420         static const std::string Null;         // NOLINT (readability-identifier-naming)
421         static const std::string Node;         // NOLINT (readability-identifier-naming)
422         static const std::string Regexp;       // NOLINT (readability-identifier-naming)
423         static const std::string Date;         // NOLINT (readability-identifier-naming)
424         static const std::string Map;          // NOLINT (readability-identifier-naming)
425         static const std::string Set;          // NOLINT (readability-identifier-naming)
426         static const std::string Weakmap;      // NOLINT (readability-identifier-naming)
427         static const std::string Weakset;      // NOLINT (readability-identifier-naming)
428         static const std::string Iterator;     // NOLINT (readability-identifier-naming)
429         static const std::string Generator;    // NOLINT (readability-identifier-naming)
430         static const std::string Error;        // NOLINT (readability-identifier-naming)
431         static const std::string Proxy;        // NOLINT (readability-identifier-naming)
432         static const std::string Promise;      // NOLINT (readability-identifier-naming)
433         static const std::string Typedarray;   // NOLINT (readability-identifier-naming)
434         static const std::string Arraybuffer;  // NOLINT (readability-identifier-naming)
435         static const std::string Dataview;     // NOLINT (readability-identifier-naming)
436         static const std::string I32;          // NOLINT (readability-identifier-naming)
437         static const std::string I64;          // NOLINT (readability-identifier-naming)
438         static const std::string F32;          // NOLINT (readability-identifier-naming)
439         static const std::string F64;          // NOLINT (readability-identifier-naming)
440         static const std::string V128;         // NOLINT (readability-identifier-naming)
441         static const std::string Externref;    // NOLINT (readability-identifier-naming)
Validpanda::ecmascript::tooling::RemoteObject::SubTypeName442         static bool Valid(const std::string &type)
443         {
444             return type == Array || type == Null || type == Node || type == Regexp || type == Map || type == Set ||
445                    type == Weakmap || type == Iterator || type == Generator || type == Error || type == Proxy ||
446                    type == Promise || type == Typedarray || type == Arraybuffer || type == Dataview || type == I32 ||
447                    type == I64 || type == F32 || type == F64 || type == V128 || type == Externref;
448         }
449     };
450     struct ClassName {
451         static const std::string Object;          // NOLINT (readability-identifier-naming)
452         static const std::string Function;        // NOLINT (readability-identifier-naming)
453         static const std::string Array;           // NOLINT (readability-identifier-naming)
454         static const std::string Regexp;          // NOLINT (readability-identifier-naming)
455         static const std::string Date;            // NOLINT (readability-identifier-naming)
456         static const std::string Map;             // NOLINT (readability-identifier-naming)
457         static const std::string Set;             // NOLINT (readability-identifier-naming)
458         static const std::string Weakmap;         // NOLINT (readability-identifier-naming)
459         static const std::string Weakset;         // NOLINT (readability-identifier-naming)
460         static const std::string Dataview;         // NOLINT (readability-identifier-naming)
461         static const std::string ArrayIterator;   // NOLINT (readability-identifier-naming)
462         static const std::string StringIterator;  // NOLINT (readability-identifier-naming)
463         static const std::string SetIterator;     // NOLINT (readability-identifier-naming)
464         static const std::string MapIterator;     // NOLINT (readability-identifier-naming)
465         static const std::string Iterator;        // NOLINT (readability-identifier-naming)
466         static const std::string Error;           // NOLINT (readability-identifier-naming)
467         static const std::string Proxy;           // NOLINT (readability-identifier-naming)
468         static const std::string Promise;         // NOLINT (readability-identifier-naming)
469         static const std::string Typedarray;      // NOLINT (readability-identifier-naming)
470         static const std::string Arraybuffer;     // NOLINT (readability-identifier-naming)
471         static const std::string Global;          // NOLINT (readability-identifier-naming)
472         static const std::string Generator;       // NOLINT (readability-identifier-naming)
Validpanda::ecmascript::tooling::RemoteObject::ClassName473         static bool Valid(const std::string &type)
474         {
475             return type == Object || type == Array || type == Regexp || type == Date || type == Map || type == Set ||
476                    type == Weakmap || type == Weakset || type == ArrayIterator || type == StringIterator ||
477                    type == Error || type == SetIterator || type == MapIterator || type == Iterator || type == Proxy ||
478                    type == Promise || type == Typedarray || type == Arraybuffer || type == Function;
479         }
480     };
481     static const std::string ObjectDescription;          // NOLINT (readability-identifier-naming)
482     static const std::string GlobalDescription;          // NOLINT (readability-identifier-naming)
483     static const std::string ProxyDescription;           // NOLINT (readability-identifier-naming)
484     static const std::string PromiseDescription;         // NOLINT (readability-identifier-naming)
485     static const std::string ArrayIteratorDescription;   // NOLINT (readability-identifier-naming)
486     static const std::string StringIteratorDescription;  // NOLINT (readability-identifier-naming)
487     static const std::string SetIteratorDescription;     // NOLINT (readability-identifier-naming)
488     static const std::string MapIteratorDescription;     // NOLINT (readability-identifier-naming)
489     static const std::string WeakRefDescription;         // NOLINT (readability-identifier-naming)
490     static const std::string WeakMapDescription;         // NOLINT (readability-identifier-naming)
491     static const std::string WeakSetDescription;         // NOLINT (readability-identifier-naming)
492     static const std::string DataViewDescription;         // NOLINT (readability-identifier-naming)
493     static const std::string JSPrimitiveRefDescription;     // NOLINT (readability-identifier-naming)
494     static const std::string JSPrimitiveNumberDescription;  // NOLINT (readability-identifier-naming)
495     static const std::string JSPrimitiveBooleanDescription; // NOLINT (readability-identifier-naming)
496     static const std::string JSPrimitiveStringDescription;  // NOLINT (readability-identifier-naming)
497     static const std::string JSPrimitiveSymbolDescription;  // NOLINT (readability-identifier-naming)
498     static const std::string JSIntlDescription;             // NOLINT (readability-identifier-naming)
499     static const std::string DateTimeFormatDescription;     // NOLINT (readability-identifier-naming)
500     static const std::string NumberFormatDescription;       // NOLINT (readability-identifier-naming)
501     static const std::string CollatorDescription;           // NOLINT (readability-identifier-naming)
502     static const std::string PluralRulesDescription;        // NOLINT (readability-identifier-naming)
503     static const std::string JSLocaleDescription;              // NOLINT (readability-identifier-naming)
504     static const std::string JSListFormatDescription;          // NOLINT (readability-identifier-naming)
505     static const std::string JSRelativeTimeFormatDescription;  // NOLINT (readability-identifier-naming)
506 
507 private:
508     NO_COPY_SEMANTIC(RemoteObject);
509     NO_MOVE_SEMANTIC(RemoteObject);
510 
511     std::string type_ {};
512     std::optional<std::string> subType_ {};
513     std::optional<std::string> className_ {};
514     std::optional<Local<JSValueRef>> value_ {};
515     std::optional<UnserializableValue> unserializableValue_ {};
516     std::optional<std::string> description_ {};
517     std::optional<RemoteObjectId> objectId_ {};
518     std::optional<std::string> previewValue_ {};
519 };
520 
521 class PrimitiveRemoteObject final : public RemoteObject {
522 public:
523     PrimitiveRemoteObject(const EcmaVM *ecmaVm, Local<JSValueRef> tagged);
524     ~PrimitiveRemoteObject() override = default;
525 };
526 
527 class StringRemoteObject final : public RemoteObject {
528 public:
529     StringRemoteObject(const EcmaVM *ecmaVm, Local<StringRef> tagged);
530     ~StringRemoteObject() override = default;
531 };
532 
533 class SymbolRemoteObject final : public RemoteObject {
534 public:
535     SymbolRemoteObject(const EcmaVM *ecmaVm, Local<SymbolRef> tagged);
536     ~SymbolRemoteObject() override = default;
537 
538 private:
539     std::string DescriptionForSymbol(const EcmaVM *ecmaVm, Local<SymbolRef> tagged) const;
540 };
541 
542 class FunctionRemoteObject final : public RemoteObject {
543 public:
544     FunctionRemoteObject(const EcmaVM *ecmaVm, Local<JSValueRef> tagged);
545     ~FunctionRemoteObject() override = default;
546 
547 private:
548     std::string DescriptionForFunction(const EcmaVM *ecmaVm, Local<FunctionRef> tagged) const;
549 };
550 
551 class GeneratorFunctionRemoteObject final : public RemoteObject {
552 public:
553     GeneratorFunctionRemoteObject(const EcmaVM *ecmaVm, Local<JSValueRef> tagged);
554     ~GeneratorFunctionRemoteObject() override = default;
555 
556 private:
557     std::string DescriptionForGeneratorFunction(const EcmaVM *ecmaVm, Local<FunctionRef> tagged) const;
558 };
559 
560 class ObjectRemoteObject final : public RemoteObject {
561 public:
562     ObjectRemoteObject(const EcmaVM *ecmaVm, Local<JSValueRef> tagged, const std::string &classname);
563     ObjectRemoteObject(const EcmaVM *ecmaVm, Local<JSValueRef> tagged, const std::string &classname,
564         const std::string &subtype);
565     ~ObjectRemoteObject() override = default;
566     static std::string DescriptionForObject(const EcmaVM *ecmaVm, Local<JSValueRef> tagged);
567 
568 private:
569     enum NumberSize : uint8_t { BYTES_OF_16BITS = 2, BYTES_OF_32BITS = 4, BYTES_OF_64BITS = 8 };
570     static std::string DescriptionForArray(const EcmaVM *ecmaVm, Local<ArrayRef> tagged);
571     static std::string DescriptionForRegexp(const EcmaVM *ecmaVm, Local<RegExpRef> tagged);
572     static std::string DescriptionForDate(const EcmaVM *ecmaVm, Local<DateRef> tagged);
573     static std::string DescriptionForMap(const EcmaVM *ecmaVm, Local<MapRef> tagged);
574     static std::string DescriptionForWeakMap(const EcmaVM *ecmaVm, Local<WeakMapRef> tagged);
575     static std::string DescriptionForSet(const EcmaVM *ecmaVm, Local<SetRef> tagged);
576     static std::string DescriptionForWeakSet(const EcmaVM *ecmaVm, Local<WeakSetRef> tagged);
577     static std::string DescriptionForDataView(Local<DataViewRef> tagged);
578     static std::string DescriptionForError(const EcmaVM *ecmaVm, Local<JSValueRef> tagged);
579     static std::string DescriptionForArrayIterator();
580     static std::string DescriptionForMapIterator();
581     static std::string DescriptionForSetIterator();
582     static std::string DescriptionForArrayBuffer(const EcmaVM *ecmaVm, Local<ArrayBufferRef> tagged);
583     static std::string DescriptionForSharedArrayBuffer(const EcmaVM *ecmaVm, Local<ArrayBufferRef> tagged);
584     static std::string DescriptionForUint8Array(const EcmaVM *ecmaVm, Local<TypedArrayRef> tagged);
585     static std::string DescriptionForInt8Array(const EcmaVM *ecmaVm, Local<TypedArrayRef> tagged);
586     static std::string DescriptionForInt16Array(const EcmaVM *ecmaVm, Local<TypedArrayRef> tagged);
587     static std::string DescriptionForInt32Array(const EcmaVM *ecmaVm, Local<TypedArrayRef> tagged);
588     static std::string DescriptionForPrimitiveNumber(const EcmaVM *ecmaVm, const Local<JSValueRef> &tagged);
589     static std::string DescriptionForPrimitiveString(const EcmaVM *ecmaVm, const Local<JSValueRef> &tagged);
590     static std::string DescriptionForPrimitiveBoolean(const EcmaVM *ecmaVm, const Local<JSValueRef> &tagged);
591     static std::string DescriptionForGeneratorObject(const EcmaVM *ecmaVm, const Local<JSValueRef> &tagged);
592     static std::string DescriptionForWeakRef();
593     static std::string DescriptionForDateTimeFormat();
594     static std::string DescriptionForNumberFormat();
595     static std::string DescriptionForCollator();
596     static std::string DescriptionForPluralRules();
597     static std::string DescriptionForJSLocale();
598     static std::string DescriptionForJSRelativeTimeFormat();
599     static std::string DescriptionForJSListFormat();
600     // container
601     static std::string DescriptionForArrayList();
602     static std::string DescriptionForDeque();
603     static std::string DescriptionForHashMap();
604     static std::string DescriptionForHashSet();
605     static std::string DescriptionForLightWeightMap();
606     static std::string DescriptionForLightWeightSet();
607     static std::string DescriptionForLinkedList();
608     static std::string DescriptionForList();
609     static std::string DescriptionForPlainArray();
610     static std::string DescriptionForQueue();
611     static std::string DescriptionForStack();
612     static std::string DescriptionForTreeMap();
613     static std::string DescriptionForTreeSet();
614     static std::string DescriptionForVector();
615     static std::string DescriptionForNativePointer(const Local<NativePointerRef> &tagged);
616 };
617 
618 // Runtime.ExceptionDetails
619 class ExceptionDetails final : public PtBaseTypes {
620 public:
621     ExceptionDetails() = default;
622     ~ExceptionDetails() override = default;
623     static std::unique_ptr<ExceptionDetails> Create(const PtJson &params);
624     std::unique_ptr<PtJson> ToJson() const override;
625 
GetExceptionId() const626     int32_t GetExceptionId() const
627     {
628         return exceptionId_;
629     }
630 
SetExceptionId(int32_t exceptionId)631     ExceptionDetails &SetExceptionId(int32_t exceptionId)
632     {
633         exceptionId_ = exceptionId;
634         return *this;
635     }
636 
GetText() const637     const std::string &GetText() const
638     {
639         return text_;
640     }
641 
SetText(const std::string &text)642     ExceptionDetails &SetText(const std::string &text)
643     {
644         text_ = text;
645         return *this;
646     }
647 
GetLine() const648     int32_t GetLine() const
649     {
650         return lineNumber_;
651     }
652 
SetLine(int32_t lineNumber)653     ExceptionDetails &SetLine(int32_t lineNumber)
654     {
655         lineNumber_ = lineNumber;
656         return *this;
657     }
658 
GetColumn() const659     int32_t GetColumn() const
660     {
661         return columnNumber_;
662     }
663 
SetColumn(int32_t columnNumber)664     ExceptionDetails &SetColumn(int32_t columnNumber)
665     {
666         columnNumber_ = columnNumber;
667         return *this;
668     }
669 
GetScriptId() const670     ScriptId GetScriptId() const
671     {
672         return scriptId_.value_or(0);
673     }
674 
SetScriptId(ScriptId scriptId)675     ExceptionDetails &SetScriptId(ScriptId scriptId)
676     {
677         scriptId_ = scriptId;
678         return *this;
679     }
680 
HasScriptId() const681     bool HasScriptId() const
682     {
683         return scriptId_.has_value();
684     }
685 
GetUrl() const686     const std::string &GetUrl() const
687     {
688         ASSERT(HasUrl());
689         return url_.value();
690     }
691 
SetUrl(const std::string &url)692     ExceptionDetails &SetUrl(const std::string &url)
693     {
694         url_ = url;
695         return *this;
696     }
697 
HasUrl() const698     bool HasUrl() const
699     {
700         return url_.has_value();
701     }
702 
GetException() const703     RemoteObject *GetException() const
704     {
705         if (exception_) {
706             return exception_->get();
707         }
708         return nullptr;
709     }
710 
SetException(std::unique_ptr<RemoteObject> exception)711     ExceptionDetails &SetException(std::unique_ptr<RemoteObject> exception)
712     {
713         exception_ = std::move(exception);
714         return *this;
715     }
716 
HasException() const717     bool HasException() const
718     {
719         return exception_.has_value();
720     }
721 
GetExecutionContextId() const722     ExecutionContextId GetExecutionContextId() const
723     {
724         return executionContextId_.value_or(-1);
725     }
726 
SetExecutionContextId(ExecutionContextId executionContextId)727     ExceptionDetails &SetExecutionContextId(ExecutionContextId executionContextId)
728     {
729         executionContextId_ = executionContextId;
730         return *this;
731     }
732 
HasExecutionContextId() const733     bool HasExecutionContextId() const
734     {
735         return executionContextId_.has_value();
736     }
737 
738 private:
739     NO_COPY_SEMANTIC(ExceptionDetails);
740     NO_MOVE_SEMANTIC(ExceptionDetails);
741 
742     int32_t exceptionId_ {0};
743     std::string text_ {};
744     int32_t lineNumber_ {0};
745     int32_t columnNumber_ {0};
746     std::optional<ScriptId> scriptId_ {};
747     std::optional<std::string> url_ {};
748     std::optional<std::unique_ptr<RemoteObject>> exception_ {};
749     std::optional<ExecutionContextId> executionContextId_ {0};
750 };
751 
752 // Runtime.InternalPropertyDescriptor
753 class InternalPropertyDescriptor final : public PtBaseTypes {
754 public:
755     InternalPropertyDescriptor() = default;
756     ~InternalPropertyDescriptor() override = default;
757 
758     static std::unique_ptr<InternalPropertyDescriptor> Create(const PtJson &params);
759     std::unique_ptr<PtJson> ToJson() const override;
760 
GetName() const761     std::string GetName() const
762     {
763         return name_;
764     }
765 
SetName(const std::string &name)766     InternalPropertyDescriptor &SetName(const std::string &name)
767     {
768         name_ = name;
769         return *this;
770     }
771 
GetValue() const772     RemoteObject *GetValue() const
773     {
774         if (value_) {
775             return value_->get();
776         }
777         return nullptr;
778     }
779 
SetValue(std::unique_ptr<RemoteObject> value)780     InternalPropertyDescriptor &SetValue(std::unique_ptr<RemoteObject> value)
781     {
782         value_ = std::move(value);
783         return *this;
784     }
785 
HasValue() const786     bool HasValue() const
787     {
788         return value_.has_value();
789     }
790 
791 private:
792     NO_COPY_SEMANTIC(InternalPropertyDescriptor);
793     NO_MOVE_SEMANTIC(InternalPropertyDescriptor);
794 
795     std::string name_ {};
796     std::optional<std::unique_ptr<RemoteObject>> value_ {};
797 };
798 
799 // Runtime.PrivatePropertyDescriptor
800 class PrivatePropertyDescriptor final : public PtBaseTypes {
801 public:
802     PrivatePropertyDescriptor() = default;
803     ~PrivatePropertyDescriptor() override = default;
804 
805     static std::unique_ptr<PrivatePropertyDescriptor> Create(const PtJson &params);
806     std::unique_ptr<PtJson> ToJson() const override;
807 
GetName() const808     std::string GetName() const
809     {
810         return name_;
811     }
812 
SetName(const std::string &name)813     PrivatePropertyDescriptor &SetName(const std::string &name)
814     {
815         name_ = name;
816         return *this;
817     }
818 
GetValue() const819     RemoteObject *GetValue() const
820     {
821         if (value_) {
822             return value_->get();
823         }
824         return nullptr;
825     }
826 
SetValue(std::unique_ptr<RemoteObject> value)827     PrivatePropertyDescriptor &SetValue(std::unique_ptr<RemoteObject> value)
828     {
829         value_ = std::move(value);
830         return *this;
831     }
832 
HasValue() const833     bool HasValue() const
834     {
835         return value_.has_value();
836     }
837 
GetGet() const838     RemoteObject *GetGet() const
839     {
840         if (get_) {
841             return get_->get();
842         }
843         return nullptr;
844     }
845 
SetGet(std::unique_ptr<RemoteObject> get)846     PrivatePropertyDescriptor &SetGet(std::unique_ptr<RemoteObject> get)
847     {
848         get_ = std::move(get);
849         return *this;
850     }
851 
HasGet() const852     bool HasGet() const
853     {
854         return get_.has_value();
855     }
856 
GetSet() const857     RemoteObject *GetSet() const
858     {
859         if (set_) {
860             return set_->get();
861         }
862         return nullptr;
863     }
864 
SetSet(std::unique_ptr<RemoteObject> set)865     PrivatePropertyDescriptor &SetSet(std::unique_ptr<RemoteObject> set)
866     {
867         set_ = std::move(set);
868         return *this;
869     }
870 
HasSet() const871     bool HasSet() const
872     {
873         return set_.has_value();
874     }
875 
876 private:
877     NO_COPY_SEMANTIC(PrivatePropertyDescriptor);
878     NO_MOVE_SEMANTIC(PrivatePropertyDescriptor);
879 
880     std::string name_ {};
881     std::optional<std::unique_ptr<RemoteObject>> value_ {};
882     std::optional<std::unique_ptr<RemoteObject>> get_ {};
883     std::optional<std::unique_ptr<RemoteObject>> set_ {};
884 };
885 
886 // Runtime.PropertyDescriptor
887 class TOOLCHAIN_EXPORT PropertyDescriptor final : public PtBaseTypes {
888 public:
889     PropertyDescriptor() = default;
890     ~PropertyDescriptor() override = default;
891 
892     static std::unique_ptr<PropertyDescriptor> FromProperty(const EcmaVM *ecmaVm, Local<JSValueRef> name,
893         const PropertyAttribute &property);
894     static std::unique_ptr<PropertyDescriptor> Create(const PtJson &params);
895     std::unique_ptr<PtJson> ToJson() const override;
896 
GetName() const897     std::string GetName() const
898     {
899         return name_;
900     }
901 
SetName(const std::string &name)902     PropertyDescriptor &SetName(const std::string &name)
903     {
904         name_ = name;
905         return *this;
906     }
907 
GetValue() const908     RemoteObject *GetValue() const
909     {
910         if (value_) {
911             return value_->get();
912         }
913         return nullptr;
914     }
915 
SetValue(std::unique_ptr<RemoteObject> value)916     PropertyDescriptor &SetValue(std::unique_ptr<RemoteObject> value)
917     {
918         value_ = std::move(value);
919         return *this;
920     }
921 
HasValue() const922     bool HasValue() const
923     {
924         return value_.has_value();
925     }
926 
GetWritable() const927     bool GetWritable() const
928     {
929         return writable_.value_or(false);
930     }
931 
SetWritable(bool writable)932     PropertyDescriptor &SetWritable(bool writable)
933     {
934         writable_ = writable;
935         return *this;
936     }
937 
HasWritable() const938     bool HasWritable() const
939     {
940         return writable_.has_value();
941     }
942 
GetGet() const943     RemoteObject *GetGet() const
944     {
945         if (get_) {
946             return get_->get();
947         }
948         return nullptr;
949     }
950 
SetGet(std::unique_ptr<RemoteObject> get)951     PropertyDescriptor &SetGet(std::unique_ptr<RemoteObject> get)
952     {
953         get_ = std::move(get);
954         return *this;
955     }
956 
HasGet() const957     bool HasGet() const
958     {
959         return get_.has_value();
960     }
961 
GetSet() const962     RemoteObject *GetSet() const
963     {
964         if (set_) {
965             return set_->get();
966         }
967         return nullptr;
968     }
969 
SetSet(std::unique_ptr<RemoteObject> set)970     PropertyDescriptor &SetSet(std::unique_ptr<RemoteObject> set)
971     {
972         set_ = std::move(set);
973         return *this;
974     }
975 
HasSet() const976     bool HasSet() const
977     {
978         return set_.has_value();
979     }
980 
GetConfigurable() const981     bool GetConfigurable() const
982     {
983         return configurable_;
984     }
985 
SetConfigurable(bool configurable)986     PropertyDescriptor &SetConfigurable(bool configurable)
987     {
988         configurable_ = configurable;
989         return *this;
990     }
991 
GetEnumerable() const992     bool GetEnumerable() const
993     {
994         return enumerable_;
995     }
996 
SetEnumerable(bool enumerable)997     PropertyDescriptor &SetEnumerable(bool enumerable)
998     {
999         enumerable_ = enumerable;
1000         return *this;
1001     }
1002 
GetWasThrown() const1003     bool GetWasThrown() const
1004     {
1005         return wasThrown_.value_or(false);
1006     }
1007 
SetWasThrown(bool wasThrown)1008     PropertyDescriptor &SetWasThrown(bool wasThrown)
1009     {
1010         wasThrown_ = wasThrown;
1011         return *this;
1012     }
1013 
HasWasThrown() const1014     bool HasWasThrown() const
1015     {
1016         return wasThrown_.has_value();
1017     }
1018 
GetIsOwn() const1019     bool GetIsOwn() const
1020     {
1021         return isOwn_.value_or(false);
1022     }
1023 
SetIsOwn(bool isOwn)1024     PropertyDescriptor &SetIsOwn(bool isOwn)
1025     {
1026         isOwn_ = isOwn;
1027         return *this;
1028     }
1029 
HasIsOwn() const1030     bool HasIsOwn() const
1031     {
1032         return isOwn_.has_value();
1033     }
1034 
GetSymbol() const1035     RemoteObject *GetSymbol() const
1036     {
1037         if (symbol_) {
1038             return symbol_->get();
1039         }
1040         return nullptr;
1041     }
1042 
SetSymbol(std::unique_ptr<RemoteObject> symbol)1043     PropertyDescriptor &SetSymbol(std::unique_ptr<RemoteObject> symbol)
1044     {
1045         symbol_ = std::move(symbol);
1046         return *this;
1047     }
1048 
HasSymbol() const1049     bool HasSymbol() const
1050     {
1051         return symbol_.has_value();
1052     }
1053 
1054 private:
1055     NO_COPY_SEMANTIC(PropertyDescriptor);
1056     NO_MOVE_SEMANTIC(PropertyDescriptor);
1057 
1058     std::string name_ {};
1059     std::optional<std::unique_ptr<RemoteObject>> value_ {};
1060     std::optional<bool> writable_ {};
1061     std::optional<std::unique_ptr<RemoteObject>> get_ {};
1062     std::optional<std::unique_ptr<RemoteObject>> set_ {};
1063     bool configurable_ {false};
1064     bool enumerable_ {false};
1065     std::optional<bool> wasThrown_ {};
1066     std::optional<bool> isOwn_ {};
1067     std::optional<std::unique_ptr<RemoteObject>> symbol_ {};
1068 };
1069 
1070 // Runtime.CallArgument
1071 class CallArgument final : public PtBaseTypes {
1072 public:
1073     CallArgument() = default;
1074     ~CallArgument() override = default;
1075 
1076     static std::unique_ptr<CallArgument> Create(const PtJson &params);
1077     std::unique_ptr<PtJson> ToJson() const override;
1078 
GetValue() const1079     Local<JSValueRef> GetValue() const
1080     {
1081         return value_.value_or(Local<JSValueRef>());
1082     }
1083 
SetValue(Local<JSValueRef> value)1084     CallArgument &SetValue(Local<JSValueRef> value)
1085     {
1086         value_ = value;
1087         return *this;
1088     }
1089 
HasValue() const1090     bool HasValue() const
1091     {
1092         return value_.has_value();
1093     }
1094 
GetUnserializableValue() const1095     const UnserializableValue &GetUnserializableValue() const
1096     {
1097         ASSERT(HasUnserializableValue());
1098         return unserializableValue_.value();
1099     }
1100 
SetUnserializableValue(const UnserializableValue &unserializableValue)1101     CallArgument &SetUnserializableValue(const UnserializableValue &unserializableValue)
1102     {
1103         unserializableValue_ = unserializableValue;
1104         return *this;
1105     }
1106 
HasUnserializableValue() const1107     bool HasUnserializableValue() const
1108     {
1109         return unserializableValue_.has_value();
1110     }
1111 
GetObjectId() const1112     RemoteObjectId GetObjectId() const
1113     {
1114         return objectId_.value_or(0);
1115     }
1116 
SetObjectId(RemoteObjectId objectId)1117     CallArgument &SetObjectId(RemoteObjectId objectId)
1118     {
1119         objectId_ = objectId;
1120         return *this;
1121     }
1122 
HasObjectId() const1123     bool HasObjectId() const
1124     {
1125         return objectId_.has_value();
1126     }
1127 
1128 private:
1129     NO_COPY_SEMANTIC(CallArgument);
1130     NO_MOVE_SEMANTIC(CallArgument);
1131 
1132     std::optional<Local<JSValueRef>> value_ {};
1133     std::optional<UnserializableValue> unserializableValue_ {};
1134     std::optional<RemoteObjectId> objectId_ {};
1135 };
1136 
1137 // ========== Debugger types begin
1138 // Debugger.ScriptLanguage
1139 struct ScriptLanguage {
Validpanda::ecmascript::tooling::final::ScriptLanguage1140     static bool Valid(const std::string &language)
1141     {
1142         return language == JavaScript() || language == WebAssembly();
1143     }
JavaScriptpanda::ecmascript::tooling::final::ScriptLanguage1144     static std::string JavaScript()
1145     {
1146         return "JavaScript";
1147     }
WebAssemblypanda::ecmascript::tooling::final::ScriptLanguage1148     static std::string WebAssembly()
1149     {
1150         return "WebAssembly";
1151     }
1152 };
1153 
1154 // Debugger.Location
1155 class Location  {
1156 public:
1157     static std::unique_ptr<Location> Create(const PtJson &params);
1158     std::unique_ptr<PtJson> ToJson() const ;
1159 
GetScriptId() const1160     ScriptId GetScriptId() const
1161     {
1162         return scriptId_;
1163     }
1164 
SetScriptId(ScriptId scriptId)1165     Location &SetScriptId(ScriptId scriptId)
1166     {
1167         scriptId_ = scriptId;
1168         return *this;
1169     }
1170 
GetLine() const1171     int32_t GetLine() const
1172     {
1173         return lineNumber_;
1174     }
1175 
SetLine(int32_t line)1176     Location &SetLine(int32_t line)
1177     {
1178         lineNumber_ = line;
1179         return *this;
1180     }
1181 
GetColumn() const1182     int32_t GetColumn() const
1183     {
1184         return columnNumber_.value_or(-1);
1185     }
1186 
SetColumn(int32_t column)1187     Location &SetColumn(int32_t column)
1188     {
1189         columnNumber_ = column;
1190         return *this;
1191     }
1192 
HasColumn() const1193     bool HasColumn() const
1194     {
1195         return columnNumber_.has_value();
1196     }
1197 
1198 private:
1199 
1200     ScriptId scriptId_ {0};
1201     int32_t lineNumber_ {0};
1202     std::optional<int32_t> columnNumber_ {};
1203 };
1204 
1205 // Debugger.ScriptPosition
1206 class ScriptPosition : public PtBaseTypes {
1207 public:
1208     ScriptPosition() = default;
1209     ~ScriptPosition() override = default;
1210 
1211     static std::unique_ptr<ScriptPosition> Create(const PtJson &params);
1212     std::unique_ptr<PtJson> ToJson() const override;
1213 
GetLine() const1214     int32_t GetLine() const
1215     {
1216         return lineNumber_;
1217     }
1218 
SetLine(int32_t line)1219     ScriptPosition &SetLine(int32_t line)
1220     {
1221         lineNumber_ = line;
1222         return *this;
1223     }
1224 
GetColumn() const1225     int32_t GetColumn() const
1226     {
1227         return columnNumber_;
1228     }
1229 
SetColumn(int32_t column)1230     ScriptPosition &SetColumn(int32_t column)
1231     {
1232         columnNumber_ = column;
1233         return *this;
1234     }
1235 
1236 private:
1237     NO_COPY_SEMANTIC(ScriptPosition);
1238     NO_MOVE_SEMANTIC(ScriptPosition);
1239 
1240     int32_t lineNumber_ {0};
1241     int32_t columnNumber_ {0};
1242 };
1243 
1244 // Debugger.SearchMatch
1245 class SearchMatch : public PtBaseTypes {
1246 public:
1247     SearchMatch() = default;
1248     ~SearchMatch() override = default;
1249     static std::unique_ptr<SearchMatch> Create(const PtJson &params);
1250     std::unique_ptr<PtJson> ToJson() const override;
1251 
GetLine() const1252     int32_t GetLine() const
1253     {
1254         return lineNumber_;
1255     }
1256 
SetLine(int32_t line)1257     SearchMatch &SetLine(int32_t line)
1258     {
1259         lineNumber_ = line;
1260         return *this;
1261     }
1262 
GetLineContent() const1263     std::string GetLineContent() const
1264     {
1265         return lineContent_;
1266     }
1267 
SetLineContent(const std::string lineContent)1268     SearchMatch &SetLineContent(const std::string lineContent)
1269     {
1270         lineContent_ = lineContent;
1271         return *this;
1272     }
1273 
1274 private:
1275     NO_COPY_SEMANTIC(SearchMatch);
1276     NO_MOVE_SEMANTIC(SearchMatch);
1277 
1278     int32_t lineNumber_ {0};
1279     std::string lineContent_ {};
1280 };
1281 
1282 // Debugger.LocationRange
1283 class LocationRange : public PtBaseTypes {
1284 public:
1285     LocationRange() = default;
1286     ~LocationRange() override = default;
1287 
1288     static std::unique_ptr<LocationRange> Create(const PtJson &params);
1289     std::unique_ptr<PtJson> ToJson() const override;
1290 
GetScriptId() const1291     ScriptId GetScriptId() const
1292     {
1293         return scriptId_;
1294     }
1295 
SetScriptId(ScriptId scriptId)1296     LocationRange &SetScriptId(ScriptId scriptId)
1297     {
1298         scriptId_ = scriptId;
1299         return *this;
1300     }
1301 
GetStart() const1302     ScriptPosition *GetStart() const
1303     {
1304         return start_.get();
1305     }
1306 
SetStart(std::unique_ptr<ScriptPosition> start)1307     LocationRange &SetStart(std::unique_ptr<ScriptPosition> start)
1308     {
1309         start_ = std::move(start);
1310         return *this;
1311     }
1312 
GetEnd() const1313     ScriptPosition *GetEnd() const
1314     {
1315         return end_.get();
1316     }
1317 
SetEnd(std::unique_ptr<ScriptPosition> end)1318     LocationRange &SetEnd(std::unique_ptr<ScriptPosition> end)
1319     {
1320         end_ = std::move(end);
1321         return *this;
1322     }
1323 
1324 private:
1325     NO_COPY_SEMANTIC(LocationRange);
1326     NO_MOVE_SEMANTIC(LocationRange);
1327 
1328     ScriptId scriptId_ {0};
1329     std::unique_ptr<ScriptPosition> start_ {nullptr};
1330     std::unique_ptr<ScriptPosition> end_ {nullptr};
1331 };
1332 
1333 class NativeRange {
1334 public:
1335     NativeRange() = default;
1336     ~NativeRange() = default;
1337 
1338     static std::unique_ptr<NativeRange> Create(const PtJson &params);
1339 
GetStart() const1340     uint64_t GetStart() const
1341     {
1342         return start_;
1343     }
1344 
SetStart(uint64_t start)1345     NativeRange &SetStart(uint64_t start)
1346     {
1347         start_ = std::move(start);
1348         return *this;
1349     }
1350 
GetEnd() const1351     uint64_t GetEnd() const
1352     {
1353         return end_;
1354     }
1355 
SetEnd(uint64_t end)1356     NativeRange &SetEnd(uint64_t end)
1357     {
1358         end_ = std::move(end);
1359         return *this;
1360     }
1361 
1362 private:
1363 
1364     uint64_t start_ {0};
1365     uint64_t end_ {0};
1366 };
1367 
1368 // Debugger.BreakLocation
1369 class BreakLocation final : public PtBaseTypes {
1370 public:
1371     BreakLocation() = default;
1372     ~BreakLocation() override = default;
1373 
1374     static std::unique_ptr<BreakLocation> Create(const PtJson &params);
1375     std::unique_ptr<PtJson> ToJson() const override;
1376 
GetScriptId() const1377     ScriptId GetScriptId() const
1378     {
1379         return scriptId_;
1380     }
1381 
SetScriptId(ScriptId scriptId)1382     BreakLocation &SetScriptId(ScriptId scriptId)
1383     {
1384         scriptId_ = scriptId;
1385         return *this;
1386     }
1387 
GetLine() const1388     int32_t GetLine() const
1389     {
1390         return lineNumber_;
1391     }
1392 
SetLine(int32_t lineNumber)1393     BreakLocation &SetLine(int32_t lineNumber)
1394     {
1395         lineNumber_ = lineNumber;
1396         return *this;
1397     }
1398 
GetColumn() const1399     int32_t GetColumn() const
1400     {
1401         return columnNumber_.value_or(-1);
1402     }
1403 
SetColumn(int32_t columnNumber)1404     BreakLocation &SetColumn(int32_t columnNumber)
1405     {
1406         columnNumber_ = columnNumber;
1407         return *this;
1408     }
1409 
HasColumn() const1410     bool HasColumn() const
1411     {
1412         return columnNumber_.has_value();
1413     }
1414 
1415     /*
1416      * @see {#BreakType}
1417      */
GetType() const1418     const std::string &GetType() const
1419     {
1420         ASSERT(HasType());
1421         return type_.value();
1422     }
1423 
SetType(const std::string &type)1424     BreakLocation &SetType(const std::string &type)
1425     {
1426         type_ = type;
1427         return *this;
1428     }
1429 
HasType() const1430     bool HasType() const
1431     {
1432         return type_.has_value();
1433     }
1434 
1435     struct Type {
Validpanda::ecmascript::tooling::final::final::Type1436         static bool Valid(const std::string &type)
1437         {
1438             return type == DebuggerStatement() || type == Call() || type == Return();
1439         }
DebuggerStatementpanda::ecmascript::tooling::final::final::Type1440         static std::string DebuggerStatement()
1441         {
1442             return "debuggerStatement";
1443         }
Callpanda::ecmascript::tooling::final::final::Type1444         static std::string Call()
1445         {
1446             return "call";
1447         }
Returnpanda::ecmascript::tooling::final::final::Type1448         static std::string Return()
1449         {
1450             return "return";
1451         }
1452     };
1453 
1454 private:
1455     NO_COPY_SEMANTIC(BreakLocation);
1456     NO_MOVE_SEMANTIC(BreakLocation);
1457 
1458     ScriptId scriptId_ {0};
1459     int32_t lineNumber_ {0};
1460     std::optional<int32_t> columnNumber_ {};
1461     std::optional<std::string> type_ {};
1462 };
1463 using BreakType = BreakLocation::Type;
1464 
1465 enum class ScopeType : uint8_t {
1466     GLOBAL,
1467     LOCAL,
1468     WITH,
1469     CLOSURE,
1470     CATCH,
1471     BLOCK,
1472     SCRIPT,
1473     EVAL,
1474     MODULE,
1475     WASM_EXPRESSION_STACK
1476 };
1477 
1478 // Debugger.Scope
1479 class Scope final : public PtBaseTypes {
1480 public:
1481     Scope() = default;
1482     ~Scope() override = default;
1483 
1484     static std::unique_ptr<Scope> Create(const PtJson &params);
1485     std::unique_ptr<PtJson> ToJson() const override;
1486 
1487     /*
1488      * @see {#Scope::Type}
1489      */
GetType() const1490     const std::string &GetType() const
1491     {
1492         return type_;
1493     }
1494 
SetType(const std::string &type)1495     Scope &SetType(const std::string &type)
1496     {
1497         type_ = type;
1498         return *this;
1499     }
1500 
GetObject() const1501     RemoteObject *GetObject() const
1502     {
1503         return object_.get();
1504     }
1505 
SetObject(std::unique_ptr<RemoteObject> params)1506     Scope &SetObject(std::unique_ptr<RemoteObject> params)
1507     {
1508         object_ = std::move(params);
1509         return *this;
1510     }
1511 
GetName() const1512     const std::string &GetName() const
1513     {
1514         ASSERT(HasName());
1515         return name_.value();
1516     }
1517 
SetName(const std::string &name)1518     Scope &SetName(const std::string &name)
1519     {
1520         name_ = name;
1521         return *this;
1522     }
1523 
HasName() const1524     bool HasName() const
1525     {
1526         return name_.has_value();
1527     }
1528 
GetStartLocation() const1529     Location *GetStartLocation() const
1530     {
1531         if (startLocation_) {
1532             return startLocation_->get();
1533         }
1534         return nullptr;
1535     }
1536 
SetStartLocation(std::unique_ptr<Location> location)1537     Scope &SetStartLocation(std::unique_ptr<Location> location)
1538     {
1539         startLocation_ = std::move(location);
1540         return *this;
1541     }
1542 
HasStartLocation() const1543     bool HasStartLocation() const
1544     {
1545         return startLocation_.has_value();
1546     }
1547 
GetEndLocation() const1548     Location *GetEndLocation() const
1549     {
1550         if (endLocation_) {
1551             return endLocation_->get();
1552         }
1553         return nullptr;
1554     }
1555 
SetEndLocation(std::unique_ptr<Location> location)1556     Scope &SetEndLocation(std::unique_ptr<Location> location)
1557     {
1558         endLocation_ = std::move(location);
1559         return *this;
1560     }
1561 
HasEndLocation() const1562     bool HasEndLocation() const
1563     {
1564         return endLocation_.has_value();
1565     }
1566 
1567     struct Type {
Validpanda::ecmascript::tooling::final::final::Type1568         static bool Valid(const std::string &type)
1569         {
1570             return type == Global() || type == Local() || type == With() || type == Closure() || type == Catch() ||
1571                    type == Block() || type == Script() || type == Eval() || type == Module() ||
1572                    type == WasmExpressionStack();
1573         }
Globalpanda::ecmascript::tooling::final::final::Type1574         static std::string Global()
1575         {
1576             return "global";
1577         }
Localpanda::ecmascript::tooling::final::final::Type1578         static std::string Local()
1579         {
1580             return "local";
1581         }
Withpanda::ecmascript::tooling::final::final::Type1582         static std::string With()
1583         {
1584             return "with";
1585         }
Closurepanda::ecmascript::tooling::final::final::Type1586         static std::string Closure()
1587         {
1588             return "closure";
1589         }
Catchpanda::ecmascript::tooling::final::final::Type1590         static std::string Catch()
1591         {
1592             return "catch";
1593         }
Blockpanda::ecmascript::tooling::final::final::Type1594         static std::string Block()
1595         {
1596             return "block";
1597         }
Scriptpanda::ecmascript::tooling::final::final::Type1598         static std::string Script()
1599         {
1600             return "script";
1601         }
Evalpanda::ecmascript::tooling::final::final::Type1602         static std::string Eval()
1603         {
1604             return "eval";
1605         }
Modulepanda::ecmascript::tooling::final::final::Type1606         static std::string Module()
1607         {
1608             return "module";
1609         }
WasmExpressionStackpanda::ecmascript::tooling::final::final::Type1610         static std::string WasmExpressionStack()
1611         {
1612             return "wasm-expression-stack";
1613         }
1614     };
1615 
1616 private:
1617     NO_COPY_SEMANTIC(Scope);
1618     NO_MOVE_SEMANTIC(Scope);
1619 
1620     std::string type_ {};
1621     std::unique_ptr<RemoteObject> object_ {nullptr};
1622     std::optional<std::string> name_ {};
1623     std::optional<std::unique_ptr<Location>> startLocation_ {};
1624     std::optional<std::unique_ptr<Location>> endLocation_ {};
1625 };
1626 
1627 // Debugger.CallFrame
1628 class TOOLCHAIN_EXPORT CallFrame final : public PtBaseTypes {
1629 public:
1630     CallFrame() = default;
1631     ~CallFrame() override = default;
1632 
1633     static std::unique_ptr<CallFrame> Create(const PtJson &params);
1634     std::unique_ptr<PtJson> ToJson() const override;
1635 
GetCallFrameId() const1636     CallFrameId GetCallFrameId() const
1637     {
1638         return callFrameId_;
1639     }
1640 
SetCallFrameId(CallFrameId callFrameId)1641     CallFrame &SetCallFrameId(CallFrameId callFrameId)
1642     {
1643         callFrameId_ = callFrameId;
1644         return *this;
1645     }
1646 
GetFunctionName() const1647     const std::string &GetFunctionName() const
1648     {
1649         return functionName_;
1650     }
1651 
SetFunctionName(const std::string &functionName)1652     CallFrame &SetFunctionName(const std::string &functionName)
1653     {
1654         functionName_ = functionName;
1655         return *this;
1656     }
1657 
GetFunctionLocation() const1658     Location *GetFunctionLocation() const
1659     {
1660         if (functionLocation_) {
1661             return functionLocation_->get();
1662         }
1663         return nullptr;
1664     }
1665 
SetFunctionLocation(std::unique_ptr<Location> location)1666     CallFrame &SetFunctionLocation(std::unique_ptr<Location> location)
1667     {
1668         functionLocation_ = std::move(location);
1669         return *this;
1670     }
1671 
HasFunctionLocation() const1672     bool HasFunctionLocation() const
1673     {
1674         return functionLocation_.has_value();
1675     }
1676 
GetLocation() const1677     Location *GetLocation() const
1678     {
1679         return location_.get();
1680     }
1681 
SetLocation(std::unique_ptr<Location> location)1682     CallFrame &SetLocation(std::unique_ptr<Location> location)
1683     {
1684         location_ = std::move(location);
1685         return *this;
1686     }
1687 
GetUrl() const1688     const std::string &GetUrl() const
1689     {
1690         return url_;
1691     }
1692 
SetUrl(const std::string &url)1693     CallFrame &SetUrl(const std::string &url)
1694     {
1695         url_ = url;
1696         return *this;
1697     }
1698 
GetScopeChain() const1699     const std::vector<std::unique_ptr<Scope>> *GetScopeChain() const
1700     {
1701         return &scopeChain_;
1702     }
1703 
SetScopeChain(std::vector<std::unique_ptr<Scope>> scopeChain)1704     CallFrame &SetScopeChain(std::vector<std::unique_ptr<Scope>> scopeChain)
1705     {
1706         scopeChain_ = std::move(scopeChain);
1707         return *this;
1708     }
GetThis() const1709     RemoteObject *GetThis() const
1710     {
1711         return this_.get();
1712     }
1713 
SetThis(std::unique_ptr<RemoteObject> thisObj)1714     CallFrame &SetThis(std::unique_ptr<RemoteObject> thisObj)
1715     {
1716         this_ = std::move(thisObj);
1717         return *this;
1718     }
1719 
GetReturnValue() const1720     RemoteObject *GetReturnValue() const
1721     {
1722         if (returnValue_) {
1723             return returnValue_->get();
1724         }
1725         return nullptr;
1726     }
1727 
SetReturnValue(std::unique_ptr<RemoteObject> returnValue)1728     CallFrame &SetReturnValue(std::unique_ptr<RemoteObject> returnValue)
1729     {
1730         returnValue_ = std::move(returnValue);
1731         return *this;
1732     }
1733 
HasReturnValue() const1734     bool HasReturnValue() const
1735     {
1736         return returnValue_.has_value();
1737     }
1738 
1739 private:
1740     NO_COPY_SEMANTIC(CallFrame);
1741     NO_MOVE_SEMANTIC(CallFrame);
1742 
1743     CallFrameId callFrameId_ {};
1744     std::string functionName_ {};
1745     std::optional<std::unique_ptr<Location>> functionLocation_ {};
1746     std::unique_ptr<Location> location_ {nullptr};
1747     std::string url_ {};
1748     std::vector<std::unique_ptr<Scope>> scopeChain_ {};
1749     std::unique_ptr<RemoteObject> this_ {nullptr};
1750     std::optional<std::unique_ptr<RemoteObject>> returnValue_ {};
1751 };
1752 
1753 // ========== Heapprofiler types begin
1754 
1755 using HeapSnapshotObjectId = int32_t;
1756 
1757 class SamplingHeapProfileSample  final :  public PtBaseTypes {
1758 public:
1759     SamplingHeapProfileSample() = default;
1760     ~SamplingHeapProfileSample() override = default;
1761     static std::unique_ptr<SamplingHeapProfileSample> Create(const PtJson &params);
1762     std::unique_ptr<PtJson> ToJson() const override;
1763 
SetSize(int32_t size)1764     SamplingHeapProfileSample &SetSize(int32_t size)
1765     {
1766         size_ = size;
1767         return *this;
1768     }
1769 
GetSize() const1770     int32_t GetSize() const
1771     {
1772         return size_;
1773     }
1774 
SetNodeId(int32_t nodeId)1775     SamplingHeapProfileSample &SetNodeId(int32_t nodeId)
1776     {
1777         nodeId_ = nodeId;
1778         return *this;
1779     }
1780 
GetNodeId() const1781     int32_t GetNodeId() const
1782     {
1783         return nodeId_;
1784     }
1785 
SetOrdinal(int64_t ordinal)1786     SamplingHeapProfileSample &SetOrdinal(int64_t ordinal)
1787     {
1788         ordinal_ = ordinal;
1789         return *this;
1790     }
1791 
GetOrdinal() const1792     int64_t GetOrdinal() const
1793     {
1794         return ordinal_;
1795     }
1796 
1797 private:
1798     NO_COPY_SEMANTIC(SamplingHeapProfileSample);
1799     NO_MOVE_SEMANTIC(SamplingHeapProfileSample);
1800 
1801     int32_t size_ {0};
1802     int32_t nodeId_ {0};
1803     int64_t ordinal_ {0};
1804 };
1805 
1806 class RuntimeCallFrame  final :  public PtBaseTypes {
1807 public:
1808     RuntimeCallFrame() = default;
1809     ~RuntimeCallFrame() override = default;
1810     static std::unique_ptr<RuntimeCallFrame> Create(const PtJson &params);
1811     static std::unique_ptr<RuntimeCallFrame> FromFrameInfo(const FrameInfo &cpuFrameInfo);
1812     std::unique_ptr<PtJson> ToJson() const override;
1813 
SetFunctionName(const std::string &functionName)1814     RuntimeCallFrame &SetFunctionName(const std::string &functionName)
1815     {
1816         functionName_ = functionName;
1817         return *this;
1818     }
1819 
GetFunctionName() const1820     const std::string &GetFunctionName() const
1821     {
1822         return functionName_;
1823     }
1824 
SetModuleName(const std::string &moduleName)1825     RuntimeCallFrame &SetModuleName(const std::string &moduleName)
1826     {
1827         moduleName_ = moduleName;
1828         return *this;
1829     }
1830 
GetModuleName() const1831     const std::string &GetModuleName() const
1832     {
1833         return moduleName_;
1834     }
1835 
SetScriptId(const std::string &scriptId)1836     RuntimeCallFrame &SetScriptId(const std::string &scriptId)
1837     {
1838         scriptId_ = scriptId;
1839         return *this;
1840     }
1841 
GetScriptId() const1842     const std::string &GetScriptId() const
1843     {
1844         return scriptId_;
1845     }
1846 
SetUrl(const std::string &url)1847     RuntimeCallFrame &SetUrl(const std::string &url)
1848     {
1849         url_ = url;
1850         return *this;
1851     }
1852 
GetUrl() const1853     const std::string &GetUrl() const
1854     {
1855         return url_;
1856     }
1857 
SetLineNumber(int32_t lineNumber)1858     RuntimeCallFrame &SetLineNumber(int32_t lineNumber)
1859     {
1860         lineNumber_ = lineNumber;
1861         return *this;
1862     }
1863 
GetLineNumber() const1864     int32_t GetLineNumber() const
1865     {
1866         return lineNumber_;
1867     }
1868 
SetColumnNumber(int32_t columnNumber)1869     RuntimeCallFrame &SetColumnNumber(int32_t columnNumber)
1870     {
1871         columnNumber_ = columnNumber;
1872         return *this;
1873     }
1874 
GetColumnNumber() const1875     int32_t GetColumnNumber() const
1876     {
1877         return columnNumber_;
1878     }
1879 
1880 private:
1881     NO_COPY_SEMANTIC(RuntimeCallFrame);
1882     NO_MOVE_SEMANTIC(RuntimeCallFrame);
1883 
1884     std::string functionName_ {};
1885     std::string moduleName_ {};
1886     std::string scriptId_ {};
1887     std::string url_ {};
1888     int32_t lineNumber_ {0};
1889     int32_t columnNumber_ {0};
1890 };
1891 
1892 class SamplingHeapProfileNode  final :  public PtBaseTypes {
1893 public:
1894     SamplingHeapProfileNode() = default;
1895     ~SamplingHeapProfileNode() override = default;
1896     static std::unique_ptr<SamplingHeapProfileNode> Create(const PtJson &params);
1897     std::unique_ptr<PtJson> ToJson() const override;
1898 
SetCallFrame(std::unique_ptr<RuntimeCallFrame> callFrame)1899     SamplingHeapProfileNode &SetCallFrame(std::unique_ptr<RuntimeCallFrame> callFrame)
1900     {
1901         callFrame_ = std::move(callFrame);
1902         return *this;
1903     }
1904 
GetCallFrame() const1905     RuntimeCallFrame *GetCallFrame() const
1906     {
1907         return callFrame_.get();
1908     }
1909 
SetSelfSize(int32_t selfSize)1910     SamplingHeapProfileNode &SetSelfSize(int32_t selfSize)
1911     {
1912         selfSize_ = selfSize;
1913         return *this;
1914     }
1915 
GetSelfSize() const1916     int32_t GetSelfSize() const
1917     {
1918         return selfSize_;
1919     }
1920 
SetId(int32_t id)1921     SamplingHeapProfileNode &SetId(int32_t id)
1922     {
1923         id_ = id;
1924         return *this;
1925     }
1926 
GetId() const1927     int32_t GetId() const
1928     {
1929         return id_;
1930     }
1931 
SetChildren(std::vector<std::unique_ptr<SamplingHeapProfileNode>> children)1932     SamplingHeapProfileNode &SetChildren(std::vector<std::unique_ptr<SamplingHeapProfileNode>> children)
1933     {
1934         children_ = std::move(children);
1935         return *this;
1936     }
1937 
GetChildren() const1938     const std::vector<std::unique_ptr<SamplingHeapProfileNode>> *GetChildren() const
1939     {
1940         return &children_;
1941     }
1942 
1943 private:
1944     NO_COPY_SEMANTIC(SamplingHeapProfileNode);
1945     NO_MOVE_SEMANTIC(SamplingHeapProfileNode);
1946 
1947     std::unique_ptr<RuntimeCallFrame> callFrame_ {nullptr};
1948     int32_t selfSize_ {0};
1949     int32_t id_ {0};
1950     std::vector<std::unique_ptr<SamplingHeapProfileNode>> children_ {};
1951 };
1952 
1953 class SamplingHeapProfile final : public PtBaseTypes {
1954 public:
1955     SamplingHeapProfile() = default;
1956     ~SamplingHeapProfile() override = default;
1957     static std::unique_ptr<SamplingHeapProfile> Create(const PtJson &params);
1958     static std::unique_ptr<SamplingHeapProfile> FromSamplingInfo(const SamplingInfo *samplingInfo);
1959     static std::unique_ptr<SamplingHeapProfileNode> TransferHead(const SamplingNode *allocationNode);
1960     std::unique_ptr<PtJson> ToJson() const override;
1961 
SetHead(std::unique_ptr<SamplingHeapProfileNode> head)1962     SamplingHeapProfile &SetHead(std::unique_ptr<SamplingHeapProfileNode> head)
1963     {
1964         head_ = std::move(head);
1965         return *this;
1966     }
1967 
GetHead() const1968     SamplingHeapProfileNode *GetHead() const
1969     {
1970         return head_.get();
1971     }
1972 
SetSamples(std::vector<std::unique_ptr<SamplingHeapProfileSample>> samples)1973     SamplingHeapProfile &SetSamples(std::vector<std::unique_ptr<SamplingHeapProfileSample>> samples)
1974     {
1975         samples_ = std::move(samples);
1976         return *this;
1977     }
1978 
GetSamples() const1979     const std::vector<std::unique_ptr<SamplingHeapProfileSample>> *GetSamples() const
1980     {
1981         return &samples_;
1982     }
1983 
1984 private:
1985     NO_COPY_SEMANTIC(SamplingHeapProfile);
1986     NO_MOVE_SEMANTIC(SamplingHeapProfile);
1987 
1988     std::unique_ptr<SamplingHeapProfileNode> head_ {nullptr};
1989     std::vector<std::unique_ptr<SamplingHeapProfileSample>> samples_ {};
1990 };
1991 
1992 // ========== Profiler types begin
1993 // Profiler.PositionTickInfo
1994 class PositionTickInfo final : public PtBaseTypes {
1995 public:
1996     PositionTickInfo() = default;
1997     ~PositionTickInfo() override = default;
1998 
1999     static std::unique_ptr<PositionTickInfo> Create(const PtJson &params);
2000     std::unique_ptr<PtJson> ToJson() const override;
2001 
GetLine() const2002     int32_t GetLine() const
2003     {
2004         return line_;
2005     }
2006 
SetLine(int32_t line)2007     PositionTickInfo &SetLine(int32_t line)
2008     {
2009         line_ = line;
2010         return *this;
2011     }
2012 
GetTicks() const2013     int32_t GetTicks() const
2014     {
2015         return ticks_;
2016     }
2017 
SetTicks(int32_t ticks)2018     PositionTickInfo &SetTicks(int32_t ticks)
2019     {
2020         ticks_ = ticks;
2021         return *this;
2022     }
2023 
2024 private:
2025     NO_COPY_SEMANTIC(PositionTickInfo);
2026     NO_MOVE_SEMANTIC(PositionTickInfo);
2027     int32_t line_ {0};
2028     int32_t ticks_ {0};
2029 };
2030 
2031 // Profiler.ProfileNode
2032 class ProfileNode final : public PtBaseTypes {
2033 public:
2034     ProfileNode() = default;
2035     ~ProfileNode() override = default;
2036 
2037     static std::unique_ptr<ProfileNode> Create(const PtJson &params);
2038     static std::unique_ptr<ProfileNode> FromCpuProfileNode(const CpuProfileNode &cpuProfileNode);
2039     std::unique_ptr<PtJson> ToJson() const override;
2040 
GetId() const2041     int32_t GetId() const
2042     {
2043         return id_;
2044     }
2045 
SetId(int32_t id)2046     ProfileNode &SetId(int32_t id)
2047     {
2048         id_ = id;
2049         return *this;
2050     }
2051 
GetCallFrame() const2052     RuntimeCallFrame *GetCallFrame() const
2053     {
2054         return callFrame_.get();
2055     }
2056 
SetCallFrame(std::unique_ptr<RuntimeCallFrame> callFrame)2057     ProfileNode &SetCallFrame(std::unique_ptr<RuntimeCallFrame> callFrame)
2058     {
2059         callFrame_ = std::move(callFrame);
2060         return *this;
2061     }
2062 
GetHitCount() const2063     int32_t GetHitCount() const
2064     {
2065         ASSERT(HasHitCount());
2066         return hitCount_.value();
2067     }
2068 
SetHitCount(int32_t hitCount)2069     ProfileNode &SetHitCount(int32_t hitCount)
2070     {
2071         hitCount_ = hitCount;
2072         return *this;
2073     }
2074 
HasHitCount() const2075     bool HasHitCount() const
2076     {
2077         return hitCount_.has_value();
2078     }
2079 
GetChildren() const2080     const std::vector<int32_t> *GetChildren() const
2081     {
2082         if (children_) {
2083             return &children_.value();
2084         }
2085         return nullptr;
2086     }
2087 
SetChildren(std::vector<int32_t> children)2088     ProfileNode &SetChildren(std::vector<int32_t> children)
2089     {
2090         children_ = std::move(children);
2091         return *this;
2092     }
2093 
HasChildren() const2094     bool HasChildren() const
2095     {
2096         return children_.has_value();
2097     }
2098 
GetPositionTicks() const2099     const std::vector<std::unique_ptr<PositionTickInfo>> *GetPositionTicks() const
2100     {
2101         if (positionTicks_) {
2102             return &positionTicks_.value();
2103         }
2104         return nullptr;
2105     }
2106 
SetPositionTicks(std::vector<std::unique_ptr<PositionTickInfo>> positionTicks)2107     ProfileNode &SetPositionTicks(std::vector<std::unique_ptr<PositionTickInfo>> positionTicks)
2108     {
2109         positionTicks_ = std::move(positionTicks);
2110         return *this;
2111     }
2112 
HasPositionTicks() const2113     bool HasPositionTicks() const
2114     {
2115         return positionTicks_.has_value();
2116     }
2117 
GetDeoptReason() const2118     const std::string &GetDeoptReason() const
2119     {
2120         ASSERT(HasDeoptReason());
2121         return deoptReason_.value();
2122     }
2123 
SetDeoptReason(const std::string &deoptReason)2124     ProfileNode &SetDeoptReason(const std::string &deoptReason)
2125     {
2126         deoptReason_ = deoptReason;
2127         return *this;
2128     }
2129 
HasDeoptReason() const2130     bool HasDeoptReason() const
2131     {
2132         return deoptReason_.has_value();
2133     }
2134 
2135 private:
2136     NO_COPY_SEMANTIC(ProfileNode);
2137     NO_MOVE_SEMANTIC(ProfileNode);
2138     int32_t id_ {0};
2139     std::unique_ptr<RuntimeCallFrame> callFrame_ {nullptr};
2140     std::optional<int32_t> hitCount_ {0};
2141     std::optional<std::vector<int32_t>> children_ {};
2142     std::optional<std::vector<std::unique_ptr<PositionTickInfo>>> positionTicks_ {};
2143     std::optional<std::string> deoptReason_ {};
2144 };
2145 
2146 // Profiler.Profile
2147 class Profile final : public PtBaseTypes {
2148 public:
2149     Profile() = default;
2150     ~Profile() override = default;
2151 
2152     static std::unique_ptr<Profile> Create(const PtJson &params);
2153     static std::unique_ptr<Profile> FromProfileInfo(const ProfileInfo &profileInfo);
2154     std::unique_ptr<PtJson> ToJson() const override;
2155 
GetTid() const2156     int64_t GetTid() const
2157     {
2158         return tid_;
2159     }
2160 
SetTid(int64_t tid)2161     Profile &SetTid(int64_t tid)
2162     {
2163         tid_ = tid;
2164         return *this;
2165     }
2166 
GetStartTime() const2167     int64_t GetStartTime() const
2168     {
2169         return startTime_;
2170     }
2171 
SetStartTime(int64_t startTime)2172     Profile &SetStartTime(int64_t startTime)
2173     {
2174         startTime_ = startTime;
2175         return *this;
2176     }
2177 
GetEndTime() const2178     int64_t GetEndTime() const
2179     {
2180         return endTime_;
2181     }
2182 
SetEndTime(int64_t endTime)2183     Profile &SetEndTime(int64_t endTime)
2184     {
2185         endTime_ = endTime;
2186         return *this;
2187     }
2188 
GetGcTime() const2189     int64_t GetGcTime() const
2190     {
2191         return gcTime_;
2192     }
2193 
SetGcTime(int64_t gcTime)2194     Profile &SetGcTime(int64_t gcTime)
2195     {
2196         gcTime_ = gcTime;
2197         return *this;
2198     }
2199 
GetCInterpreterTime() const2200     int64_t GetCInterpreterTime() const
2201     {
2202         return cInterpreterTime_;
2203     }
2204 
SetCInterpreterTime(int64_t cInterpreterTime)2205     Profile &SetCInterpreterTime(int64_t cInterpreterTime)
2206     {
2207         cInterpreterTime_ = cInterpreterTime;
2208         return *this;
2209     }
2210 
GetAsmInterpreterTime() const2211     int64_t GetAsmInterpreterTime() const
2212     {
2213         return asmInterpreterTime_;
2214     }
2215 
SetAsmInterpreterTime(int64_t asmInterpreterTime)2216     Profile &SetAsmInterpreterTime(int64_t asmInterpreterTime)
2217     {
2218         asmInterpreterTime_ = asmInterpreterTime;
2219         return *this;
2220     }
2221 
GetAotTime() const2222     int64_t GetAotTime() const
2223     {
2224         return aotTime_;
2225     }
2226 
SetAotTime(int64_t aotTime)2227     Profile &SetAotTime(int64_t aotTime)
2228     {
2229         aotTime_ = aotTime;
2230         return *this;
2231     }
2232 
GetBuiltinTime() const2233     int64_t GetBuiltinTime() const
2234     {
2235         return builtinTime_;
2236     }
2237 
SetBuiltinTime(int64_t builtinTime)2238     Profile &SetBuiltinTime(int64_t builtinTime)
2239     {
2240         builtinTime_ = builtinTime;
2241         return *this;
2242     }
2243 
GetNapiTime() const2244     int64_t GetNapiTime() const
2245     {
2246         return napiTime_;
2247     }
2248 
SetNapiTime(int64_t napiTime)2249     Profile &SetNapiTime(int64_t napiTime)
2250     {
2251         napiTime_ = napiTime;
2252         return *this;
2253     }
2254 
GetArkuiEngineTime() const2255     int64_t GetArkuiEngineTime() const
2256     {
2257         return arkuiEngineTime_;
2258     }
2259 
SetArkuiEngineTime(int64_t arkuiEngineTime)2260     Profile &SetArkuiEngineTime(int64_t arkuiEngineTime)
2261     {
2262         arkuiEngineTime_ = arkuiEngineTime;
2263         return *this;
2264     }
2265 
GetRuntimeTime() const2266     int64_t GetRuntimeTime() const
2267     {
2268         return runtimeTime_;
2269     }
2270 
SetRuntimeTime(int64_t runtimeTime)2271     Profile &SetRuntimeTime(int64_t runtimeTime)
2272     {
2273         runtimeTime_ = runtimeTime;
2274         return *this;
2275     }
2276 
GetOtherTime() const2277     int64_t GetOtherTime() const
2278     {
2279         return otherTime_;
2280     }
2281 
SetOtherTime(int64_t otherTime)2282     Profile &SetOtherTime(int64_t otherTime)
2283     {
2284         otherTime_ = otherTime;
2285         return *this;
2286     }
2287 
GetNodes() const2288     const std::vector<std::unique_ptr<ProfileNode>> *GetNodes() const
2289     {
2290         return &nodes_;
2291     }
2292 
SetNodes(std::vector<std::unique_ptr<ProfileNode>> nodes)2293     Profile &SetNodes(std::vector<std::unique_ptr<ProfileNode>> nodes)
2294     {
2295         nodes_ = std::move(nodes);
2296         return *this;
2297     }
2298 
GetSamples() const2299     const std::vector<int32_t> *GetSamples() const
2300     {
2301         if (samples_) {
2302             return &samples_.value();
2303         }
2304         return nullptr;
2305     }
2306 
SetSamples(std::vector<int32_t> samples)2307     Profile &SetSamples(std::vector<int32_t> samples)
2308     {
2309         samples_ = std::move(samples);
2310         return *this;
2311     }
2312 
HasSamples() const2313     bool HasSamples() const
2314     {
2315         return samples_.has_value();
2316     }
2317 
GetTimeDeltas() const2318     const std::vector<int32_t> *GetTimeDeltas() const
2319     {
2320         if (timeDeltas_) {
2321             return &timeDeltas_.value();
2322         }
2323         return nullptr;
2324     }
2325 
SetTimeDeltas(std::vector<int32_t> timeDeltas)2326     Profile &SetTimeDeltas(std::vector<int32_t> timeDeltas)
2327     {
2328         timeDeltas_ = std::move(timeDeltas);
2329         return *this;
2330     }
2331 
HasTimeDeltas() const2332     bool HasTimeDeltas() const
2333     {
2334         return timeDeltas_.has_value();
2335     }
2336 
2337 private:
2338     NO_COPY_SEMANTIC(Profile);
2339     NO_MOVE_SEMANTIC(Profile);
2340 
2341     int64_t tid_ {0};
2342     int64_t startTime_ {0};
2343     int64_t endTime_ {0};
2344     int64_t gcTime_ {0};
2345     int64_t cInterpreterTime_ {0};
2346     int64_t asmInterpreterTime_ {0};
2347     int64_t aotTime_ {0};
2348     int64_t builtinTime_ {0};
2349     int64_t napiTime_ {0};
2350     int64_t arkuiEngineTime_ {0};
2351     int64_t runtimeTime_ {0};
2352     int64_t otherTime_ {0};
2353     std::vector<std::unique_ptr<ProfileNode>> nodes_ {};
2354     std::optional<std::vector<int32_t>> samples_ {};
2355     std::optional<std::vector<int32_t>> timeDeltas_ {};
2356 };
2357 
2358 // Profiler.Coverage
2359 class Coverage final : public PtBaseTypes {
2360 public:
2361     Coverage() = default;
2362     ~Coverage() override = default;
2363 
2364     static std::unique_ptr<Coverage> Create(const PtJson &params);
2365     std::unique_ptr<PtJson> ToJson() const override;
2366 
GetStartOffset() const2367     int32_t GetStartOffset() const
2368     {
2369         return startOffset_;
2370     }
2371 
SetStartOffset(int32_t startOffset)2372     Coverage &SetStartOffset(int32_t startOffset)
2373     {
2374         startOffset_ = startOffset;
2375         return *this;
2376     }
2377 
GetEndOffset() const2378     int32_t GetEndOffset() const
2379     {
2380         return endOffset_;
2381     }
2382 
SetEndOffset(int32_t endOffset)2383     Coverage &SetEndOffset(int32_t endOffset)
2384     {
2385         endOffset_ = endOffset;
2386         return *this;
2387     }
2388 
GetCount() const2389     int32_t GetCount() const
2390     {
2391         return count_;
2392     }
2393 
SetCount(int32_t count)2394     Coverage &SetCount(int32_t count)
2395     {
2396         count_ = count;
2397         return *this;
2398     }
2399 
2400 private:
2401     NO_COPY_SEMANTIC(Coverage);
2402     NO_MOVE_SEMANTIC(Coverage);
2403 
2404     int32_t startOffset_ {0};
2405     int32_t endOffset_ {0};
2406     int32_t count_ {0};
2407 };
2408 
2409 // Profiler.FunctionCoverage
2410 class FunctionCoverage final : public PtBaseTypes {
2411 public:
2412     FunctionCoverage() = default;
2413     ~FunctionCoverage() override = default;
2414 
2415     static std::unique_ptr<FunctionCoverage> Create(const PtJson &params);
2416     std::unique_ptr<PtJson> ToJson() const override;
2417 
GetFunctionName() const2418     const std::string &GetFunctionName() const
2419     {
2420         return functionName_;
2421     }
2422 
SetFunctionName(const std::string &functionName)2423     FunctionCoverage &SetFunctionName(const std::string &functionName)
2424     {
2425         functionName_ = functionName;
2426         return *this;
2427     }
2428 
GetRanges() const2429     const std::vector<std::unique_ptr<Coverage>> *GetRanges() const
2430     {
2431         return &ranges_;
2432     }
2433 
SetFunctions(std::vector<std::unique_ptr<Coverage>> ranges)2434     FunctionCoverage &SetFunctions(std::vector<std::unique_ptr<Coverage>> ranges)
2435     {
2436         ranges_ = std::move(ranges);
2437         return *this;
2438     }
2439 
GetIsBlockCoverage() const2440     bool GetIsBlockCoverage() const
2441     {
2442         return isBlockCoverage_;
2443     }
2444 
SetisBlockCoverage(bool isBlockCoverage)2445     FunctionCoverage &SetisBlockCoverage(bool isBlockCoverage)
2446     {
2447         isBlockCoverage_ = isBlockCoverage;
2448         return *this;
2449     }
2450 
2451 private:
2452     NO_COPY_SEMANTIC(FunctionCoverage);
2453     NO_MOVE_SEMANTIC(FunctionCoverage);
2454 
2455     std::string functionName_ {};
2456     std::vector<std::unique_ptr<Coverage>> ranges_ {};
2457     bool isBlockCoverage_ {};
2458 };
2459 
2460 // Profiler.ScriptCoverage
2461 // Profiler.GetBestEffortCoverage and Profiler.TakePreciseCoverage share this return value type
2462 class ScriptCoverage final : public PtBaseTypes {
2463 public:
2464     ScriptCoverage() = default;
2465     ~ScriptCoverage() override = default;
2466 
2467     static std::unique_ptr<ScriptCoverage> Create(const PtJson &params);
2468     std::unique_ptr<PtJson> ToJson() const override;
2469 
GetScriptId() const2470     const std::string &GetScriptId() const
2471     {
2472         return scriptId_;
2473     }
2474 
SetScriptId(const std::string &scriptId)2475     ScriptCoverage &SetScriptId(const std::string &scriptId)
2476     {
2477         scriptId_ = scriptId;
2478         return *this;
2479     }
2480 
GetUrl() const2481     const std::string &GetUrl() const
2482     {
2483         return url_;
2484     }
2485 
SetUrl(const std::string &url)2486     ScriptCoverage &SetUrl(const std::string &url)
2487     {
2488         url_ = url;
2489         return *this;
2490     }
2491 
GetFunctions() const2492     const std::vector<std::unique_ptr<FunctionCoverage>> *GetFunctions() const
2493     {
2494         return &functions_;
2495     }
2496 
SetFunctions(std::vector<std::unique_ptr<FunctionCoverage>> functions)2497     ScriptCoverage &SetFunctions(std::vector<std::unique_ptr<FunctionCoverage>> functions)
2498     {
2499         functions_ = std::move(functions);
2500         return *this;
2501     }
2502 
2503 private:
2504     NO_COPY_SEMANTIC(ScriptCoverage);
2505     NO_MOVE_SEMANTIC(ScriptCoverage);
2506 
2507     std::string scriptId_ {};
2508     std::string url_ {};
2509     std::vector<std::unique_ptr<FunctionCoverage>> functions_ {};
2510 };
2511 
2512 // Profiler.TypeObject
2513 class TypeObject final : public PtBaseTypes {
2514 public:
2515     TypeObject() = default;
2516     ~TypeObject() override = default;
2517 
2518     static std::unique_ptr<TypeObject> Create(const PtJson &params);
2519     std::unique_ptr<PtJson> ToJson() const override;
2520 
GetName() const2521     const std::string &GetName() const
2522     {
2523         return name_;
2524     }
2525 
SetName(const std::string &name)2526     TypeObject &SetName(const std::string &name)
2527     {
2528         name_ = name;
2529         return *this;
2530     }
2531 
2532 private:
2533     NO_COPY_SEMANTIC(TypeObject);
2534     NO_MOVE_SEMANTIC(TypeObject);
2535 
2536     std::string name_ {};
2537 };
2538 
2539 // Profiler.TypeProfileEntry
2540 class TypeProfileEntry final : public PtBaseTypes {
2541 public:
2542     TypeProfileEntry() = default;
2543     ~TypeProfileEntry() override = default;
2544 
2545     static std::unique_ptr<TypeProfileEntry> Create(const PtJson &params);
2546     std::unique_ptr<PtJson> ToJson() const override;
2547 
GetOffset() const2548     int32_t GetOffset() const
2549     {
2550         return offset_;
2551     }
2552 
SetOffset(int32_t offset)2553     TypeProfileEntry &SetOffset(int32_t offset)
2554     {
2555         offset_ = offset;
2556         return *this;
2557     }
2558 
GetTypes() const2559     const std::vector<std::unique_ptr<TypeObject>> *GetTypes() const
2560     {
2561         return &types_;
2562     }
2563 
SetTypes(std::vector<std::unique_ptr<TypeObject>> types)2564     TypeProfileEntry &SetTypes(std::vector<std::unique_ptr<TypeObject>> types)
2565     {
2566         types_ = std::move(types);
2567         return *this;
2568     }
2569 
2570 private:
2571     NO_COPY_SEMANTIC(TypeProfileEntry);
2572     NO_MOVE_SEMANTIC(TypeProfileEntry);
2573 
2574     int32_t offset_ {0};
2575     std::vector<std::unique_ptr<TypeObject>> types_ {};
2576 };
2577 
2578 // Profiler.ScriptTypeProfile
2579 class ScriptTypeProfile final : public PtBaseTypes {
2580 public:
2581     ScriptTypeProfile() = default;
2582     ~ScriptTypeProfile() override = default;
2583 
2584     static std::unique_ptr<ScriptTypeProfile> Create(const PtJson &params);
2585     std::unique_ptr<PtJson> ToJson() const override;
2586 
GetScriptId() const2587     const std::string &GetScriptId() const
2588     {
2589         return scriptId_;
2590     }
2591 
SetScriptId(const std::string &scriptId)2592     ScriptTypeProfile &SetScriptId(const std::string &scriptId)
2593     {
2594         scriptId_ = scriptId;
2595         return *this;
2596     }
2597 
GetUrl() const2598     const std::string &GetUrl() const
2599     {
2600         return url_;
2601     }
2602 
SetUrl(const std::string &url)2603     ScriptTypeProfile &SetUrl(const std::string &url)
2604     {
2605         url_ = url;
2606         return *this;
2607     }
2608 
GetEntries() const2609     const std::vector<std::unique_ptr<TypeProfileEntry>> *GetEntries() const
2610     {
2611         return &entries_;
2612     }
2613 
SetEntries(std::vector<std::unique_ptr<TypeProfileEntry>> entries)2614     ScriptTypeProfile &SetEntries(std::vector<std::unique_ptr<TypeProfileEntry>> entries)
2615     {
2616         entries_ = std::move(entries);
2617         return *this;
2618     }
2619 
2620 private:
2621     NO_COPY_SEMANTIC(ScriptTypeProfile);
2622     NO_MOVE_SEMANTIC(ScriptTypeProfile);
2623 
2624     std::string scriptId_ {};
2625     std::string url_ {};
2626     std::vector<std::unique_ptr<TypeProfileEntry>> entries_ {};
2627 };
2628 
2629 // ========== Tracing types begin
2630 // Tracing.MemoryDumpConfig
2631 using MemoryDumpConfig = PtJson;
2632 
2633 // Tracing.MemoryDumpLevelOfDetail
2634 using MemoryDumpLevelOfDetail = std::string;
2635 struct MemoryDumpLevelOfDetailValues {
Validpanda::ecmascript::tooling::final::MemoryDumpLevelOfDetailValues2636     static bool Valid(const std::string &values)
2637     {
2638         return values == Background() || values == Light() || values == Detailed();
2639     }
Backgroundpanda::ecmascript::tooling::final::MemoryDumpLevelOfDetailValues2640     static std::string Background()
2641     {
2642         return "background";
2643     }
Lightpanda::ecmascript::tooling::final::MemoryDumpLevelOfDetailValues2644     static std::string Light()
2645     {
2646         return "light";
2647     }
Detailedpanda::ecmascript::tooling::final::MemoryDumpLevelOfDetailValues2648     static std::string Detailed()
2649     {
2650         return "detailed";
2651     }
2652 };
2653 
2654 // Tracing.StreamCompression
2655 using StreamCompression = std::string;
2656 struct StreamCompressionValues {
Validpanda::ecmascript::tooling::final::StreamCompressionValues2657     static bool Valid(const std::string &values)
2658     {
2659         return values == None() || values == Gzip();
2660     }
Nonepanda::ecmascript::tooling::final::StreamCompressionValues2661     static std::string None()
2662     {
2663         return "none";
2664     }
Gzippanda::ecmascript::tooling::final::StreamCompressionValues2665     static std::string Gzip()
2666     {
2667         return "gzip";
2668     }
2669 };
2670 
2671 // Tracing.StreamFormat
2672 using StreamFormat = std::string;
2673 struct StreamFormatValues {
Validpanda::ecmascript::tooling::final::StreamFormatValues2674     static bool Valid(const std::string &values)
2675     {
2676         return values == Json() || values == Proto();
2677     }
Jsonpanda::ecmascript::tooling::final::StreamFormatValues2678     static std::string Json()
2679     {
2680         return "json";
2681     }
Protopanda::ecmascript::tooling::final::StreamFormatValues2682     static std::string Proto()
2683     {
2684         return "proto";
2685     }
2686 };
2687 
2688 // Tracing.TraceConfig
2689 class TraceConfig final : public PtBaseTypes {
2690 public:
2691     TraceConfig() = default;
2692     ~TraceConfig() override = default;
2693 
2694     static std::unique_ptr<TraceConfig> Create(const PtJson &params);
2695     std::unique_ptr<PtJson> ToJson() const override;
2696 
GetRecordMode() const2697     std::string GetRecordMode() const
2698     {
2699         return recordMode_.value();
2700     }
2701 
SetRecordMode(std::string recordMode)2702     TraceConfig &SetRecordMode(std::string recordMode)
2703     {
2704         recordMode_ = recordMode;
2705         return *this;
2706     }
2707 
HasRecordMode() const2708     bool HasRecordMode() const
2709     {
2710         return recordMode_.has_value();
2711     }
2712 
2713     struct RecordModeValues {
Validpanda::ecmascript::tooling::final::final::RecordModeValues2714         static bool Valid(const std::string &values)
2715         {
2716             return values == RecordUntilFull() || values == RecordContinuously() ||
2717                    values == RecordAsMuchAsPossible() || values == EchoToConsole();
2718         }
RecordUntilFullpanda::ecmascript::tooling::final::final::RecordModeValues2719         static std::string RecordUntilFull()
2720         {
2721             return "recordUntilFull";
2722         }
RecordContinuouslypanda::ecmascript::tooling::final::final::RecordModeValues2723         static std::string RecordContinuously()
2724         {
2725             return "recordContinuously";
2726         }
RecordAsMuchAsPossiblepanda::ecmascript::tooling::final::final::RecordModeValues2727         static std::string RecordAsMuchAsPossible()
2728         {
2729             return "recordAsMuchAsPossible";
2730         }
EchoToConsolepanda::ecmascript::tooling::final::final::RecordModeValues2731         static std::string EchoToConsole()
2732         {
2733             return "echoToConsole";
2734         }
2735     };
2736 
GetEnableSampling() const2737     bool GetEnableSampling() const
2738     {
2739         return enableSampling_.value();
2740     }
2741 
SetEnableSampling(bool enableSampling)2742     TraceConfig &SetEnableSampling(bool enableSampling)
2743     {
2744         enableSampling_ = enableSampling;
2745         return *this;
2746     }
2747 
HasEnableSampling() const2748     bool HasEnableSampling() const
2749     {
2750         return enableSampling_.has_value();
2751     }
2752 
GetEnableSystrace() const2753     bool GetEnableSystrace() const
2754     {
2755         return enableSystrace_.value();
2756     }
2757 
SetEnableSystrace(bool enableSystrace)2758     TraceConfig &SetEnableSystrace(bool enableSystrace)
2759     {
2760         enableSystrace_ = enableSystrace;
2761         return *this;
2762     }
2763 
HasEnableSystrace() const2764     bool HasEnableSystrace() const
2765     {
2766         return enableSystrace_.has_value();
2767     }
2768 
GetEnableArgumentFilter() const2769     bool GetEnableArgumentFilter() const
2770     {
2771         return enableArgumentFilter_.value();
2772     }
2773 
SetEnableArgumentFilter(bool enableArgumentFilter)2774     TraceConfig &SetEnableArgumentFilter(bool enableArgumentFilter)
2775     {
2776         enableArgumentFilter_ = enableArgumentFilter;
2777         return *this;
2778     }
2779 
HasEnableArgumentFilter() const2780     bool HasEnableArgumentFilter() const
2781     {
2782         return enableArgumentFilter_.has_value();
2783     }
2784 
GetIncludedCategories() const2785     const std::vector<std::string> *GetIncludedCategories() const
2786     {
2787         if (includedCategories_) {
2788             return &includedCategories_.value();
2789         }
2790         return nullptr;
2791     }
2792 
SetIncludedCategories(std::vector<std::string> includedCategories)2793     TraceConfig &SetIncludedCategories(std::vector<std::string> includedCategories)
2794     {
2795         includedCategories_ = includedCategories;
2796         return *this;
2797     }
2798 
HasIncludedCategories() const2799     bool HasIncludedCategories() const
2800     {
2801         return includedCategories_.has_value();
2802     }
2803 
GetExcludedCategories() const2804     const std::vector<std::string> *GetExcludedCategories() const
2805     {
2806         if (excludedCategories_) {
2807             return &excludedCategories_.value();
2808         }
2809         return nullptr;
2810     }
2811 
SetExcludedCategories(std::vector<std::string> excludedCategories)2812     TraceConfig &SetExcludedCategories(std::vector<std::string> excludedCategories)
2813     {
2814         excludedCategories_ = excludedCategories;
2815         return *this;
2816     }
2817 
HasExcludedCategories() const2818     bool HasExcludedCategories() const
2819     {
2820         return excludedCategories_.has_value();
2821     }
2822 
GetSyntheticDelays() const2823     const std::vector<std::string> *GetSyntheticDelays() const
2824     {
2825         if (syntheticDelays_) {
2826             return &syntheticDelays_.value();
2827         }
2828         return nullptr;
2829     }
2830 
SetSyntheticDelays(std::vector<std::string> syntheticDelays)2831     TraceConfig &SetSyntheticDelays(std::vector<std::string> syntheticDelays)
2832     {
2833         syntheticDelays_ = syntheticDelays;
2834         return *this;
2835     }
2836 
HasSyntheticDelays() const2837     bool HasSyntheticDelays() const
2838     {
2839         return syntheticDelays_.has_value();
2840     }
2841 
2842 private:
2843     NO_COPY_SEMANTIC(TraceConfig);
2844     NO_MOVE_SEMANTIC(TraceConfig);
2845 
2846     std::optional<std::string> recordMode_ {};
2847     std::optional<bool> enableSampling_ {};
2848     std::optional<bool> enableSystrace_ {};
2849     std::optional<bool> enableArgumentFilter_ {};
2850     std::optional<std::vector<std::string>> includedCategories_ {};
2851     std::optional<std::vector<std::string>> excludedCategories_ {};
2852     std::optional<std::vector<std::string>> syntheticDelays_ {};
2853     std::optional<std::unique_ptr<MemoryDumpConfig>> memoryDumpConfig_ {};
2854 };
2855 
2856 // Tracing.TracingBackend
2857 using TracingBackend = std::string;
2858 struct TracingBackendValues {
Validpanda::ecmascript::tooling::final::TracingBackendValues2859     static bool Valid(const std::string &values)
2860     {
2861         return values == Auto() || values == Chrome() || values == System();
2862     }
Autopanda::ecmascript::tooling::final::TracingBackendValues2863     static std::string Auto()
2864     {
2865         return "auto";
2866     }
Chromepanda::ecmascript::tooling::final::TracingBackendValues2867     static std::string Chrome()
2868     {
2869         return "chrome";
2870     }
Systempanda::ecmascript::tooling::final::TracingBackendValues2871     static std::string System()
2872     {
2873         return "system";
2874     }
2875 };
2876 }  // namespace panda::ecmascript::tooling
2877 #endif
2878