OLD | NEW |
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 3185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3196 if (Token::IsUnaryOp(op)) { | 3196 if (Token::IsUnaryOp(op)) { |
3197 op = Next(); | 3197 op = Next(); |
3198 int position = scanner().location().beg_pos; | 3198 int position = scanner().location().beg_pos; |
3199 Expression* expression = ParseUnaryExpression(CHECK_OK); | 3199 Expression* expression = ParseUnaryExpression(CHECK_OK); |
3200 | 3200 |
3201 if (expression != NULL && (expression->AsLiteral() != NULL)) { | 3201 if (expression != NULL && (expression->AsLiteral() != NULL)) { |
3202 Handle<Object> literal = expression->AsLiteral()->handle(); | 3202 Handle<Object> literal = expression->AsLiteral()->handle(); |
3203 if (op == Token::NOT) { | 3203 if (op == Token::NOT) { |
3204 // Convert the literal to a boolean condition and negate it. | 3204 // Convert the literal to a boolean condition and negate it. |
3205 bool condition = literal->ToBoolean()->IsTrue(); | 3205 bool condition = literal->ToBoolean()->IsTrue(); |
3206 Handle<Object> result(isolate()->heap()->ToBoolean(!condition)); | 3206 Handle<Object> result(isolate()->heap()->ToBoolean(!condition), |
| 3207 isolate()); |
3207 return factory()->NewLiteral(result); | 3208 return factory()->NewLiteral(result); |
3208 } else if (literal->IsNumber()) { | 3209 } else if (literal->IsNumber()) { |
3209 // Compute some expressions involving only number literals. | 3210 // Compute some expressions involving only number literals. |
3210 double value = literal->Number(); | 3211 double value = literal->Number(); |
3211 switch (op) { | 3212 switch (op) { |
3212 case Token::ADD: | 3213 case Token::ADD: |
3213 return expression; | 3214 return expression; |
3214 case Token::SUB: | 3215 case Token::SUB: |
3215 return factory()->NewNumberLiteral(-value); | 3216 return factory()->NewNumberLiteral(-value); |
3216 case Token::BIT_NOT: | 3217 case Token::BIT_NOT: |
(...skipping 2754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5971 ASSERT(info->isolate()->has_pending_exception()); | 5972 ASSERT(info->isolate()->has_pending_exception()); |
5972 } else { | 5973 } else { |
5973 result = parser.ParseProgram(); | 5974 result = parser.ParseProgram(); |
5974 } | 5975 } |
5975 } | 5976 } |
5976 info->SetFunction(result); | 5977 info->SetFunction(result); |
5977 return (result != NULL); | 5978 return (result != NULL); |
5978 } | 5979 } |
5979 | 5980 |
5980 } } // namespace v8::internal | 5981 } } // namespace v8::internal |
OLD | NEW |