v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
rewriter.h
Go to the documentation of this file.
1
// Copyright 2011 the V8 project authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#ifndef V8_PARSING_REWRITER_H_
6
#define V8_PARSING_REWRITER_H_
7
8
#include <optional>
9
10
#include "
src/base/macros.h
"
11
#include "
src/zone/zone-type-traits.h
"
12
13
namespace
v8::internal
{
14
15
class
AstValueFactory;
16
class
Isolate;
17
class
ParseInfo;
18
class
Parser;
19
class
DeclarationScope;
20
class
Scope;
21
class
Statement;
22
class
VariableProxy;
23
24
class
Rewriter
{
25
public
:
26
// Rewrite top-level code (ECMA 262 "programs") so as to conservatively
27
// include an assignment of the value of the last statement in the code to
28
// a compiler-generated temporary variable wherever needed.
29
//
30
// Assumes code has been parsed and scopes have been analyzed. Mutates the
31
// AST, so the AST should not continue to be used in the case of failure.
32
V8_EXPORT_PRIVATE
static
bool
Rewrite
(
ParseInfo
* info,
33
bool
* out_has_stack_overflow);
34
35
// Helper that does the actual re-writing. Extracted so REPL scripts can
36
// rewrite the body but then use the ".result" VariableProxy to resolve
37
// the async promise that is the result of running a REPL script.
38
// Returns std::nullopt in case something went wrong.
39
static
std::optional<VariableProxy*>
RewriteBody
(
40
ParseInfo
* info,
Scope
* scope,
ZonePtrList<Statement>
* body,
41
bool
* out_has_stack_overflow);
42
};
43
44
}
// namespace v8::internal
45
46
#endif
// V8_PARSING_REWRITER_H_
v8::internal::ParseInfo
Definition
parse-info.h:227
v8::internal::Rewriter
Definition
rewriter.h:24
v8::internal::Rewriter::Rewrite
static V8_EXPORT_PRIVATE bool Rewrite(ParseInfo *info, bool *out_has_stack_overflow)
Definition
rewriter.cc:386
v8::internal::Rewriter::RewriteBody
static std::optional< VariableProxy * > RewriteBody(ParseInfo *info, Scope *scope, ZonePtrList< Statement > *body, bool *out_has_stack_overflow)
Definition
rewriter.cc:406
v8::internal::Scope
Definition
scopes.h:90
v8::internal::ZoneList
Definition
zone-type-traits.h:18
v8::internal
Definition
api-arguments-inl.h:20
macros.h
V8_EXPORT_PRIVATE
#define V8_EXPORT_PRIVATE
Definition
macros.h:460
zone-type-traits.h
src
parsing
rewriter.h
Generated on Sun Apr 6 2025 21:08:56 for v8 by
1.12.0