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

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: Implement handling of arrow functions in the parser Created 6 years, 9 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 2291 matching lines...) Expand 10 before | Expand all | Expand 10 after
2302 enum IsParenthesizedFlag { 2302 enum IsParenthesizedFlag {
2303 kIsParenthesized, 2303 kIsParenthesized,
2304 kNotParenthesized 2304 kNotParenthesized
2305 }; 2305 };
2306 2306
2307 enum IsGeneratorFlag { 2307 enum IsGeneratorFlag {
2308 kIsGenerator, 2308 kIsGenerator,
2309 kNotGenerator 2309 kNotGenerator
2310 }; 2310 };
2311 2311
2312 enum IsArrowFlag {
2313 kIsArrow,
2314 kNotArrow
2315 };
2316
2312 DECLARE_NODE_TYPE(FunctionLiteral) 2317 DECLARE_NODE_TYPE(FunctionLiteral)
2313 2318
2314 Handle<String> name() const { return name_; } 2319 Handle<String> name() const { return name_; }
2315 Scope* scope() const { return scope_; } 2320 Scope* scope() const { return scope_; }
2316 ZoneList<Statement*>* body() const { return body_; } 2321 ZoneList<Statement*>* body() const { return body_; }
2317 void set_function_token_position(int pos) { function_token_position_ = pos; } 2322 void set_function_token_position(int pos) { function_token_position_ = pos; }
2318 int function_token_position() const { return function_token_position_; } 2323 int function_token_position() const { return function_token_position_; }
2319 int start_position() const; 2324 int start_position() const;
2320 int end_position() const; 2325 int end_position() const;
2321 int SourceSize() const { return end_position() - start_position(); } 2326 int SourceSize() const { return end_position() - start_position(); }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2364 return IsParenthesized::decode(bitfield_) == kIsParenthesized; 2369 return IsParenthesized::decode(bitfield_) == kIsParenthesized;
2365 } 2370 }
2366 void set_parenthesized() { 2371 void set_parenthesized() {
2367 bitfield_ = IsParenthesized::update(bitfield_, kIsParenthesized); 2372 bitfield_ = IsParenthesized::update(bitfield_, kIsParenthesized);
2368 } 2373 }
2369 2374
2370 bool is_generator() { 2375 bool is_generator() {
2371 return IsGenerator::decode(bitfield_) == kIsGenerator; 2376 return IsGenerator::decode(bitfield_) == kIsGenerator;
2372 } 2377 }
2373 2378
2379 bool is_arrow() {
2380 return IsArrow::decode(bitfield_) == kIsArrow;
2381 }
2382
2374 int ast_node_count() { return ast_properties_.node_count(); } 2383 int ast_node_count() { return ast_properties_.node_count(); }
2375 AstProperties::Flags* flags() { return ast_properties_.flags(); } 2384 AstProperties::Flags* flags() { return ast_properties_.flags(); }
2376 void set_ast_properties(AstProperties* ast_properties) { 2385 void set_ast_properties(AstProperties* ast_properties) {
2377 ast_properties_ = *ast_properties; 2386 ast_properties_ = *ast_properties;
2378 } 2387 }
2379 void set_slot_processor(DeferredFeedbackSlotProcessor* slot_processor) { 2388 void set_slot_processor(DeferredFeedbackSlotProcessor* slot_processor) {
2380 slot_processor_ = *slot_processor; 2389 slot_processor_ = *slot_processor;
2381 } 2390 }
2382 void ProcessFeedbackSlots(Isolate* isolate) { 2391 void ProcessFeedbackSlots(Isolate* isolate) {
2383 slot_processor_.ProcessFeedbackSlots(isolate); 2392 slot_processor_.ProcessFeedbackSlots(isolate);
(...skipping 14 matching lines...) Expand all
2398 ZoneList<Statement*>* body, 2407 ZoneList<Statement*>* body,
2399 int materialized_literal_count, 2408 int materialized_literal_count,
2400 int expected_property_count, 2409 int expected_property_count,
2401 int handler_count, 2410 int handler_count,
2402 int parameter_count, 2411 int parameter_count,
2403 FunctionType function_type, 2412 FunctionType function_type,
2404 ParameterFlag has_duplicate_parameters, 2413 ParameterFlag has_duplicate_parameters,
2405 IsFunctionFlag is_function, 2414 IsFunctionFlag is_function,
2406 IsParenthesizedFlag is_parenthesized, 2415 IsParenthesizedFlag is_parenthesized,
2407 IsGeneratorFlag is_generator, 2416 IsGeneratorFlag is_generator,
2417 IsArrowFlag is_arrow,
2408 int position) 2418 int position)
2409 : Expression(zone, position), 2419 : Expression(zone, position),
2410 name_(name), 2420 name_(name),
2411 scope_(scope), 2421 scope_(scope),
2412 body_(body), 2422 body_(body),
2413 inferred_name_(zone->isolate()->factory()->empty_string()), 2423 inferred_name_(zone->isolate()->factory()->empty_string()),
2414 dont_optimize_reason_(kNoReason), 2424 dont_optimize_reason_(kNoReason),
2415 materialized_literal_count_(materialized_literal_count), 2425 materialized_literal_count_(materialized_literal_count),
2416 expected_property_count_(expected_property_count), 2426 expected_property_count_(expected_property_count),
2417 handler_count_(handler_count), 2427 handler_count_(handler_count),
2418 parameter_count_(parameter_count), 2428 parameter_count_(parameter_count),
2419 function_token_position_(RelocInfo::kNoPosition) { 2429 function_token_position_(RelocInfo::kNoPosition) {
2420 bitfield_ = 2430 bitfield_ =
2421 IsExpression::encode(function_type != DECLARATION) | 2431 IsExpression::encode(function_type != DECLARATION) |
2422 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) | 2432 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) |
2423 Pretenure::encode(false) | 2433 Pretenure::encode(false) |
2424 HasDuplicateParameters::encode(has_duplicate_parameters) | 2434 HasDuplicateParameters::encode(has_duplicate_parameters) |
2425 IsFunction::encode(is_function) | 2435 IsFunction::encode(is_function) |
2426 IsParenthesized::encode(is_parenthesized) | 2436 IsParenthesized::encode(is_parenthesized) |
2427 IsGenerator::encode(is_generator); 2437 IsGenerator::encode(is_generator) |
2438 IsArrow::encode(is_arrow);
2428 } 2439 }
2429 2440
2430 private: 2441 private:
2431 Handle<String> name_; 2442 Handle<String> name_;
2432 Handle<SharedFunctionInfo> shared_info_; 2443 Handle<SharedFunctionInfo> shared_info_;
2433 Scope* scope_; 2444 Scope* scope_;
2434 ZoneList<Statement*>* body_; 2445 ZoneList<Statement*>* body_;
2435 Handle<String> inferred_name_; 2446 Handle<String> inferred_name_;
2436 AstProperties ast_properties_; 2447 AstProperties ast_properties_;
2437 DeferredFeedbackSlotProcessor slot_processor_; 2448 DeferredFeedbackSlotProcessor slot_processor_;
2438 BailoutReason dont_optimize_reason_; 2449 BailoutReason dont_optimize_reason_;
2439 2450
2440 int materialized_literal_count_; 2451 int materialized_literal_count_;
2441 int expected_property_count_; 2452 int expected_property_count_;
2442 int handler_count_; 2453 int handler_count_;
2443 int parameter_count_; 2454 int parameter_count_;
2444 int function_token_position_; 2455 int function_token_position_;
2445 2456
2446 unsigned bitfield_; 2457 unsigned bitfield_;
2447 class IsExpression: public BitField<bool, 0, 1> {}; 2458 class IsExpression: public BitField<bool, 0, 1> {};
2448 class IsAnonymous: public BitField<bool, 1, 1> {}; 2459 class IsAnonymous: public BitField<bool, 1, 1> {};
2449 class Pretenure: public BitField<bool, 2, 1> {}; 2460 class Pretenure: public BitField<bool, 2, 1> {};
2450 class HasDuplicateParameters: public BitField<ParameterFlag, 3, 1> {}; 2461 class HasDuplicateParameters: public BitField<ParameterFlag, 3, 1> {};
2451 class IsFunction: public BitField<IsFunctionFlag, 4, 1> {}; 2462 class IsFunction: public BitField<IsFunctionFlag, 4, 1> {};
2452 class IsParenthesized: public BitField<IsParenthesizedFlag, 5, 1> {}; 2463 class IsParenthesized: public BitField<IsParenthesizedFlag, 5, 1> {};
2453 class IsGenerator: public BitField<IsGeneratorFlag, 6, 1> {}; 2464 class IsGenerator: public BitField<IsGeneratorFlag, 6, 1> {};
2465 class IsArrow: public BitField<IsArrowFlag, 7, 1> {};
2454 }; 2466 };
2455 2467
2456 2468
2457 class NativeFunctionLiteral V8_FINAL : public Expression { 2469 class NativeFunctionLiteral V8_FINAL : public Expression {
2458 public: 2470 public:
2459 DECLARE_NODE_TYPE(NativeFunctionLiteral) 2471 DECLARE_NODE_TYPE(NativeFunctionLiteral)
2460 2472
2461 Handle<String> name() const { return name_; } 2473 Handle<String> name() const { return name_; }
2462 v8::Extension* extension() const { return extension_; } 2474 v8::Extension* extension() const { return extension_; }
2463 2475
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
3326 ZoneList<Statement*>* body, 3338 ZoneList<Statement*>* body,
3327 int materialized_literal_count, 3339 int materialized_literal_count,
3328 int expected_property_count, 3340 int expected_property_count,
3329 int handler_count, 3341 int handler_count,
3330 int parameter_count, 3342 int parameter_count,
3331 FunctionLiteral::ParameterFlag has_duplicate_parameters, 3343 FunctionLiteral::ParameterFlag has_duplicate_parameters,
3332 FunctionLiteral::FunctionType function_type, 3344 FunctionLiteral::FunctionType function_type,
3333 FunctionLiteral::IsFunctionFlag is_function, 3345 FunctionLiteral::IsFunctionFlag is_function,
3334 FunctionLiteral::IsParenthesizedFlag is_parenthesized, 3346 FunctionLiteral::IsParenthesizedFlag is_parenthesized,
3335 FunctionLiteral::IsGeneratorFlag is_generator, 3347 FunctionLiteral::IsGeneratorFlag is_generator,
3348 FunctionLiteral::IsArrowFlag is_arrow,
3336 int position) { 3349 int position) {
3337 FunctionLiteral* lit = new(zone_) FunctionLiteral( 3350 FunctionLiteral* lit = new(zone_) FunctionLiteral(
3338 zone_, name, scope, body, 3351 zone_, name, scope, body,
3339 materialized_literal_count, expected_property_count, handler_count, 3352 materialized_literal_count, expected_property_count, handler_count,
3340 parameter_count, function_type, has_duplicate_parameters, is_function, 3353 parameter_count, function_type, has_duplicate_parameters, is_function,
3341 is_parenthesized, is_generator, position); 3354 is_parenthesized, is_generator, is_arrow, position);
3342 // Top-level literal doesn't count for the AST's properties. 3355 // Top-level literal doesn't count for the AST's properties.
3343 if (is_function == FunctionLiteral::kIsFunction) { 3356 if (is_function == FunctionLiteral::kIsFunction) {
3344 visitor_.VisitFunctionLiteral(lit); 3357 visitor_.VisitFunctionLiteral(lit);
3345 } 3358 }
3346 return lit; 3359 return lit;
3347 } 3360 }
3348 3361
3349 NativeFunctionLiteral* NewNativeFunctionLiteral( 3362 NativeFunctionLiteral* NewNativeFunctionLiteral(
3350 Handle<String> name, v8::Extension* extension, int pos) { 3363 Handle<String> name, v8::Extension* extension, int pos) {
3351 NativeFunctionLiteral* lit = 3364 NativeFunctionLiteral* lit =
(...skipping 10 matching lines...) Expand all
3362 3375
3363 private: 3376 private:
3364 Zone* zone_; 3377 Zone* zone_;
3365 Visitor visitor_; 3378 Visitor visitor_;
3366 }; 3379 };
3367 3380
3368 3381
3369 } } // namespace v8::internal 3382 } } // namespace v8::internal
3370 3383
3371 #endif // V8_AST_H_ 3384 #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