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

Side by Side Diff: src/ast.h

Issue 6691058: Restart AST node numbering when we enter a function. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add remaining platforms to change. Created 9 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 class AstNode: public ZoneObject { 127 class AstNode: public ZoneObject {
128 public: 128 public:
129 #define DECLARE_TYPE_ENUM(type) k##type, 129 #define DECLARE_TYPE_ENUM(type) k##type,
130 enum Type { 130 enum Type {
131 AST_NODE_LIST(DECLARE_TYPE_ENUM) 131 AST_NODE_LIST(DECLARE_TYPE_ENUM)
132 kInvalid = -1 132 kInvalid = -1
133 }; 133 };
134 #undef DECLARE_TYPE_ENUM 134 #undef DECLARE_TYPE_ENUM
135 135
136 static const int kNoNumber = -1; 136 static const int kNoNumber = -1;
137 // The root of every AST, a FunctionLiteral node, has id kRootAstId when
Kevin Millikin (Chromium) 2011/04/07 13:42:51 This comment is unnecessary and I think it confuse
138 // used as the root of its AST.
139 // The same FunctionLiteral AstNode has a different, real, AST id where
140 // it appears in the AST of the outer function containing it.
141 static const int kRootAstId = 2; // Using 0 could make disguise errors.
137 142
138 AstNode() : id_(GetNextId()) { 143 AstNode() : id_(GetNextId()) {
139 Isolate* isolate = Isolate::Current(); 144 Isolate* isolate = Isolate::Current();
140 isolate->set_ast_node_count(isolate->ast_node_count() + 1); 145 isolate->set_ast_node_count(isolate->ast_node_count() + 1);
141 } 146 }
142 147
143 virtual ~AstNode() { } 148 virtual ~AstNode() { }
144 149
145 virtual void Accept(AstVisitor* v) = 0; 150 virtual void Accept(AstVisitor* v) = 0;
146 virtual Type node_type() const { return kInvalid; } 151 virtual Type node_type() const { return kInvalid; }
(...skipping 1577 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 FunctionLiteral(Handle<String> name, 1729 FunctionLiteral(Handle<String> name,
1725 Scope* scope, 1730 Scope* scope,
1726 ZoneList<Statement*>* body, 1731 ZoneList<Statement*>* body,
1727 int materialized_literal_count, 1732 int materialized_literal_count,
1728 int expected_property_count, 1733 int expected_property_count,
1729 bool has_only_simple_this_property_assignments, 1734 bool has_only_simple_this_property_assignments,
1730 Handle<FixedArray> this_property_assignments, 1735 Handle<FixedArray> this_property_assignments,
1731 int num_parameters, 1736 int num_parameters,
1732 int start_position, 1737 int start_position,
1733 int end_position, 1738 int end_position,
1734 bool is_expression, 1739 bool is_expression)
1735 bool contains_loops)
1736 : name_(name), 1740 : name_(name),
1737 scope_(scope), 1741 scope_(scope),
1738 body_(body), 1742 body_(body),
1739 materialized_literal_count_(materialized_literal_count), 1743 materialized_literal_count_(materialized_literal_count),
1740 expected_property_count_(expected_property_count), 1744 expected_property_count_(expected_property_count),
1741 has_only_simple_this_property_assignments_( 1745 has_only_simple_this_property_assignments_(
1742 has_only_simple_this_property_assignments), 1746 has_only_simple_this_property_assignments),
1743 this_property_assignments_(this_property_assignments), 1747 this_property_assignments_(this_property_assignments),
1744 num_parameters_(num_parameters), 1748 num_parameters_(num_parameters),
1745 start_position_(start_position), 1749 start_position_(start_position),
1746 end_position_(end_position), 1750 end_position_(end_position),
1747 is_expression_(is_expression), 1751 is_expression_(is_expression),
1748 contains_loops_(contains_loops),
1749 function_token_position_(RelocInfo::kNoPosition), 1752 function_token_position_(RelocInfo::kNoPosition),
1750 inferred_name_(HEAP->empty_string()), 1753 inferred_name_(HEAP->empty_string()),
1751 pretenure_(false) { } 1754 pretenure_(false) { }
1752 1755
1753 DECLARE_NODE_TYPE(FunctionLiteral) 1756 DECLARE_NODE_TYPE(FunctionLiteral)
1754 1757
1755 Handle<String> name() const { return name_; } 1758 Handle<String> name() const { return name_; }
1756 Scope* scope() const { return scope_; } 1759 Scope* scope() const { return scope_; }
1757 ZoneList<Statement*>* body() const { return body_; } 1760 ZoneList<Statement*>* body() const { return body_; }
1758 void set_function_token_position(int pos) { function_token_position_ = pos; } 1761 void set_function_token_position(int pos) { function_token_position_ = pos; }
1759 int function_token_position() const { return function_token_position_; } 1762 int function_token_position() const { return function_token_position_; }
1760 int start_position() const { return start_position_; } 1763 int start_position() const { return start_position_; }
1761 int end_position() const { return end_position_; } 1764 int end_position() const { return end_position_; }
1762 bool is_expression() const { return is_expression_; } 1765 bool is_expression() const { return is_expression_; }
1763 bool contains_loops() const { return contains_loops_; }
1764 bool strict_mode() const; 1766 bool strict_mode() const;
1765 1767
1766 int materialized_literal_count() { return materialized_literal_count_; } 1768 int materialized_literal_count() { return materialized_literal_count_; }
1767 int expected_property_count() { return expected_property_count_; } 1769 int expected_property_count() { return expected_property_count_; }
1768 bool has_only_simple_this_property_assignments() { 1770 bool has_only_simple_this_property_assignments() {
1769 return has_only_simple_this_property_assignments_; 1771 return has_only_simple_this_property_assignments_;
1770 } 1772 }
1771 Handle<FixedArray> this_property_assignments() { 1773 Handle<FixedArray> this_property_assignments() {
1772 return this_property_assignments_; 1774 return this_property_assignments_;
1773 } 1775 }
(...skipping 19 matching lines...) Expand all
1793 Scope* scope_; 1795 Scope* scope_;
1794 ZoneList<Statement*>* body_; 1796 ZoneList<Statement*>* body_;
1795 int materialized_literal_count_; 1797 int materialized_literal_count_;
1796 int expected_property_count_; 1798 int expected_property_count_;
1797 bool has_only_simple_this_property_assignments_; 1799 bool has_only_simple_this_property_assignments_;
1798 Handle<FixedArray> this_property_assignments_; 1800 Handle<FixedArray> this_property_assignments_;
1799 int num_parameters_; 1801 int num_parameters_;
1800 int start_position_; 1802 int start_position_;
1801 int end_position_; 1803 int end_position_;
1802 bool is_expression_; 1804 bool is_expression_;
1803 bool contains_loops_;
1804 bool strict_mode_; 1805 bool strict_mode_;
1805 int function_token_position_; 1806 int function_token_position_;
1806 Handle<String> inferred_name_; 1807 Handle<String> inferred_name_;
1807 bool pretenure_; 1808 bool pretenure_;
1808 }; 1809 };
1809 1810
1810 1811
1811 class SharedFunctionInfoLiteral: public Expression { 1812 class SharedFunctionInfoLiteral: public Expression {
1812 public: 1813 public:
1813 explicit SharedFunctionInfoLiteral( 1814 explicit SharedFunctionInfoLiteral(
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
2225 2226
2226 private: 2227 private:
2227 Isolate* isolate_; 2228 Isolate* isolate_;
2228 bool stack_overflow_; 2229 bool stack_overflow_;
2229 }; 2230 };
2230 2231
2231 2232
2232 } } // namespace v8::internal 2233 } } // namespace v8::internal
2233 2234
2234 #endif // V8_AST_H_ 2235 #endif // V8_AST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698