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

Side by Side Diff: src/parser.cc

Issue 7044100: Constant-fold !<number> (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2537 matching lines...) Expand 10 before | Expand all | Expand 10 after
2548 if (expression != NULL && expression->AsLiteral() && 2548 if (expression != NULL && expression->AsLiteral() &&
2549 expression->AsLiteral()->handle()->IsNumber()) { 2549 expression->AsLiteral()->handle()->IsNumber()) {
2550 double value = expression->AsLiteral()->handle()->Number(); 2550 double value = expression->AsLiteral()->handle()->Number();
2551 switch (op) { 2551 switch (op) {
2552 case Token::ADD: 2552 case Token::ADD:
2553 return expression; 2553 return expression;
2554 case Token::SUB: 2554 case Token::SUB:
2555 return NewNumberLiteral(-value); 2555 return NewNumberLiteral(-value);
2556 case Token::BIT_NOT: 2556 case Token::BIT_NOT:
2557 return NewNumberLiteral(~DoubleToInt32(value)); 2557 return NewNumberLiteral(~DoubleToInt32(value));
2558 case Token::NOT:
2559 if (value == 0) {
Kasper Lund 2011/06/10 09:20:08 Could this be something ala: Handle<Object> bo
Kevin Millikin (Chromium) 2011/06/10 10:05:14 We already have this constant folding in void Full
2560 return new(zone()) Literal(isolate()->factory()->true_value());
2561 } else {
2562 return new(zone()) Literal(isolate()->factory()->false_value());
2563 }
2558 default: break; 2564 default: break;
2559 } 2565 }
2560 } 2566 }
2561 2567
2562 // "delete identifier" is a syntax error in strict mode. 2568 // "delete identifier" is a syntax error in strict mode.
2563 if (op == Token::DELETE && top_scope_->is_strict_mode()) { 2569 if (op == Token::DELETE && top_scope_->is_strict_mode()) {
2564 VariableProxy* operand = expression->AsVariableProxy(); 2570 VariableProxy* operand = expression->AsVariableProxy();
2565 if (operand != NULL && !operand->is_this()) { 2571 if (operand != NULL && !operand->is_this()) {
2566 ReportMessage("strict_delete", Vector<const char*>::empty()); 2572 ReportMessage("strict_delete", Vector<const char*>::empty());
2567 *ok = false; 2573 *ok = false;
(...skipping 2422 matching lines...) Expand 10 before | Expand all | Expand 10 after
4990 info->is_global(), 4996 info->is_global(),
4991 info->StrictMode()); 4997 info->StrictMode());
4992 } 4998 }
4993 } 4999 }
4994 5000
4995 info->SetFunction(result); 5001 info->SetFunction(result);
4996 return (result != NULL); 5002 return (result != NULL);
4997 } 5003 }
4998 5004
4999 } } // namespace v8::internal 5005 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698