Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: src/parser.cc

Issue 22184004: Desugar bitwise negation into XOR and kill all UnaryOp stuff. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased. Feedback. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 3186 matching lines...) Expand 10 before | Expand all | Expand 10 after
3197 factory()->NewNumberLiteral(1), 3197 factory()->NewNumberLiteral(1),
3198 position); 3198 position);
3199 } 3199 }
3200 // The same idea for '-foo' => 'foo*(-1)'. 3200 // The same idea for '-foo' => 'foo*(-1)'.
3201 if (op == Token::SUB) { 3201 if (op == Token::SUB) {
3202 return factory()->NewBinaryOperation(Token::MUL, 3202 return factory()->NewBinaryOperation(Token::MUL,
3203 expression, 3203 expression,
3204 factory()->NewNumberLiteral(-1), 3204 factory()->NewNumberLiteral(-1),
3205 position); 3205 position);
3206 } 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 }
3207 3214
3208 return factory()->NewUnaryOperation(op, expression, position); 3215 return factory()->NewUnaryOperation(op, expression, position);
3209 3216
3210 } else if (Token::IsCountOp(op)) { 3217 } else if (Token::IsCountOp(op)) {
3211 op = Next(); 3218 op = Next();
3212 Expression* expression = ParseUnaryExpression(CHECK_OK); 3219 Expression* expression = ParseUnaryExpression(CHECK_OK);
3213 // Signal a reference error if the expression is an invalid 3220 // Signal a reference error if the expression is an invalid
3214 // left-hand side expression. We could report this as a syntax 3221 // left-hand side expression. We could report this as a syntax
3215 // error here but for compatibility with JSC we choose to report the 3222 // error here but for compatibility with JSC we choose to report the
3216 // error at runtime. 3223 // error at runtime.
(...skipping 2709 matching lines...) Expand 10 before | Expand all | Expand 10 after
5926 ASSERT(info()->isolate()->has_pending_exception()); 5933 ASSERT(info()->isolate()->has_pending_exception());
5927 } else { 5934 } else {
5928 result = ParseProgram(); 5935 result = ParseProgram();
5929 } 5936 }
5930 } 5937 }
5931 info()->SetFunction(result); 5938 info()->SetFunction(result);
5932 return (result != NULL); 5939 return (result != NULL);
5933 } 5940 }
5934 5941
5935 } } // namespace v8::internal 5942 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | src/runtime.h » ('j') | src/x64/lithium-codegen-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698