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

Side by Side Diff: src/parser.cc

Issue 298143004: Minor cleanups & trivial refactoring related to Ast. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 6 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/mips/full-codegen-mips.cc ('k') | src/x64/full-codegen-x64.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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "api.h" 7 #include "api.h"
8 #include "ast.h" 8 #include "ast.h"
9 #include "bootstrapper.h" 9 #include "bootstrapper.h"
10 #include "char-predicates-inl.h" 10 #include "char-predicates-inl.h"
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 } 518 }
519 } 519 }
520 return false; 520 return false;
521 } 521 }
522 522
523 523
524 Expression* ParserTraits::BuildUnaryExpression( 524 Expression* ParserTraits::BuildUnaryExpression(
525 Expression* expression, Token::Value op, int pos, 525 Expression* expression, Token::Value op, int pos,
526 AstNodeFactory<AstConstructionVisitor>* factory) { 526 AstNodeFactory<AstConstructionVisitor>* factory) {
527 ASSERT(expression != NULL); 527 ASSERT(expression != NULL);
528 if (expression->AsLiteral() != NULL) { 528 if (expression->IsLiteral()) {
529 Handle<Object> literal = expression->AsLiteral()->value(); 529 Handle<Object> literal = expression->AsLiteral()->value();
530 if (op == Token::NOT) { 530 if (op == Token::NOT) {
531 // Convert the literal to a boolean condition and negate it. 531 // Convert the literal to a boolean condition and negate it.
532 bool condition = literal->BooleanValue(); 532 bool condition = literal->BooleanValue();
533 Handle<Object> result = 533 Handle<Object> result =
534 parser_->isolate()->factory()->ToBoolean(!condition); 534 parser_->isolate()->factory()->ToBoolean(!condition);
535 return factory->NewLiteral(result, pos); 535 return factory->NewLiteral(result, pos);
536 } else if (literal->IsNumber()) { 536 } else if (literal->IsNumber()) {
537 // Compute some expressions involving only number literals. 537 // Compute some expressions involving only number literals.
538 double value = literal->Number(); 538 double value = literal->Number();
(...skipping 2678 matching lines...) Expand 10 before | Expand all | Expand 10 after
3217 } 3217 }
3218 3218
3219 3219
3220 void Parser::ReportInvalidCachedData(Handle<String> name, bool* ok) { 3220 void Parser::ReportInvalidCachedData(Handle<String> name, bool* ok) {
3221 ParserTraits::ReportMessage("invalid_cached_data_function", name); 3221 ParserTraits::ReportMessage("invalid_cached_data_function", name);
3222 *ok = false; 3222 *ok = false;
3223 } 3223 }
3224 3224
3225 3225
3226 bool CompileTimeValue::IsCompileTimeValue(Expression* expression) { 3226 bool CompileTimeValue::IsCompileTimeValue(Expression* expression) {
3227 if (expression->AsLiteral() != NULL) return true; 3227 if (expression->IsLiteral()) return true;
3228 MaterializedLiteral* lit = expression->AsMaterializedLiteral(); 3228 MaterializedLiteral* lit = expression->AsMaterializedLiteral();
3229 return lit != NULL && lit->is_simple(); 3229 return lit != NULL && lit->is_simple();
3230 } 3230 }
3231 3231
3232 3232
3233 Handle<FixedArray> CompileTimeValue::GetValue(Isolate* isolate, 3233 Handle<FixedArray> CompileTimeValue::GetValue(Isolate* isolate,
3234 Expression* expression) { 3234 Expression* expression) {
3235 Factory* factory = isolate->factory(); 3235 Factory* factory = isolate->factory();
3236 ASSERT(IsCompileTimeValue(expression)); 3236 ASSERT(IsCompileTimeValue(expression));
3237 Handle<FixedArray> result = factory->NewFixedArray(2, TENURED); 3237 Handle<FixedArray> result = factory->NewFixedArray(2, TENURED);
(...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after
4781 ASSERT(info()->isolate()->has_pending_exception()); 4781 ASSERT(info()->isolate()->has_pending_exception());
4782 } else { 4782 } else {
4783 result = ParseProgram(); 4783 result = ParseProgram();
4784 } 4784 }
4785 } 4785 }
4786 info()->SetFunction(result); 4786 info()->SetFunction(result);
4787 return (result != NULL); 4787 return (result != NULL);
4788 } 4788 }
4789 4789
4790 } } // namespace v8::internal 4790 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mips/full-codegen-mips.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698