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

Side by Side Diff: src/ast.cc

Issue 19661003: Merged r15267, r15610, r15723, r15724, r15725, r15728 into 3.19 branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.19
Patch Set: Created 7 years, 5 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') | 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 // 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 bool Expression::IsStringLiteral() { 64 bool Expression::IsStringLiteral() {
65 return AsLiteral() != NULL && AsLiteral()->handle()->IsString(); 65 return AsLiteral() != NULL && AsLiteral()->handle()->IsString();
66 } 66 }
67 67
68 68
69 bool Expression::IsNullLiteral() { 69 bool Expression::IsNullLiteral() {
70 return AsLiteral() != NULL && AsLiteral()->handle()->IsNull(); 70 return AsLiteral() != NULL && AsLiteral()->handle()->IsNull();
71 } 71 }
72 72
73 73
74 bool Expression::IsUndefinedLiteral() { 74 bool Expression::IsUndefinedLiteral(Isolate* isolate) {
75 return AsLiteral() != NULL && AsLiteral()->handle()->IsUndefined(); 75 VariableProxy* var_proxy = AsVariableProxy();
76 if (var_proxy == NULL) return false;
77 Variable* var = var_proxy->var();
78 // The global identifier "undefined" is immutable. Everything
79 // else could be reassigned.
80 return var != NULL && var->location() == Variable::UNALLOCATED &&
81 var_proxy->name()->Equals(isolate->heap()->undefined_string());
76 } 82 }
77 83
78 84
79 VariableProxy::VariableProxy(Isolate* isolate, Variable* var) 85 VariableProxy::VariableProxy(Isolate* isolate, Variable* var)
80 : Expression(isolate), 86 : Expression(isolate),
81 name_(var->name()), 87 name_(var->name()),
82 var_(NULL), // Will be set by the call to BindTo. 88 var_(NULL), // Will be set by the call to BindTo.
83 is_this_(var->is_this()), 89 is_this_(var->is_this()),
84 is_trivial_(false), 90 is_trivial_(false),
85 is_lvalue_(false), 91 is_lvalue_(false),
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 maybe_unary->op() == Token::VOID && 363 maybe_unary->op() == Token::VOID &&
358 maybe_unary->expression()->AsLiteral() != NULL; 364 maybe_unary->expression()->AsLiteral() != NULL;
359 } 365 }
360 366
361 367
362 // Check for the pattern: void <literal> equals <expression> or 368 // Check for the pattern: void <literal> equals <expression> or
363 // undefined equals <expression> 369 // undefined equals <expression>
364 static bool MatchLiteralCompareUndefined(Expression* left, 370 static bool MatchLiteralCompareUndefined(Expression* left,
365 Token::Value op, 371 Token::Value op,
366 Expression* right, 372 Expression* right,
367 Expression** expr) { 373 Expression** expr,
374 Isolate* isolate) {
368 if (IsVoidOfLiteral(left) && Token::IsEqualityOp(op)) { 375 if (IsVoidOfLiteral(left) && Token::IsEqualityOp(op)) {
369 *expr = right; 376 *expr = right;
370 return true; 377 return true;
371 } 378 }
372 if (left->IsUndefinedLiteral() && Token::IsEqualityOp(op)) { 379 if (left->IsUndefinedLiteral(isolate) && Token::IsEqualityOp(op)) {
373 *expr = right; 380 *expr = right;
374 return true; 381 return true;
375 } 382 }
376 return false; 383 return false;
377 } 384 }
378 385
379 386
380 bool CompareOperation::IsLiteralCompareUndefined(Expression** expr) { 387 bool CompareOperation::IsLiteralCompareUndefined(
381 return MatchLiteralCompareUndefined(left_, op_, right_, expr) || 388 Expression** expr, Isolate* isolate) {
382 MatchLiteralCompareUndefined(right_, op_, left_, expr); 389 return MatchLiteralCompareUndefined(left_, op_, right_, expr, isolate) ||
390 MatchLiteralCompareUndefined(right_, op_, left_, expr, isolate);
383 } 391 }
384 392
385 393
386 // Check for the pattern: null equals <expression> 394 // Check for the pattern: null equals <expression>
387 static bool MatchLiteralCompareNull(Expression* left, 395 static bool MatchLiteralCompareNull(Expression* left,
388 Token::Value op, 396 Token::Value op,
389 Expression* right, 397 Expression* right,
390 Expression** expr) { 398 Expression** expr) {
391 if (left->IsNullLiteral() && Token::IsEqualityOp(op)) { 399 if (left->IsNullLiteral() && Token::IsEqualityOp(op)) {
392 *expr = right; 400 *expr = right;
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 OS::SNPrintF(buffer, "%d", Smi::cast(*handle_)->value()); 1184 OS::SNPrintF(buffer, "%d", Smi::cast(*handle_)->value());
1177 str = arr; 1185 str = arr;
1178 } else { 1186 } else {
1179 str = DoubleToCString(handle_->Number(), buffer); 1187 str = DoubleToCString(handle_->Number(), buffer);
1180 } 1188 }
1181 return factory->NewStringFromAscii(CStrVector(str)); 1189 return factory->NewStringFromAscii(CStrVector(str));
1182 } 1190 }
1183 1191
1184 1192
1185 } } // namespace v8::internal 1193 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/full-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698