Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: src/ast.h

Issue 477263002: ES6: Add support for method shorthand in object literals (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/arm64/lithium-codegen-arm64.cc ('k') | src/code-stubs.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index 8e9ff2d2249dd10b1615283cda0cea23d7bf10aa..d75c93dd6b6ceebf0e0ef805be51d50ec76bee2e 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -2325,12 +2325,6 @@ class FunctionLiteral V8_FINAL : public Expression {
kNotParenthesized
};
- enum KindFlag {
- kNormalFunction,
- kArrowFunction,
- kGeneratorFunction
- };
-
enum ArityRestriction {
NORMAL_ARITY,
GETTER_ARITY,
@@ -2422,6 +2416,14 @@ class FunctionLiteral V8_FINAL : public Expression {
bool is_generator() { return IsGenerator::decode(bitfield_); }
bool is_arrow() { return IsArrow::decode(bitfield_); }
+ bool is_concise_method() { return IsConciseMethod::decode(bitfield_); }
+ FunctionKind kind() {
+ // TODO(arv): Update to handle concise generator methods.
+ if (is_arrow()) return FunctionKind::kArrowFunction;
arv (Not doing code reviews) 2014/08/22 23:16:03 These are currently stored as a bitfield_. I could
+ if (is_generator()) return FunctionKind::kGeneratorFunction;
+ if (is_concise_method()) return FunctionKind::kConciseMethod;
+ return FunctionKind::kNormalFunction;
+ }
int ast_node_count() { return ast_properties_.node_count(); }
AstProperties::Flags* flags() { return ast_properties_.flags(); }
@@ -2445,7 +2447,7 @@ class FunctionLiteral V8_FINAL : public Expression {
int parameter_count, FunctionType function_type,
ParameterFlag has_duplicate_parameters,
IsFunctionFlag is_function,
- IsParenthesizedFlag is_parenthesized, KindFlag kind,
+ IsParenthesizedFlag is_parenthesized, FunctionKind kind,
int position, IdGen* id_gen)
: Expression(zone, position, id_gen),
raw_name_(name),
@@ -2465,7 +2467,10 @@ class FunctionLiteral V8_FINAL : public Expression {
IsFunction::encode(is_function) |
IsParenthesized::encode(is_parenthesized) |
IsGenerator::encode(kind == kGeneratorFunction) |
- IsArrow::encode(kind == kArrowFunction);
+ IsArrow::encode(kind == kArrowFunction) |
+ IsConciseMethod::encode(kind == kConciseMethod);
+ DCHECK(!(is_arrow() && is_concise_method()));
+ DCHECK(!(is_arrow() && is_generator()));
}
private:
@@ -2494,6 +2499,7 @@ class FunctionLiteral V8_FINAL : public Expression {
class IsParenthesized: public BitField<IsParenthesizedFlag, 5, 1> {};
class IsGenerator : public BitField<bool, 6, 1> {};
class IsArrow : public BitField<bool, 7, 1> {};
+ class IsConciseMethod : public BitField<bool, 8, 1> {};
};
@@ -3439,8 +3445,8 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED {
FunctionLiteral::ParameterFlag has_duplicate_parameters,
FunctionLiteral::FunctionType function_type,
FunctionLiteral::IsFunctionFlag is_function,
- FunctionLiteral::IsParenthesizedFlag is_parenthesized,
- FunctionLiteral::KindFlag kind, int position) {
+ FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionKind kind,
+ int position) {
FunctionLiteral* lit = new (zone_) FunctionLiteral(
zone_, name, ast_value_factory, scope, body, materialized_literal_count,
expected_property_count, handler_count, parameter_count, function_type,
« no previous file with comments | « src/arm64/lithium-codegen-arm64.cc ('k') | src/code-stubs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698