11cb0ef41Sopenharmony_ci// Copyright 2016 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_PARSING_PARSING_H_
61cb0ef41Sopenharmony_ci#define V8_PARSING_PARSING_H_
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci#include "src/common/globals.h"
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_cinamespace v8 {
111cb0ef41Sopenharmony_cinamespace internal {
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ciclass ParseInfo;
141cb0ef41Sopenharmony_ciclass SharedFunctionInfo;
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_cinamespace parsing {
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_cienum class ReportStatisticsMode { kYes, kNo };
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ci// Parses the top-level source code represented by the parse info and sets its
211cb0ef41Sopenharmony_ci// function literal. Returns false (and deallocates any allocated AST nodes) if
221cb0ef41Sopenharmony_ci// parsing failed.
231cb0ef41Sopenharmony_ciV8_EXPORT_PRIVATE bool ParseProgram(ParseInfo* info, Handle<Script> script,
241cb0ef41Sopenharmony_ci                                    Isolate* isolate,
251cb0ef41Sopenharmony_ci                                    ReportStatisticsMode mode);
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ci// Parses the top-level source code represented by the parse info and sets its
281cb0ef41Sopenharmony_ci// function literal. Allows passing an |outer_scope| for programs that exist in
291cb0ef41Sopenharmony_ci// another scope (e.g. eval). Returns false (and deallocates any allocated AST
301cb0ef41Sopenharmony_ci// nodes) if parsing failed.
311cb0ef41Sopenharmony_ciV8_EXPORT_PRIVATE bool ParseProgram(ParseInfo* info, Handle<Script> script,
321cb0ef41Sopenharmony_ci                                    MaybeHandle<ScopeInfo> outer_scope,
331cb0ef41Sopenharmony_ci                                    Isolate* isolate,
341cb0ef41Sopenharmony_ci                                    ReportStatisticsMode mode);
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ci// Like ParseProgram but for an individual function which already has a
371cb0ef41Sopenharmony_ci// allocated shared function info.
381cb0ef41Sopenharmony_ciV8_EXPORT_PRIVATE bool ParseFunction(ParseInfo* info,
391cb0ef41Sopenharmony_ci                                     Handle<SharedFunctionInfo> shared_info,
401cb0ef41Sopenharmony_ci                                     Isolate* isolate,
411cb0ef41Sopenharmony_ci                                     ReportStatisticsMode mode);
421cb0ef41Sopenharmony_ci
431cb0ef41Sopenharmony_ci// If you don't know whether info->is_toplevel() is true or not, use this method
441cb0ef41Sopenharmony_ci// to dispatch to either of the above functions. Prefer to use the above methods
451cb0ef41Sopenharmony_ci// whenever possible.
461cb0ef41Sopenharmony_ciV8_EXPORT_PRIVATE bool ParseAny(ParseInfo* info,
471cb0ef41Sopenharmony_ci                                Handle<SharedFunctionInfo> shared_info,
481cb0ef41Sopenharmony_ci                                Isolate* isolate, ReportStatisticsMode mode);
491cb0ef41Sopenharmony_ci
501cb0ef41Sopenharmony_ci}  // namespace parsing
511cb0ef41Sopenharmony_ci}  // namespace internal
521cb0ef41Sopenharmony_ci}  // namespace v8
531cb0ef41Sopenharmony_ci
541cb0ef41Sopenharmony_ci#endif  // V8_PARSING_PARSING_H_
55