OLD | NEW |
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 2538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2549 if (expression != NULL && expression->AsLiteral() && | 2549 if (expression != NULL && expression->AsLiteral() && |
2550 expression->AsLiteral()->handle()->IsNumber()) { | 2550 expression->AsLiteral()->handle()->IsNumber()) { |
2551 double value = expression->AsLiteral()->handle()->Number(); | 2551 double value = expression->AsLiteral()->handle()->Number(); |
2552 switch (op) { | 2552 switch (op) { |
2553 case Token::ADD: | 2553 case Token::ADD: |
2554 return expression; | 2554 return expression; |
2555 case Token::SUB: | 2555 case Token::SUB: |
2556 return NewNumberLiteral(-value); | 2556 return NewNumberLiteral(-value); |
2557 case Token::BIT_NOT: | 2557 case Token::BIT_NOT: |
2558 return NewNumberLiteral(~DoubleToInt32(value)); | 2558 return NewNumberLiteral(~DoubleToInt32(value)); |
| 2559 case Token::NOT: { |
| 2560 bool bool_value = isnan(value) ? true : (value == 0); |
| 2561 Handle<Object> boolean(isolate()->heap()->ToBoolean(bool_value)); |
| 2562 return new(zone()) Literal(boolean); |
| 2563 } |
2559 default: break; | 2564 default: break; |
2560 } | 2565 } |
2561 } | 2566 } |
2562 | 2567 |
2563 // "delete identifier" is a syntax error in strict mode. | 2568 // "delete identifier" is a syntax error in strict mode. |
2564 if (op == Token::DELETE && top_scope_->is_strict_mode()) { | 2569 if (op == Token::DELETE && top_scope_->is_strict_mode()) { |
2565 VariableProxy* operand = expression->AsVariableProxy(); | 2570 VariableProxy* operand = expression->AsVariableProxy(); |
2566 if (operand != NULL && !operand->is_this()) { | 2571 if (operand != NULL && !operand->is_this()) { |
2567 ReportMessage("strict_delete", Vector<const char*>::empty()); | 2572 ReportMessage("strict_delete", Vector<const char*>::empty()); |
2568 *ok = false; | 2573 *ok = false; |
(...skipping 2426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4995 info->is_global(), | 5000 info->is_global(), |
4996 info->StrictMode()); | 5001 info->StrictMode()); |
4997 } | 5002 } |
4998 } | 5003 } |
4999 | 5004 |
5000 info->SetFunction(result); | 5005 info->SetFunction(result); |
5001 return (result != NULL); | 5006 return (result != NULL); |
5002 } | 5007 } |
5003 | 5008 |
5004 } } // namespace v8::internal | 5009 } } // namespace v8::internal |
OLD | NEW |