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 } | |
3207 // ...and one more time for '~foo' => 'foo^(~0)'. | |
3208 if (op == Token::BIT_NOT) { | |
3209 return factory()->NewBinaryOperation(Token::BIT_XOR, | |
3210 expression, | |
3211 factory()->NewNumberLiteral(~0), | |
3212 position); | |
3213 } | |
3214 | 3200 |
3215 return factory()->NewUnaryOperation(op, expression, position); | 3201 return factory()->NewUnaryOperation(op, expression, position); |
3216 | 3202 |
3217 } else if (Token::IsCountOp(op)) { | 3203 } else if (Token::IsCountOp(op)) { |
3218 op = Next(); | 3204 op = Next(); |
3219 Expression* expression = ParseUnaryExpression(CHECK_OK); | 3205 Expression* expression = ParseUnaryExpression(CHECK_OK); |
3220 // Signal a reference error if the expression is an invalid | 3206 // Signal a reference error if the expression is an invalid |
3221 // left-hand side expression. We could report this as a syntax | 3207 // left-hand side expression. We could report this as a syntax |
3222 // error here but for compatibility with JSC we choose to report the | 3208 // error here but for compatibility with JSC we choose to report the |
3223 // error at runtime. | 3209 // error at runtime. |
(...skipping 2709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5933 ASSERT(info()->isolate()->has_pending_exception()); | 5919 ASSERT(info()->isolate()->has_pending_exception()); |
5934 } else { | 5920 } else { |
5935 result = ParseProgram(); | 5921 result = ParseProgram(); |
5936 } | 5922 } |
5937 } | 5923 } |
5938 info()->SetFunction(result); | 5924 info()->SetFunction(result); |
5939 return (result != NULL); | 5925 return (result != NULL); |
5940 } | 5926 } |
5941 | 5927 |
5942 } } // namespace v8::internal | 5928 } } // namespace v8::internal |
OLD | NEW |