| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |