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

Side by Side Diff: src/parser.cc

Issue 24104006: Limit entry points into the parser API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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
« no previous file with comments | « src/parser.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3152 matching lines...) Expand 10 before | Expand all | Expand 10 after
3163 if (Token::IsUnaryOp(op)) { 3163 if (Token::IsUnaryOp(op)) {
3164 op = Next(); 3164 op = Next();
3165 int position = scanner().location().beg_pos; 3165 int position = scanner().location().beg_pos;
3166 Expression* expression = ParseUnaryExpression(CHECK_OK); 3166 Expression* expression = ParseUnaryExpression(CHECK_OK);
3167 3167
3168 if (expression != NULL && (expression->AsLiteral() != NULL)) { 3168 if (expression != NULL && (expression->AsLiteral() != NULL)) {
3169 Handle<Object> literal = expression->AsLiteral()->value(); 3169 Handle<Object> literal = expression->AsLiteral()->value();
3170 if (op == Token::NOT) { 3170 if (op == Token::NOT) {
3171 // Convert the literal to a boolean condition and negate it. 3171 // Convert the literal to a boolean condition and negate it.
3172 bool condition = literal->BooleanValue(); 3172 bool condition = literal->BooleanValue();
3173 Handle<Object> result(isolate()->heap()->ToBoolean(!condition), 3173 Handle<Object> result = isolate()->factory()->ToBoolean(!condition);
3174 isolate());
3175 return factory()->NewLiteral(result); 3174 return factory()->NewLiteral(result);
3176 } else if (literal->IsNumber()) { 3175 } else if (literal->IsNumber()) {
3177 // Compute some expressions involving only number literals. 3176 // Compute some expressions involving only number literals.
3178 double value = literal->Number(); 3177 double value = literal->Number();
3179 switch (op) { 3178 switch (op) {
3180 case Token::ADD: 3179 case Token::ADD:
3181 return expression; 3180 return expression;
3182 case Token::SUB: 3181 case Token::SUB:
3183 return factory()->NewNumberLiteral(-value); 3182 return factory()->NewNumberLiteral(-value);
3184 case Token::BIT_NOT: 3183 case Token::BIT_NOT:
(...skipping 2791 matching lines...) Expand 10 before | Expand all | Expand 10 after
5976 ASSERT(info()->isolate()->has_pending_exception()); 5975 ASSERT(info()->isolate()->has_pending_exception());
5977 } else { 5976 } else {
5978 result = ParseProgram(); 5977 result = ParseProgram();
5979 } 5978 }
5980 } 5979 }
5981 info()->SetFunction(result); 5980 info()->SetFunction(result);
5982 return (result != NULL); 5981 return (result != NULL);
5983 } 5982 }
5984 5983
5985 } } // namespace v8::internal 5984 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698