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

Side by Side Diff: src/ast.h

Issue 160073006: Implement handling of arrow functions in the parser (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased after latest changes in runtime.{h,cc} Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | src/parser.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2305 enum IsParenthesizedFlag { 2305 enum IsParenthesizedFlag {
2306 kIsParenthesized, 2306 kIsParenthesized,
2307 kNotParenthesized 2307 kNotParenthesized
2308 }; 2308 };
2309 2309
2310 enum IsGeneratorFlag { 2310 enum IsGeneratorFlag {
2311 kIsGenerator, 2311 kIsGenerator,
2312 kNotGenerator 2312 kNotGenerator
2313 }; 2313 };
2314 2314
2315 enum IsArrowFlag {
2316 kIsArrow,
2317 kNotArrow
2318 };
2319
2315 DECLARE_NODE_TYPE(FunctionLiteral) 2320 DECLARE_NODE_TYPE(FunctionLiteral)
2316 2321
2317 Handle<String> name() const { return name_; } 2322 Handle<String> name() const { return name_; }
2318 Scope* scope() const { return scope_; } 2323 Scope* scope() const { return scope_; }
2319 ZoneList<Statement*>* body() const { return body_; } 2324 ZoneList<Statement*>* body() const { return body_; }
2320 void set_function_token_position(int pos) { function_token_position_ = pos; } 2325 void set_function_token_position(int pos) { function_token_position_ = pos; }
2321 int function_token_position() const { return function_token_position_; } 2326 int function_token_position() const { return function_token_position_; }
2322 int start_position() const; 2327 int start_position() const;
2323 int end_position() const; 2328 int end_position() const;
2324 int SourceSize() const { return end_position() - start_position(); } 2329 int SourceSize() const { return end_position() - start_position(); }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2367 return IsParenthesized::decode(bitfield_) == kIsParenthesized; 2372 return IsParenthesized::decode(bitfield_) == kIsParenthesized;
2368 } 2373 }
2369 void set_parenthesized() { 2374 void set_parenthesized() {
2370 bitfield_ = IsParenthesized::update(bitfield_, kIsParenthesized); 2375 bitfield_ = IsParenthesized::update(bitfield_, kIsParenthesized);
2371 } 2376 }
2372 2377
2373 bool is_generator() { 2378 bool is_generator() {
2374 return IsGenerator::decode(bitfield_) == kIsGenerator; 2379 return IsGenerator::decode(bitfield_) == kIsGenerator;
2375 } 2380 }
2376 2381
2382 bool is_arrow() {
2383 return IsArrow::decode(bitfield_) == kIsArrow;
2384 }
2385
2377 int ast_node_count() { return ast_properties_.node_count(); } 2386 int ast_node_count() { return ast_properties_.node_count(); }
2378 AstProperties::Flags* flags() { return ast_properties_.flags(); } 2387 AstProperties::Flags* flags() { return ast_properties_.flags(); }
2379 void set_ast_properties(AstProperties* ast_properties) { 2388 void set_ast_properties(AstProperties* ast_properties) {
2380 ast_properties_ = *ast_properties; 2389 ast_properties_ = *ast_properties;
2381 } 2390 }
2382 void set_slot_processor(DeferredFeedbackSlotProcessor* slot_processor) { 2391 void set_slot_processor(DeferredFeedbackSlotProcessor* slot_processor) {
2383 slot_processor_ = *slot_processor; 2392 slot_processor_ = *slot_processor;
2384 } 2393 }
2385 void ProcessFeedbackSlots(Isolate* isolate) { 2394 void ProcessFeedbackSlots(Isolate* isolate) {
2386 slot_processor_.ProcessFeedbackSlots(isolate); 2395 slot_processor_.ProcessFeedbackSlots(isolate);
(...skipping 14 matching lines...) Expand all
2401 ZoneList<Statement*>* body, 2410 ZoneList<Statement*>* body,
2402 int materialized_literal_count, 2411 int materialized_literal_count,
2403 int expected_property_count, 2412 int expected_property_count,
2404 int handler_count, 2413 int handler_count,
2405 int parameter_count, 2414 int parameter_count,
2406 FunctionType function_type, 2415 FunctionType function_type,
2407 ParameterFlag has_duplicate_parameters, 2416 ParameterFlag has_duplicate_parameters,
2408 IsFunctionFlag is_function, 2417 IsFunctionFlag is_function,
2409 IsParenthesizedFlag is_parenthesized, 2418 IsParenthesizedFlag is_parenthesized,
2410 IsGeneratorFlag is_generator, 2419 IsGeneratorFlag is_generator,
2420 IsArrowFlag is_arrow,
2411 int position) 2421 int position)
2412 : Expression(zone, position), 2422 : Expression(zone, position),
2413 name_(name), 2423 name_(name),
2414 scope_(scope), 2424 scope_(scope),
2415 body_(body), 2425 body_(body),
2416 inferred_name_(zone->isolate()->factory()->empty_string()), 2426 inferred_name_(zone->isolate()->factory()->empty_string()),
2417 dont_optimize_reason_(kNoReason), 2427 dont_optimize_reason_(kNoReason),
2418 materialized_literal_count_(materialized_literal_count), 2428 materialized_literal_count_(materialized_literal_count),
2419 expected_property_count_(expected_property_count), 2429 expected_property_count_(expected_property_count),
2420 handler_count_(handler_count), 2430 handler_count_(handler_count),
2421 parameter_count_(parameter_count), 2431 parameter_count_(parameter_count),
2422 function_token_position_(RelocInfo::kNoPosition) { 2432 function_token_position_(RelocInfo::kNoPosition) {
2423 bitfield_ = 2433 bitfield_ =
2424 IsExpression::encode(function_type != DECLARATION) | 2434 IsExpression::encode(function_type != DECLARATION) |
2425 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) | 2435 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) |
2426 Pretenure::encode(false) | 2436 Pretenure::encode(false) |
2427 HasDuplicateParameters::encode(has_duplicate_parameters) | 2437 HasDuplicateParameters::encode(has_duplicate_parameters) |
2428 IsFunction::encode(is_function) | 2438 IsFunction::encode(is_function) |
2429 IsParenthesized::encode(is_parenthesized) | 2439 IsParenthesized::encode(is_parenthesized) |
2430 IsGenerator::encode(is_generator); 2440 IsGenerator::encode(is_generator) |
2441 IsArrow::encode(is_arrow);
2431 } 2442 }
2432 2443
2433 private: 2444 private:
2434 Handle<String> name_; 2445 Handle<String> name_;
2435 Handle<SharedFunctionInfo> shared_info_; 2446 Handle<SharedFunctionInfo> shared_info_;
2436 Scope* scope_; 2447 Scope* scope_;
2437 ZoneList<Statement*>* body_; 2448 ZoneList<Statement*>* body_;
2438 Handle<String> inferred_name_; 2449 Handle<String> inferred_name_;
2439 AstProperties ast_properties_; 2450 AstProperties ast_properties_;
2440 DeferredFeedbackSlotProcessor slot_processor_; 2451 DeferredFeedbackSlotProcessor slot_processor_;
2441 BailoutReason dont_optimize_reason_; 2452 BailoutReason dont_optimize_reason_;
2442 2453
2443 int materialized_literal_count_; 2454 int materialized_literal_count_;
2444 int expected_property_count_; 2455 int expected_property_count_;
2445 int handler_count_; 2456 int handler_count_;
2446 int parameter_count_; 2457 int parameter_count_;
2447 int function_token_position_; 2458 int function_token_position_;
2448 2459
2449 unsigned bitfield_; 2460 unsigned bitfield_;
2450 class IsExpression: public BitField<bool, 0, 1> {}; 2461 class IsExpression: public BitField<bool, 0, 1> {};
2451 class IsAnonymous: public BitField<bool, 1, 1> {}; 2462 class IsAnonymous: public BitField<bool, 1, 1> {};
2452 class Pretenure: public BitField<bool, 2, 1> {}; 2463 class Pretenure: public BitField<bool, 2, 1> {};
2453 class HasDuplicateParameters: public BitField<ParameterFlag, 3, 1> {}; 2464 class HasDuplicateParameters: public BitField<ParameterFlag, 3, 1> {};
2454 class IsFunction: public BitField<IsFunctionFlag, 4, 1> {}; 2465 class IsFunction: public BitField<IsFunctionFlag, 4, 1> {};
2455 class IsParenthesized: public BitField<IsParenthesizedFlag, 5, 1> {}; 2466 class IsParenthesized: public BitField<IsParenthesizedFlag, 5, 1> {};
2456 class IsGenerator: public BitField<IsGeneratorFlag, 6, 1> {}; 2467 class IsGenerator: public BitField<IsGeneratorFlag, 6, 1> {};
2468 class IsArrow: public BitField<IsArrowFlag, 7, 1> {};
2457 }; 2469 };
2458 2470
2459 2471
2460 class NativeFunctionLiteral V8_FINAL : public Expression { 2472 class NativeFunctionLiteral V8_FINAL : public Expression {
2461 public: 2473 public:
2462 DECLARE_NODE_TYPE(NativeFunctionLiteral) 2474 DECLARE_NODE_TYPE(NativeFunctionLiteral)
2463 2475
2464 Handle<String> name() const { return name_; } 2476 Handle<String> name() const { return name_; }
2465 v8::Extension* extension() const { return extension_; } 2477 v8::Extension* extension() const { return extension_; }
2466 2478
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
3329 ZoneList<Statement*>* body, 3341 ZoneList<Statement*>* body,
3330 int materialized_literal_count, 3342 int materialized_literal_count,
3331 int expected_property_count, 3343 int expected_property_count,
3332 int handler_count, 3344 int handler_count,
3333 int parameter_count, 3345 int parameter_count,
3334 FunctionLiteral::ParameterFlag has_duplicate_parameters, 3346 FunctionLiteral::ParameterFlag has_duplicate_parameters,
3335 FunctionLiteral::FunctionType function_type, 3347 FunctionLiteral::FunctionType function_type,
3336 FunctionLiteral::IsFunctionFlag is_function, 3348 FunctionLiteral::IsFunctionFlag is_function,
3337 FunctionLiteral::IsParenthesizedFlag is_parenthesized, 3349 FunctionLiteral::IsParenthesizedFlag is_parenthesized,
3338 FunctionLiteral::IsGeneratorFlag is_generator, 3350 FunctionLiteral::IsGeneratorFlag is_generator,
3351 FunctionLiteral::IsArrowFlag is_arrow,
3339 int position) { 3352 int position) {
3340 FunctionLiteral* lit = new(zone_) FunctionLiteral( 3353 FunctionLiteral* lit = new(zone_) FunctionLiteral(
3341 zone_, name, scope, body, 3354 zone_, name, scope, body,
3342 materialized_literal_count, expected_property_count, handler_count, 3355 materialized_literal_count, expected_property_count, handler_count,
3343 parameter_count, function_type, has_duplicate_parameters, is_function, 3356 parameter_count, function_type, has_duplicate_parameters, is_function,
3344 is_parenthesized, is_generator, position); 3357 is_parenthesized, is_generator, is_arrow, position);
3345 // Top-level literal doesn't count for the AST's properties. 3358 // Top-level literal doesn't count for the AST's properties.
3346 if (is_function == FunctionLiteral::kIsFunction) { 3359 if (is_function == FunctionLiteral::kIsFunction) {
3347 visitor_.VisitFunctionLiteral(lit); 3360 visitor_.VisitFunctionLiteral(lit);
3348 } 3361 }
3349 return lit; 3362 return lit;
3350 } 3363 }
3351 3364
3352 NativeFunctionLiteral* NewNativeFunctionLiteral( 3365 NativeFunctionLiteral* NewNativeFunctionLiteral(
3353 Handle<String> name, v8::Extension* extension, int pos) { 3366 Handle<String> name, v8::Extension* extension, int pos) {
3354 NativeFunctionLiteral* lit = 3367 NativeFunctionLiteral* lit =
(...skipping 10 matching lines...) Expand all
3365 3378
3366 private: 3379 private:
3367 Zone* zone_; 3380 Zone* zone_;
3368 Visitor visitor_; 3381 Visitor visitor_;
3369 }; 3382 };
3370 3383
3371 3384
3372 } } // namespace v8::internal 3385 } } // namespace v8::internal
3373 3386
3374 #endif // V8_AST_H_ 3387 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | src/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698