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

Side by Side Diff: src/preparser.h

Issue 203353002: New compilation API, part 2. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . 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
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // typedef Factory; 76 // typedef Factory;
77 // }; 77 // };
78 // // ... 78 // // ...
79 // }; 79 // };
80 80
81 template <typename Traits> 81 template <typename Traits>
82 class ParserBase : public Traits { 82 class ParserBase : public Traits {
83 public: 83 public:
84 ParserBase(Scanner* scanner, uintptr_t stack_limit, 84 ParserBase(Scanner* scanner, uintptr_t stack_limit,
85 v8::Extension* extension, 85 v8::Extension* extension,
86 ParserRecorder* log,
86 typename Traits::Type::Zone* zone, 87 typename Traits::Type::Zone* zone,
87 typename Traits::Type::Parser this_object) 88 typename Traits::Type::Parser this_object)
88 : Traits(this_object), 89 : Traits(this_object),
89 parenthesized_function_(false), 90 parenthesized_function_(false),
90 scope_(NULL), 91 scope_(NULL),
91 function_state_(NULL), 92 function_state_(NULL),
92 extension_(extension), 93 extension_(extension),
93 fni_(NULL), 94 fni_(NULL),
95 log_(log),
94 scanner_(scanner), 96 scanner_(scanner),
95 stack_limit_(stack_limit), 97 stack_limit_(stack_limit),
96 stack_overflow_(false), 98 stack_overflow_(false),
97 allow_lazy_(false), 99 allow_lazy_(false),
98 allow_natives_syntax_(false), 100 allow_natives_syntax_(false),
99 allow_generators_(false), 101 allow_generators_(false),
100 allow_for_of_(false), 102 allow_for_of_(false),
101 zone_(zone) { } 103 zone_(zone) { }
102 104
103 // Getters that indicate whether certain syntactical constructs are 105 // Getters that indicate whether certain syntactical constructs are
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 // If true, the next (and immediately following) function literal is 453 // If true, the next (and immediately following) function literal is
452 // preceded by a parenthesis. 454 // preceded by a parenthesis.
453 // Heuristically that means that the function will be called immediately, 455 // Heuristically that means that the function will be called immediately,
454 // so never lazily compile it. 456 // so never lazily compile it.
455 bool parenthesized_function_; 457 bool parenthesized_function_;
456 458
457 typename Traits::Type::Scope* scope_; // Scope stack. 459 typename Traits::Type::Scope* scope_; // Scope stack.
458 FunctionState* function_state_; // Function state stack. 460 FunctionState* function_state_; // Function state stack.
459 v8::Extension* extension_; 461 v8::Extension* extension_;
460 FuncNameInferrer* fni_; 462 FuncNameInferrer* fni_;
463 ParserRecorder* log_;
461 464
462 private: 465 private:
463 Scanner* scanner_; 466 Scanner* scanner_;
464 uintptr_t stack_limit_; 467 uintptr_t stack_limit_;
465 bool stack_overflow_; 468 bool stack_overflow_;
466 469
467 bool allow_lazy_; 470 bool allow_lazy_;
468 bool allow_natives_syntax_; 471 bool allow_natives_syntax_;
469 bool allow_generators_; 472 bool allow_generators_;
470 bool allow_for_of_; 473 bool allow_for_of_;
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 class PreParser : public ParserBase<PreParserTraits> { 945 class PreParser : public ParserBase<PreParserTraits> {
943 public: 946 public:
944 typedef PreParserIdentifier Identifier; 947 typedef PreParserIdentifier Identifier;
945 typedef PreParserExpression Expression; 948 typedef PreParserExpression Expression;
946 949
947 enum PreParseResult { 950 enum PreParseResult {
948 kPreParseStackOverflow, 951 kPreParseStackOverflow,
949 kPreParseSuccess 952 kPreParseSuccess
950 }; 953 };
951 954
952 PreParser(Scanner* scanner, 955 PreParser(Scanner* scanner, ParserRecorder* log, uintptr_t stack_limit)
953 ParserRecorder* log, 956 : ParserBase<PreParserTraits>(scanner, stack_limit, NULL, log, NULL,
954 uintptr_t stack_limit) 957 this) {}
955 : ParserBase<PreParserTraits>(scanner, stack_limit, NULL, NULL, this),
956 log_(log) {}
957 958
958 // Pre-parse the program from the character stream; returns true on 959 // Pre-parse the program from the character stream; returns true on
959 // success (even if parsing failed, the pre-parse data successfully 960 // success (even if parsing failed, the pre-parse data successfully
960 // captured the syntax error), and false if a stack-overflow happened 961 // captured the syntax error), and false if a stack-overflow happened
961 // during parsing. 962 // during parsing.
962 PreParseResult PreParseProgram() { 963 PreParseResult PreParseProgram() {
963 PreParserScope scope(scope_, GLOBAL_SCOPE); 964 PreParserScope scope(scope_, GLOBAL_SCOPE);
964 FunctionState top_scope(&function_state_, &scope_, &scope, NULL); 965 FunctionState top_scope(&function_state_, &scope_, &scope, NULL);
965 bool ok = true; 966 bool ok = true;
966 int start_position = scanner()->peek_location().beg_pos; 967 int start_position = scanner()->peek_location().beg_pos;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 FunctionLiteral::FunctionType function_type, 1106 FunctionLiteral::FunctionType function_type,
1106 bool* ok); 1107 bool* ok);
1107 void ParseLazyFunctionLiteralBody(bool* ok); 1108 void ParseLazyFunctionLiteralBody(bool* ok);
1108 1109
1109 // Logs the currently parsed literal as a symbol in the preparser data. 1110 // Logs the currently parsed literal as a symbol in the preparser data.
1110 void LogSymbol(); 1111 void LogSymbol();
1111 // Log the currently parsed string literal. 1112 // Log the currently parsed string literal.
1112 Expression GetStringSymbol(); 1113 Expression GetStringSymbol();
1113 1114
1114 bool CheckInOrOf(bool accept_OF); 1115 bool CheckInOrOf(bool accept_OF);
1115
1116 ParserRecorder* log_;
1117 }; 1116 };
1118 1117
1119
1120 template<class Traits> 1118 template<class Traits>
1121 ParserBase<Traits>::FunctionState::FunctionState( 1119 ParserBase<Traits>::FunctionState::FunctionState(
1122 FunctionState** function_state_stack, 1120 FunctionState** function_state_stack,
1123 typename Traits::Type::Scope** scope_stack, 1121 typename Traits::Type::Scope** scope_stack,
1124 typename Traits::Type::Scope* scope, 1122 typename Traits::Type::Scope* scope,
1125 typename Traits::Type::Zone* extra_param) 1123 typename Traits::Type::Zone* extra_param)
1126 : next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize), 1124 : next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize),
1127 next_handler_index_(0), 1125 next_handler_index_(0),
1128 expected_property_count_(0), 1126 expected_property_count_(0),
1129 is_generator_(false), 1127 is_generator_(false),
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
1827 "accessor_get_set"); 1825 "accessor_get_set");
1828 } 1826 }
1829 *ok = false; 1827 *ok = false;
1830 } 1828 }
1831 } 1829 }
1832 1830
1833 1831
1834 } } // v8::internal 1832 } } // v8::internal
1835 1833
1836 #endif // V8_PREPARSER_H 1834 #endif // V8_PREPARSER_H
OLDNEW
« include/v8.h ('K') | « src/parser.cc ('k') | test/cctest/cctest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698