11cb0ef41Sopenharmony_ci// Copyright 2020 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#ifndef V8_REGEXP_EXPERIMENTAL_EXPERIMENTAL_COMPILER_H_
61cb0ef41Sopenharmony_ci#define V8_REGEXP_EXPERIMENTAL_EXPERIMENTAL_COMPILER_H_
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci#include "src/regexp/experimental/experimental-bytecode.h"
91cb0ef41Sopenharmony_ci#include "src/regexp/regexp-ast.h"
101cb0ef41Sopenharmony_ci#include "src/regexp/regexp-flags.h"
111cb0ef41Sopenharmony_ci#include "src/zone/zone-list.h"
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_cinamespace v8 {
141cb0ef41Sopenharmony_cinamespace internal {
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ciclass ExperimentalRegExpCompiler final : public AllStatic {
171cb0ef41Sopenharmony_ci public:
181cb0ef41Sopenharmony_ci  // Checks whether a given RegExpTree can be compiled into an experimental
191cb0ef41Sopenharmony_ci  // bytecode program.  This mostly amounts to the absence of back references,
201cb0ef41Sopenharmony_ci  // but see the definition.
211cb0ef41Sopenharmony_ci  // TODO(mbid,v8:10765): Currently more things are not handled, e.g. some
221cb0ef41Sopenharmony_ci  // quantifiers and unicode.
231cb0ef41Sopenharmony_ci  static bool CanBeHandled(RegExpTree* tree, RegExpFlags flags,
241cb0ef41Sopenharmony_ci                           int capture_count);
251cb0ef41Sopenharmony_ci  // Compile regexp into a bytecode program.  The regexp must be handlable by
261cb0ef41Sopenharmony_ci  // the experimental engine; see`CanBeHandled`.  The program is returned as a
271cb0ef41Sopenharmony_ci  // ZoneList backed by the same Zone that is used in the RegExpTree argument.
281cb0ef41Sopenharmony_ci  static ZoneList<RegExpInstruction> Compile(RegExpTree* tree,
291cb0ef41Sopenharmony_ci                                             RegExpFlags flags, Zone* zone);
301cb0ef41Sopenharmony_ci};
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ci}  // namespace internal
331cb0ef41Sopenharmony_ci}  // namespace v8
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_ci#endif  // V8_REGEXP_EXPERIMENTAL_EXPERIMENTAL_COMPILER_H_
36