diff options
author | Myles Borins <mylesborins@google.com> | 2019-09-24 11:56:38 -0400 |
---|---|---|
committer | Myles Borins <myles.borins@gmail.com> | 2019-10-07 03:19:23 -0400 |
commit | f7f6c928c1c9c136b7926f892b8a2fda11d8b4b2 (patch) | |
tree | f5edbccb3ffda2573d70a6e291e7157f290e0ae0 /deps/v8/src/torque/ast.h | |
parent | ffd22e81983056d09c064c59343a0e488236272d (diff) | |
download | android-node-v8-f7f6c928c1c9c136b7926f892b8a2fda11d8b4b2.tar.gz android-node-v8-f7f6c928c1c9c136b7926f892b8a2fda11d8b4b2.tar.bz2 android-node-v8-f7f6c928c1c9c136b7926f892b8a2fda11d8b4b2.zip |
deps: update V8 to 7.8.279.9
PR-URL: https://github.com/nodejs/node/pull/29694
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Diffstat (limited to 'deps/v8/src/torque/ast.h')
-rw-r--r-- | deps/v8/src/torque/ast.h | 203 |
1 files changed, 93 insertions, 110 deletions
diff --git a/deps/v8/src/torque/ast.h b/deps/v8/src/torque/ast.h index 23de121065..5ce25cf13a 100644 --- a/deps/v8/src/torque/ast.h +++ b/deps/v8/src/torque/ast.h @@ -46,8 +46,7 @@ namespace torque { #define AST_TYPE_EXPRESSION_NODE_KIND_LIST(V) \ V(BasicTypeExpression) \ V(FunctionTypeExpression) \ - V(UnionTypeExpression) \ - V(ReferenceTypeExpression) + V(UnionTypeExpression) #define AST_STATEMENT_NODE_KIND_LIST(V) \ V(BlockStatement) \ @@ -72,20 +71,17 @@ namespace torque { #define AST_DECLARATION_NODE_KIND_LIST(V) \ AST_TYPE_DECLARATION_NODE_KIND_LIST(V) \ - V(StandardDeclaration) \ V(GenericDeclaration) \ V(SpecializationDeclaration) \ V(ExternConstDeclaration) \ V(NamespaceDeclaration) \ V(ConstDeclaration) \ - V(CppIncludeDeclaration) - -#define AST_CALLABLE_NODE_KIND_LIST(V) \ - V(TorqueMacroDeclaration) \ - V(TorqueBuiltinDeclaration) \ - V(ExternalMacroDeclaration) \ - V(ExternalBuiltinDeclaration) \ - V(ExternalRuntimeDeclaration) \ + V(CppIncludeDeclaration) \ + V(TorqueMacroDeclaration) \ + V(TorqueBuiltinDeclaration) \ + V(ExternalMacroDeclaration) \ + V(ExternalBuiltinDeclaration) \ + V(ExternalRuntimeDeclaration) \ V(IntrinsicDeclaration) #define AST_NODE_KIND_LIST(V) \ @@ -93,7 +89,6 @@ namespace torque { AST_TYPE_EXPRESSION_NODE_KIND_LIST(V) \ AST_STATEMENT_NODE_KIND_LIST(V) \ AST_DECLARATION_NODE_KIND_LIST(V) \ - AST_CALLABLE_NODE_KIND_LIST(V) \ V(Identifier) \ V(LabelBlock) @@ -118,16 +113,16 @@ struct AstNodeClassCheck { }; // Boilerplate for most derived classes. -#define DEFINE_AST_NODE_LEAF_BOILERPLATE(T) \ - static const Kind kKind = Kind::k##T; \ - static T* cast(AstNode* node) { \ - if (node->kind != kKind) return nullptr; \ - return static_cast<T*>(node); \ - } \ - static T* DynamicCast(AstNode* node) { \ - if (!node) return nullptr; \ - if (!AstNodeClassCheck::IsInstanceOf<T>(node)) return nullptr; \ - return static_cast<T*>(node); \ +#define DEFINE_AST_NODE_LEAF_BOILERPLATE(T) \ + static const Kind kKind = Kind::k##T; \ + static T* cast(AstNode* node) { \ + DCHECK_EQ(node->kind, kKind); \ + return static_cast<T*>(node); \ + } \ + static T* DynamicCast(AstNode* node) { \ + if (!node) return nullptr; \ + if (node->kind != kKind) return nullptr; \ + return static_cast<T*>(node); \ } // Boilerplate for classes with subclasses. @@ -221,6 +216,10 @@ struct Identifier : AstNode { std::string value; }; +inline std::ostream& operator<<(std::ostream& os, Identifier* id) { + return os << id->value; +} + struct IdentifierPtrValueEq { bool operator()(const Identifier* a, const Identifier* b) { return a->value < b->value; @@ -252,11 +251,11 @@ struct IdentifierExpression : LocationExpression { struct IntrinsicCallExpression : Expression { DEFINE_AST_NODE_LEAF_BOILERPLATE(IntrinsicCallExpression) - IntrinsicCallExpression(SourcePosition pos, std::string name, + IntrinsicCallExpression(SourcePosition pos, Identifier* name, std::vector<TypeExpression*> generic_arguments, std::vector<Expression*> arguments) : Expression(kKind, pos), - name(std::move(name)), + name(name), generic_arguments(std::move(generic_arguments)), arguments(std::move(arguments)) {} @@ -267,7 +266,7 @@ struct IntrinsicCallExpression : Expression { callback(this); } - std::string name; + Identifier* name; std::vector<TypeExpression*> generic_arguments; std::vector<Expression*> arguments; }; @@ -619,13 +618,6 @@ struct UnionTypeExpression : TypeExpression { TypeExpression* b; }; -struct ReferenceTypeExpression : TypeExpression { - DEFINE_AST_NODE_LEAF_BOILERPLATE(ReferenceTypeExpression) - ReferenceTypeExpression(SourcePosition pos, TypeExpression* referenced_type) - : TypeExpression(kKind, pos), referenced_type(referenced_type) {} - TypeExpression* referenced_type; -}; - struct ExpressionStatement : Statement { DEFINE_AST_NODE_LEAF_BOILERPLATE(ExpressionStatement) ExpressionStatement(SourcePosition pos, Expression* expression) @@ -849,10 +841,15 @@ struct ConditionalAnnotation { ConditionalAnnotationType type; }; +struct Annotation { + Identifier* name; + base::Optional<std::string> param; +}; + struct ClassFieldExpression { NameAndTypeExpression name_and_type; base::Optional<std::string> index; - base::Optional<ConditionalAnnotation> conditional; + std::vector<ConditionalAnnotation> conditions; bool weak; bool const_qualified; bool generate_verify; @@ -865,34 +862,33 @@ struct LabelAndTypes { using LabelAndTypesVector = std::vector<LabelAndTypes>; -struct CallableNodeSignature { +struct CallableDeclaration : Declaration { + CallableDeclaration(AstNode::Kind kind, SourcePosition pos, + bool transitioning, Identifier* name, + ParameterList parameters, TypeExpression* return_type, + LabelAndTypesVector labels) + : Declaration(kind, pos), + transitioning(transitioning), + name(name), + parameters(std::move(parameters)), + return_type(return_type), + labels(std::move(labels)) {} + DEFINE_AST_NODE_INNER_BOILERPLATE(CallableDeclaration) + bool transitioning; + Identifier* name; ParameterList parameters; TypeExpression* return_type; LabelAndTypesVector labels; }; -struct CallableNode : AstNode { - CallableNode(AstNode::Kind kind, SourcePosition pos, bool transitioning, - std::string name, ParameterList parameters, - TypeExpression* return_type, const LabelAndTypesVector& labels) - : AstNode(kind, pos), - transitioning(transitioning), - name(std::move(name)), - signature(new CallableNodeSignature{parameters, return_type, labels}) {} - DEFINE_AST_NODE_INNER_BOILERPLATE(CallableNode) - bool transitioning; - std::string name; - std::unique_ptr<CallableNodeSignature> signature; -}; - -struct MacroDeclaration : CallableNode { +struct MacroDeclaration : CallableDeclaration { DEFINE_AST_NODE_INNER_BOILERPLATE(MacroDeclaration) MacroDeclaration(AstNode::Kind kind, SourcePosition pos, bool transitioning, - std::string name, base::Optional<std::string> op, + Identifier* name, base::Optional<std::string> op, ParameterList parameters, TypeExpression* return_type, const LabelAndTypesVector& labels) - : CallableNode(kind, pos, transitioning, std::move(name), - std::move(parameters), return_type, labels), + : CallableDeclaration(kind, pos, transitioning, name, + std::move(parameters), return_type, labels), op(std::move(op)) { if (parameters.implicit_kind == ImplicitKind::kJSImplicit) { Error("Cannot use \"js-implicit\" with macros, use \"implicit\" instead.") @@ -906,23 +902,22 @@ struct ExternalMacroDeclaration : MacroDeclaration { DEFINE_AST_NODE_LEAF_BOILERPLATE(ExternalMacroDeclaration) ExternalMacroDeclaration(SourcePosition pos, bool transitioning, std::string external_assembler_name, - std::string name, base::Optional<std::string> op, + Identifier* name, base::Optional<std::string> op, ParameterList parameters, TypeExpression* return_type, const LabelAndTypesVector& labels) - : MacroDeclaration(kKind, pos, transitioning, std::move(name), - std::move(op), std::move(parameters), return_type, - labels), + : MacroDeclaration(kKind, pos, transitioning, name, std::move(op), + std::move(parameters), return_type, labels), external_assembler_name(std::move(external_assembler_name)) {} std::string external_assembler_name; }; -struct IntrinsicDeclaration : CallableNode { +struct IntrinsicDeclaration : CallableDeclaration { DEFINE_AST_NODE_LEAF_BOILERPLATE(IntrinsicDeclaration) - IntrinsicDeclaration(SourcePosition pos, std::string name, + IntrinsicDeclaration(SourcePosition pos, Identifier* name, ParameterList parameters, TypeExpression* return_type) - : CallableNode(kKind, pos, false, std::move(name), std::move(parameters), - return_type, {}) { + : CallableDeclaration(kKind, pos, false, name, std::move(parameters), + return_type, {}) { if (parameters.implicit_kind != ImplicitKind::kNoImplicit) { Error("Intinsics cannot have implicit parameters."); } @@ -932,24 +927,26 @@ struct IntrinsicDeclaration : CallableNode { struct TorqueMacroDeclaration : MacroDeclaration { DEFINE_AST_NODE_LEAF_BOILERPLATE(TorqueMacroDeclaration) TorqueMacroDeclaration(SourcePosition pos, bool transitioning, - std::string name, base::Optional<std::string> op, + Identifier* name, base::Optional<std::string> op, ParameterList parameters, TypeExpression* return_type, - const LabelAndTypesVector& labels, bool export_to_csa) - : MacroDeclaration(kKind, pos, transitioning, std::move(name), - std::move(op), std::move(parameters), return_type, - labels), - export_to_csa(export_to_csa) {} + const LabelAndTypesVector& labels, bool export_to_csa, + base::Optional<Statement*> body) + : MacroDeclaration(kKind, pos, transitioning, name, std::move(op), + std::move(parameters), return_type, labels), + export_to_csa(export_to_csa), + body(body) {} bool export_to_csa; + base::Optional<Statement*> body; }; -struct BuiltinDeclaration : CallableNode { +struct BuiltinDeclaration : CallableDeclaration { DEFINE_AST_NODE_INNER_BOILERPLATE(BuiltinDeclaration) BuiltinDeclaration(AstNode::Kind kind, SourcePosition pos, bool javascript_linkage, bool transitioning, - std::string name, ParameterList parameters, + Identifier* name, ParameterList parameters, TypeExpression* return_type) - : CallableNode(kind, pos, transitioning, std::move(name), - std::move(parameters), return_type, {}), + : CallableDeclaration(kind, pos, transitioning, name, + std::move(parameters), return_type, {}), javascript_linkage(javascript_linkage) { if (parameters.implicit_kind == ImplicitKind::kJSImplicit && !javascript_linkage) { @@ -971,32 +968,33 @@ struct BuiltinDeclaration : CallableNode { struct ExternalBuiltinDeclaration : BuiltinDeclaration { DEFINE_AST_NODE_LEAF_BOILERPLATE(ExternalBuiltinDeclaration) ExternalBuiltinDeclaration(SourcePosition pos, bool transitioning, - bool javascript_linkage, std::string name, + bool javascript_linkage, Identifier* name, ParameterList parameters, TypeExpression* return_type) - : BuiltinDeclaration(kKind, pos, javascript_linkage, transitioning, - std::move(name), std::move(parameters), - return_type) {} + : BuiltinDeclaration(kKind, pos, javascript_linkage, transitioning, name, + std::move(parameters), return_type) {} }; struct TorqueBuiltinDeclaration : BuiltinDeclaration { DEFINE_AST_NODE_LEAF_BOILERPLATE(TorqueBuiltinDeclaration) TorqueBuiltinDeclaration(SourcePosition pos, bool transitioning, - bool javascript_linkage, std::string name, + bool javascript_linkage, Identifier* name, ParameterList parameters, - TypeExpression* return_type) - : BuiltinDeclaration(kKind, pos, javascript_linkage, transitioning, - std::move(name), std::move(parameters), - return_type) {} + TypeExpression* return_type, + base::Optional<Statement*> body) + : BuiltinDeclaration(kKind, pos, javascript_linkage, transitioning, name, + std::move(parameters), return_type), + body(body) {} + base::Optional<Statement*> body; }; -struct ExternalRuntimeDeclaration : CallableNode { +struct ExternalRuntimeDeclaration : CallableDeclaration { DEFINE_AST_NODE_LEAF_BOILERPLATE(ExternalRuntimeDeclaration) ExternalRuntimeDeclaration(SourcePosition pos, bool transitioning, - std::string name, ParameterList parameters, + Identifier* name, ParameterList parameters, TypeExpression* return_type) - : CallableNode(kKind, pos, transitioning, name, parameters, return_type, - {}) {} + : CallableDeclaration(kKind, pos, transitioning, name, parameters, + return_type, {}) {} }; struct ConstDeclaration : Declaration { @@ -1012,47 +1010,32 @@ struct ConstDeclaration : Declaration { Expression* expression; }; -struct StandardDeclaration : Declaration { - DEFINE_AST_NODE_LEAF_BOILERPLATE(StandardDeclaration) - StandardDeclaration(SourcePosition pos, CallableNode* callable, - base::Optional<Statement*> body) - : Declaration(kKind, pos), callable(callable), body(body) {} - CallableNode* callable; - base::Optional<Statement*> body; -}; - struct GenericDeclaration : Declaration { DEFINE_AST_NODE_LEAF_BOILERPLATE(GenericDeclaration) - GenericDeclaration(SourcePosition pos, CallableNode* callable, + GenericDeclaration(SourcePosition pos, std::vector<Identifier*> generic_parameters, - base::Optional<Statement*> body = base::nullopt) + CallableDeclaration* declaration) : Declaration(kKind, pos), - callable(callable), generic_parameters(std::move(generic_parameters)), - body(body) {} - CallableNode* callable; + declaration(declaration) {} std::vector<Identifier*> generic_parameters; - base::Optional<Statement*> body; + CallableDeclaration* declaration; }; -struct SpecializationDeclaration : Declaration { +struct SpecializationDeclaration : CallableDeclaration { DEFINE_AST_NODE_LEAF_BOILERPLATE(SpecializationDeclaration) - SpecializationDeclaration(SourcePosition pos, Identifier* name, + SpecializationDeclaration(SourcePosition pos, bool transitioning, + Identifier* name, std::vector<TypeExpression*> generic_parameters, ParameterList parameters, TypeExpression* return_type, - LabelAndTypesVector labels, Statement* b) - : Declaration(kKind, pos), - name(name), - external(false), + LabelAndTypesVector labels, Statement* body) + : CallableDeclaration(kKind, pos, transitioning, name, + std::move(parameters), return_type, + std::move(labels)), generic_parameters(std::move(generic_parameters)), - signature(new CallableNodeSignature{std::move(parameters), return_type, - std::move(labels)}), - body(b) {} - Identifier* name; - bool external; + body(body) {} std::vector<TypeExpression*> generic_parameters; - std::unique_ptr<CallableNodeSignature> signature; Statement* body; }; |