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

Side by Side Diff: src/ast.cc

Issue 24076007: Unify handling of position info in AST, part 1 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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 | « src/ast.h ('k') | src/full-codegen.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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 VariableProxy* var_proxy = AsVariableProxy(); 75 VariableProxy* var_proxy = AsVariableProxy();
76 if (var_proxy == NULL) return false; 76 if (var_proxy == NULL) return false;
77 Variable* var = var_proxy->var(); 77 Variable* var = var_proxy->var();
78 // The global identifier "undefined" is immutable. Everything 78 // The global identifier "undefined" is immutable. Everything
79 // else could be reassigned. 79 // else could be reassigned.
80 return var != NULL && var->location() == Variable::UNALLOCATED && 80 return var != NULL && var->location() == Variable::UNALLOCATED &&
81 var_proxy->name()->Equals(isolate->heap()->undefined_string()); 81 var_proxy->name()->Equals(isolate->heap()->undefined_string());
82 } 82 }
83 83
84 84
85 VariableProxy::VariableProxy(Isolate* isolate, Variable* var) 85 VariableProxy::VariableProxy(Isolate* isolate, Variable* var, int position)
86 : Expression(isolate), 86 : Expression(isolate, position),
87 name_(var->name()), 87 name_(var->name()),
88 var_(NULL), // Will be set by the call to BindTo. 88 var_(NULL), // Will be set by the call to BindTo.
89 is_this_(var->is_this()), 89 is_this_(var->is_this()),
90 is_trivial_(false), 90 is_trivial_(false),
91 is_lvalue_(false), 91 is_lvalue_(false),
92 position_(RelocInfo::kNoPosition),
93 interface_(var->interface()) { 92 interface_(var->interface()) {
94 BindTo(var); 93 BindTo(var);
95 } 94 }
96 95
97 96
98 VariableProxy::VariableProxy(Isolate* isolate, 97 VariableProxy::VariableProxy(Isolate* isolate,
99 Handle<String> name, 98 Handle<String> name,
100 bool is_this, 99 bool is_this,
101 Interface* interface, 100 Interface* interface,
102 int position) 101 int position)
103 : Expression(isolate), 102 : Expression(isolate, position),
104 name_(name), 103 name_(name),
105 var_(NULL), 104 var_(NULL),
106 is_this_(is_this), 105 is_this_(is_this),
107 is_trivial_(false), 106 is_trivial_(false),
108 is_lvalue_(false), 107 is_lvalue_(false),
109 position_(position),
110 interface_(interface) { 108 interface_(interface) {
111 // Names must be canonicalized for fast equality checks. 109 // Names must be canonicalized for fast equality checks.
112 ASSERT(name->IsInternalizedString()); 110 ASSERT(name->IsInternalizedString());
113 } 111 }
114 112
115 113
116 void VariableProxy::BindTo(Variable* var) { 114 void VariableProxy::BindTo(Variable* var) {
117 ASSERT(var_ == NULL); // must be bound only once 115 ASSERT(var_ == NULL); // must be bound only once
118 ASSERT(var != NULL); // must bind 116 ASSERT(var != NULL); // must bind
119 ASSERT(!FLAG_harmony_modules || interface_->IsUnified(var->interface())); 117 ASSERT(!FLAG_harmony_modules || interface_->IsUnified(var->interface()));
120 ASSERT((is_this() && var->is_this()) || name_.is_identical_to(var->name())); 118 ASSERT((is_this() && var->is_this()) || name_.is_identical_to(var->name()));
121 // Ideally CONST-ness should match. However, this is very hard to achieve 119 // Ideally CONST-ness should match. However, this is very hard to achieve
122 // because we don't know the exact semantics of conflicting (const and 120 // because we don't know the exact semantics of conflicting (const and
123 // non-const) multiple variable declarations, const vars introduced via 121 // non-const) multiple variable declarations, const vars introduced via
124 // eval() etc. Const-ness and variable declarations are a complete mess 122 // eval() etc. Const-ness and variable declarations are a complete mess
125 // in JS. Sigh... 123 // in JS. Sigh...
126 var_ = var; 124 var_ = var;
127 var->set_is_used(true); 125 var->set_is_used(true);
128 } 126 }
129 127
130 128
131 Assignment::Assignment(Isolate* isolate, 129 Assignment::Assignment(Isolate* isolate,
132 Token::Value op, 130 Token::Value op,
133 Expression* target, 131 Expression* target,
134 Expression* value, 132 Expression* value,
135 int pos) 133 int pos)
136 : Expression(isolate), 134 : Expression(isolate, pos),
137 op_(op), 135 op_(op),
138 target_(target), 136 target_(target),
139 value_(value), 137 value_(value),
140 pos_(pos),
141 binary_operation_(NULL), 138 binary_operation_(NULL),
142 assignment_id_(GetNextId(isolate)), 139 assignment_id_(GetNextId(isolate)),
143 is_monomorphic_(false), 140 is_monomorphic_(false),
144 is_uninitialized_(false), 141 is_uninitialized_(false),
145 store_mode_(STANDARD_STORE) { } 142 store_mode_(STANDARD_STORE) { }
146 143
147 144
148 Token::Value Assignment::binary_op() const { 145 Token::Value Assignment::binary_op() const {
149 switch (op_) { 146 switch (op_) {
150 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; 147 case Token::ASSIGN_BIT_OR: return Token::BIT_OR;
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value()); 1187 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value());
1191 str = arr; 1188 str = arr;
1192 } else { 1189 } else {
1193 str = DoubleToCString(value_->Number(), buffer); 1190 str = DoubleToCString(value_->Number(), buffer);
1194 } 1191 }
1195 return isolate_->factory()->NewStringFromAscii(CStrVector(str)); 1192 return isolate_->factory()->NewStringFromAscii(CStrVector(str));
1196 } 1193 }
1197 1194
1198 1195
1199 } } // namespace v8::internal 1196 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/full-codegen.cc » ('j') | src/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698