| 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 3179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3190 | 3190 |
| 3191 // Desugar '+foo' into 'foo*1', this enables the collection of type feedback | 3191 // Desugar '+foo' into 'foo*1', this enables the collection of type feedback |
| 3192 // without any special stub and the multiplication is removed later in | 3192 // without any special stub and the multiplication is removed later in |
| 3193 // Crankshaft's canonicalization pass. | 3193 // Crankshaft's canonicalization pass. |
| 3194 if (op == Token::ADD) { | 3194 if (op == Token::ADD) { |
| 3195 return factory()->NewBinaryOperation(Token::MUL, | 3195 return factory()->NewBinaryOperation(Token::MUL, |
| 3196 expression, | 3196 expression, |
| 3197 factory()->NewNumberLiteral(1), | 3197 factory()->NewNumberLiteral(1), |
| 3198 position); | 3198 position); |
| 3199 } | 3199 } |
| 3200 // The same idea for '-foo' => 'foo*(-1)'. |
| 3201 if (op == Token::SUB) { |
| 3202 return factory()->NewBinaryOperation(Token::MUL, |
| 3203 expression, |
| 3204 factory()->NewNumberLiteral(-1), |
| 3205 position); |
| 3206 } |
| 3200 | 3207 |
| 3201 return factory()->NewUnaryOperation(op, expression, position); | 3208 return factory()->NewUnaryOperation(op, expression, position); |
| 3202 | 3209 |
| 3203 } else if (Token::IsCountOp(op)) { | 3210 } else if (Token::IsCountOp(op)) { |
| 3204 op = Next(); | 3211 op = Next(); |
| 3205 Expression* expression = ParseUnaryExpression(CHECK_OK); | 3212 Expression* expression = ParseUnaryExpression(CHECK_OK); |
| 3206 // Signal a reference error if the expression is an invalid | 3213 // Signal a reference error if the expression is an invalid |
| 3207 // left-hand side expression. We could report this as a syntax | 3214 // left-hand side expression. We could report this as a syntax |
| 3208 // error here but for compatibility with JSC we choose to report the | 3215 // error here but for compatibility with JSC we choose to report the |
| 3209 // error at runtime. | 3216 // error at runtime. |
| (...skipping 2709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5919 ASSERT(info()->isolate()->has_pending_exception()); | 5926 ASSERT(info()->isolate()->has_pending_exception()); |
| 5920 } else { | 5927 } else { |
| 5921 result = ParseProgram(); | 5928 result = ParseProgram(); |
| 5922 } | 5929 } |
| 5923 } | 5930 } |
| 5924 info()->SetFunction(result); | 5931 info()->SetFunction(result); |
| 5925 return (result != NULL); | 5932 return (result != NULL); |
| 5926 } | 5933 } |
| 5927 | 5934 |
| 5928 } } // namespace v8::internal | 5935 } } // namespace v8::internal |
| OLD | NEW |