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

Side by Side Diff: src/parser.cc

Issue 12459011: Avoid bool to Oddball conversions by being lazy. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 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/objects.cc ('k') | src/runtime.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 3194 matching lines...) Expand 10 before | Expand all | Expand 10 after
3205 Token::Value op = peek(); 3205 Token::Value op = peek();
3206 if (Token::IsUnaryOp(op)) { 3206 if (Token::IsUnaryOp(op)) {
3207 op = Next(); 3207 op = Next();
3208 int position = scanner().location().beg_pos; 3208 int position = scanner().location().beg_pos;
3209 Expression* expression = ParseUnaryExpression(CHECK_OK); 3209 Expression* expression = ParseUnaryExpression(CHECK_OK);
3210 3210
3211 if (expression != NULL && (expression->AsLiteral() != NULL)) { 3211 if (expression != NULL && (expression->AsLiteral() != NULL)) {
3212 Handle<Object> literal = expression->AsLiteral()->handle(); 3212 Handle<Object> literal = expression->AsLiteral()->handle();
3213 if (op == Token::NOT) { 3213 if (op == Token::NOT) {
3214 // Convert the literal to a boolean condition and negate it. 3214 // Convert the literal to a boolean condition and negate it.
3215 bool condition = literal->ToBoolean()->IsTrue(); 3215 bool condition = literal->BooleanValue();
3216 Handle<Object> result(isolate()->heap()->ToBoolean(!condition), 3216 Handle<Object> result(isolate()->heap()->ToBoolean(!condition),
3217 isolate()); 3217 isolate());
3218 return factory()->NewLiteral(result); 3218 return factory()->NewLiteral(result);
3219 } else if (literal->IsNumber()) { 3219 } else if (literal->IsNumber()) {
3220 // Compute some expressions involving only number literals. 3220 // Compute some expressions involving only number literals.
3221 double value = literal->Number(); 3221 double value = literal->Number();
3222 switch (op) { 3222 switch (op) {
3223 case Token::ADD: 3223 case Token::ADD:
3224 return expression; 3224 return expression;
3225 case Token::SUB: 3225 case Token::SUB:
(...skipping 2706 matching lines...) Expand 10 before | Expand all | Expand 10 after
5932 ASSERT(info->isolate()->has_pending_exception()); 5932 ASSERT(info->isolate()->has_pending_exception());
5933 } else { 5933 } else {
5934 result = parser.ParseProgram(); 5934 result = parser.ParseProgram();
5935 } 5935 }
5936 } 5936 }
5937 info->SetFunction(result); 5937 info->SetFunction(result);
5938 return (result != NULL); 5938 return (result != NULL);
5939 } 5939 }
5940 5940
5941 } } // namespace v8::internal 5941 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698