| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 7042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7053 } | 7053 } |
| 7054 | 7054 |
| 7055 | 7055 |
| 7056 Object* PixelArray::SetValue(uint32_t index, Object* value) { | 7056 Object* PixelArray::SetValue(uint32_t index, Object* value) { |
| 7057 uint8_t clamped_value = 0; | 7057 uint8_t clamped_value = 0; |
| 7058 if (index < static_cast<uint32_t>(length())) { | 7058 if (index < static_cast<uint32_t>(length())) { |
| 7059 int int_value = 0; | 7059 int int_value = 0; |
| 7060 if (value->IsSmi()) { | 7060 if (value->IsSmi()) { |
| 7061 int_value = Smi::cast(value)->value(); | 7061 int_value = Smi::cast(value)->value(); |
| 7062 } else if (value->IsHeapNumber()) { | 7062 } else if (value->IsHeapNumber()) { |
| 7063 static const DoubleRepresentation nan(OS::nan_value()); | 7063 double double_value = HeapNumber::cast(value)->value(); |
| 7064 DoubleRepresentation double_value = HeapNumber::cast(value)->value(); | 7064 if (!isnan(double_value)) { |
| 7065 if (nan.bits != double_value.bits) { | 7065 // NaN clamps to zero (default). Other doubles are rounded to |
| 7066 int_value = static_cast<int>(double_value.value + 0.5); | 7066 // the nearest integer. |
| 7067 } else { | 7067 int_value = static_cast<int>(double_value + 0.5); |
| 7068 // NaN clamps to zero. | |
| 7069 int_value = 0; | |
| 7070 } | 7068 } |
| 7071 } else if (value->IsUndefined()) { | |
| 7072 int_value = 0; | |
| 7073 } else { | 7069 } else { |
| 7074 // All other types have been converted to a number type further up in the | 7070 // Clamp undefined to zero (default). All other types have been |
| 7075 // call chain. | 7071 // converted to a number type further up in the call chain. |
| 7076 UNREACHABLE(); | 7072 ASSERT(value->IsUndefined()); |
| 7077 } | 7073 } |
| 7078 if (int_value < 0) { | 7074 if (int_value < 0) { |
| 7079 clamped_value = 0; | 7075 clamped_value = 0; |
| 7080 } else if (int_value > 255) { | 7076 } else if (int_value > 255) { |
| 7081 clamped_value = 255; | 7077 clamped_value = 255; |
| 7082 } else { | 7078 } else { |
| 7083 clamped_value = static_cast<uint8_t>(int_value); | 7079 clamped_value = static_cast<uint8_t>(int_value); |
| 7084 } | 7080 } |
| 7085 set(index, clamped_value); | 7081 set(index, clamped_value); |
| 7086 } | 7082 } |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7997 if (break_point_objects()->IsUndefined()) return 0; | 7993 if (break_point_objects()->IsUndefined()) return 0; |
| 7998 // Single beak point. | 7994 // Single beak point. |
| 7999 if (!break_point_objects()->IsFixedArray()) return 1; | 7995 if (!break_point_objects()->IsFixedArray()) return 1; |
| 8000 // Multiple break points. | 7996 // Multiple break points. |
| 8001 return FixedArray::cast(break_point_objects())->length(); | 7997 return FixedArray::cast(break_point_objects())->length(); |
| 8002 } | 7998 } |
| 8003 #endif | 7999 #endif |
| 8004 | 8000 |
| 8005 | 8001 |
| 8006 } } // namespace v8::internal | 8002 } } // namespace v8::internal |
| OLD | NEW |