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

Side by Side Diff: src/ast.cc

Issue 298143004: Minor cleanups & trivial refactoring related to Ast. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 6 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/hydrogen.cc » ('j') | no next file with comments »
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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ast.h" 5 #include "ast.h"
6 6
7 #include <cmath> // For isfinite. 7 #include <cmath> // For isfinite.
8 #include "builtins.h" 8 #include "builtins.h"
9 #include "code-stubs.h" 9 #include "code-stubs.h"
10 #include "contexts.h" 10 #include "contexts.h"
(...skipping 16 matching lines...) Expand all
27 void type::Accept(AstVisitor* v) { v->Visit##type(this); } 27 void type::Accept(AstVisitor* v) { v->Visit##type(this); }
28 AST_NODE_LIST(DECL_ACCEPT) 28 AST_NODE_LIST(DECL_ACCEPT)
29 #undef DECL_ACCEPT 29 #undef DECL_ACCEPT
30 30
31 31
32 // ---------------------------------------------------------------------------- 32 // ----------------------------------------------------------------------------
33 // Implementation of other node functionality. 33 // Implementation of other node functionality.
34 34
35 35
36 bool Expression::IsSmiLiteral() const { 36 bool Expression::IsSmiLiteral() const {
37 return AsLiteral() != NULL && AsLiteral()->value()->IsSmi(); 37 return IsLiteral() && AsLiteral()->value()->IsSmi();
38 } 38 }
39 39
40 40
41 bool Expression::IsStringLiteral() const { 41 bool Expression::IsStringLiteral() const {
42 return AsLiteral() != NULL && AsLiteral()->value()->IsString(); 42 return IsLiteral() && AsLiteral()->value()->IsString();
43 } 43 }
44 44
45 45
46 bool Expression::IsNullLiteral() const { 46 bool Expression::IsNullLiteral() const {
47 return AsLiteral() != NULL && AsLiteral()->value()->IsNull(); 47 return IsLiteral() && AsLiteral()->value()->IsNull();
48 } 48 }
49 49
50 50
51 bool Expression::IsUndefinedLiteral(Isolate* isolate) const { 51 bool Expression::IsUndefinedLiteral(Isolate* isolate) const {
52 const VariableProxy* var_proxy = AsVariableProxy(); 52 const VariableProxy* var_proxy = AsVariableProxy();
53 if (var_proxy == NULL) return false; 53 if (var_proxy == NULL) return false;
54 Variable* var = var_proxy->var(); 54 Variable* var = var_proxy->var();
55 // The global identifier "undefined" is immutable. Everything 55 // The global identifier "undefined" is immutable. Everything
56 // else could be reassigned. 56 // else could be reassigned.
57 return var != NULL && var->location() == Variable::UNALLOCATED && 57 return var != NULL && var->location() == Variable::UNALLOCATED &&
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 emit_store_ = true; 185 emit_store_ = true;
186 key_ = key; 186 key_ = key;
187 value_ = value; 187 value_ = value;
188 Handle<Object> k = key->value(); 188 Handle<Object> k = key->value();
189 if (k->IsInternalizedString() && 189 if (k->IsInternalizedString() &&
190 String::Equals(Handle<String>::cast(k), 190 String::Equals(Handle<String>::cast(k),
191 zone->isolate()->factory()->proto_string())) { 191 zone->isolate()->factory()->proto_string())) {
192 kind_ = PROTOTYPE; 192 kind_ = PROTOTYPE;
193 } else if (value_->AsMaterializedLiteral() != NULL) { 193 } else if (value_->AsMaterializedLiteral() != NULL) {
194 kind_ = MATERIALIZED_LITERAL; 194 kind_ = MATERIALIZED_LITERAL;
195 } else if (value_->AsLiteral() != NULL) { 195 } else if (value_->IsLiteral()) {
196 kind_ = CONSTANT; 196 kind_ = CONSTANT;
197 } else { 197 } else {
198 kind_ = COMPUTED; 198 kind_ = COMPUTED;
199 } 199 }
200 } 200 }
201 201
202 202
203 ObjectLiteralProperty::ObjectLiteralProperty( 203 ObjectLiteralProperty::ObjectLiteralProperty(
204 Zone* zone, bool is_getter, FunctionLiteral* value) { 204 Zone* zone, bool is_getter, FunctionLiteral* value) {
205 emit_store_ = true; 205 emit_store_ = true;
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 literals->set(1, *element_values); 383 literals->set(1, *element_values);
384 384
385 constant_elements_ = literals; 385 constant_elements_ = literals;
386 set_is_simple(is_simple); 386 set_is_simple(is_simple);
387 set_depth(depth_acc); 387 set_depth(depth_acc);
388 } 388 }
389 389
390 390
391 Handle<Object> MaterializedLiteral::GetBoilerplateValue(Expression* expression, 391 Handle<Object> MaterializedLiteral::GetBoilerplateValue(Expression* expression,
392 Isolate* isolate) { 392 Isolate* isolate) {
393 if (expression->AsLiteral() != NULL) { 393 if (expression->IsLiteral()) {
394 return expression->AsLiteral()->value(); 394 return expression->AsLiteral()->value();
395 } 395 }
396 if (CompileTimeValue::IsCompileTimeValue(expression)) { 396 if (CompileTimeValue::IsCompileTimeValue(expression)) {
397 return CompileTimeValue::GetValue(isolate, expression); 397 return CompileTimeValue::GetValue(isolate, expression);
398 } 398 }
399 return isolate->factory()->uninitialized_value(); 399 return isolate->factory()->uninitialized_value();
400 } 400 }
401 401
402 402
403 void MaterializedLiteral::BuildConstants(Isolate* isolate) { 403 void MaterializedLiteral::BuildConstants(Isolate* isolate) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 Handle<String>* check) { 492 Handle<String>* check) {
493 return MatchLiteralCompareTypeof(left_, op_, right_, expr, check) || 493 return MatchLiteralCompareTypeof(left_, op_, right_, expr, check) ||
494 MatchLiteralCompareTypeof(right_, op_, left_, expr, check); 494 MatchLiteralCompareTypeof(right_, op_, left_, expr, check);
495 } 495 }
496 496
497 497
498 static bool IsVoidOfLiteral(Expression* expr) { 498 static bool IsVoidOfLiteral(Expression* expr) {
499 UnaryOperation* maybe_unary = expr->AsUnaryOperation(); 499 UnaryOperation* maybe_unary = expr->AsUnaryOperation();
500 return maybe_unary != NULL && 500 return maybe_unary != NULL &&
501 maybe_unary->op() == Token::VOID && 501 maybe_unary->op() == Token::VOID &&
502 maybe_unary->expression()->AsLiteral() != NULL; 502 maybe_unary->expression()->IsLiteral();
503 } 503 }
504 504
505 505
506 // Check for the pattern: void <literal> equals <expression> or 506 // Check for the pattern: void <literal> equals <expression> or
507 // undefined equals <expression> 507 // undefined equals <expression>
508 static bool MatchLiteralCompareUndefined(Expression* left, 508 static bool MatchLiteralCompareUndefined(Expression* left,
509 Token::Value op, 509 Token::Value op,
510 Expression* right, 510 Expression* right,
511 Expression** expr, 511 Expression** expr,
512 Isolate* isolate) { 512 Isolate* isolate) {
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value()); 1149 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value());
1150 str = arr; 1150 str = arr;
1151 } else { 1151 } else {
1152 str = DoubleToCString(value_->Number(), buffer); 1152 str = DoubleToCString(value_->Number(), buffer);
1153 } 1153 }
1154 return isolate_->factory()->NewStringFromAsciiChecked(str); 1154 return isolate_->factory()->NewStringFromAsciiChecked(str);
1155 } 1155 }
1156 1156
1157 1157
1158 } } // namespace v8::internal 1158 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698