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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 int length = start[0]; | 364 int length = start[0]; |
365 char* result = NewArray<char>(length + 1); | 365 char* result = NewArray<char>(length + 1); |
366 for (int i = 0; i < length; i++) { | 366 for (int i = 0; i < length; i++) { |
367 result[i] = start[i + 1]; | 367 result[i] = start[i + 1]; |
368 } | 368 } |
369 result[length] = '\0'; | 369 result[length] = '\0'; |
370 if (chars != NULL) *chars = length; | 370 if (chars != NULL) *chars = length; |
371 return result; | 371 return result; |
372 } | 372 } |
373 | 373 |
| 374 |
374 Scanner::Location ScriptDataImpl::MessageLocation() { | 375 Scanner::Location ScriptDataImpl::MessageLocation() { |
375 int beg_pos = Read(PreparseDataConstants::kMessageStartPos); | 376 int beg_pos = Read(PreparseDataConstants::kMessageStartPos); |
376 int end_pos = Read(PreparseDataConstants::kMessageEndPos); | 377 int end_pos = Read(PreparseDataConstants::kMessageEndPos); |
377 return Scanner::Location(beg_pos, end_pos); | 378 return Scanner::Location(beg_pos, end_pos); |
378 } | 379 } |
379 | 380 |
380 | 381 |
381 const char* ScriptDataImpl::BuildMessage() { | 382 const char* ScriptDataImpl::BuildMessage() { |
382 unsigned* start = ReadAddress(PreparseDataConstants::kMessageTextPos); | 383 unsigned* start = ReadAddress(PreparseDataConstants::kMessageTextPos); |
383 return ReadString(start, NULL); | 384 return ReadString(start, NULL); |
(...skipping 3378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3762 Handle<Object> Parser::GetBoilerplateValue(Expression* expression) { | 3763 Handle<Object> Parser::GetBoilerplateValue(Expression* expression) { |
3763 if (expression->AsLiteral() != NULL) { | 3764 if (expression->AsLiteral() != NULL) { |
3764 return expression->AsLiteral()->value(); | 3765 return expression->AsLiteral()->value(); |
3765 } | 3766 } |
3766 if (CompileTimeValue::IsCompileTimeValue(expression)) { | 3767 if (CompileTimeValue::IsCompileTimeValue(expression)) { |
3767 return CompileTimeValue::GetValue(expression); | 3768 return CompileTimeValue::GetValue(expression); |
3768 } | 3769 } |
3769 return isolate()->factory()->uninitialized_value(); | 3770 return isolate()->factory()->uninitialized_value(); |
3770 } | 3771 } |
3771 | 3772 |
| 3773 |
3772 // Validation per 11.1.5 Object Initialiser | 3774 // Validation per 11.1.5 Object Initialiser |
3773 class ObjectLiteralPropertyChecker { | 3775 class ObjectLiteralPropertyChecker { |
3774 public: | 3776 public: |
3775 ObjectLiteralPropertyChecker(Parser* parser, LanguageMode language_mode) : | 3777 ObjectLiteralPropertyChecker(Parser* parser, LanguageMode language_mode) : |
3776 props_(Literal::Match), | 3778 props_(Literal::Match), |
3777 parser_(parser), | 3779 parser_(parser), |
3778 language_mode_(language_mode) { | 3780 language_mode_(language_mode) { |
3779 } | 3781 } |
3780 | 3782 |
3781 void CheckProperty( | 3783 void CheckProperty( |
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4955 elements, FAST_ELEMENTS, TENURED); | 4957 elements, FAST_ELEMENTS, TENURED); |
4956 | 4958 |
4957 ZoneList<Expression*>* args = new(zone()) ZoneList<Expression*>(2, zone()); | 4959 ZoneList<Expression*>* args = new(zone()) ZoneList<Expression*>(2, zone()); |
4958 args->Add(factory()->NewLiteral(message), zone()); | 4960 args->Add(factory()->NewLiteral(message), zone()); |
4959 args->Add(factory()->NewLiteral(array), zone()); | 4961 args->Add(factory()->NewLiteral(array), zone()); |
4960 CallRuntime* call_constructor = | 4962 CallRuntime* call_constructor = |
4961 factory()->NewCallRuntime(constructor, NULL, args); | 4963 factory()->NewCallRuntime(constructor, NULL, args); |
4962 return factory()->NewThrow(call_constructor, scanner().location().beg_pos); | 4964 return factory()->NewThrow(call_constructor, scanner().location().beg_pos); |
4963 } | 4965 } |
4964 | 4966 |
| 4967 |
4965 // ---------------------------------------------------------------------------- | 4968 // ---------------------------------------------------------------------------- |
4966 // Regular expressions | 4969 // Regular expressions |
4967 | 4970 |
4968 | 4971 |
4969 RegExpParser::RegExpParser(FlatStringReader* in, | 4972 RegExpParser::RegExpParser(FlatStringReader* in, |
4970 Handle<String>* error, | 4973 Handle<String>* error, |
4971 bool multiline, | 4974 bool multiline, |
4972 Zone* zone) | 4975 Zone* zone) |
4973 : isolate_(Isolate::Current()), | 4976 : isolate_(Isolate::Current()), |
4974 zone_(zone), | 4977 zone_(zone), |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5025 void RegExpParser::Advance(int dist) { | 5028 void RegExpParser::Advance(int dist) { |
5026 next_pos_ += dist - 1; | 5029 next_pos_ += dist - 1; |
5027 Advance(); | 5030 Advance(); |
5028 } | 5031 } |
5029 | 5032 |
5030 | 5033 |
5031 bool RegExpParser::simple() { | 5034 bool RegExpParser::simple() { |
5032 return simple_; | 5035 return simple_; |
5033 } | 5036 } |
5034 | 5037 |
| 5038 |
5035 RegExpTree* RegExpParser::ReportError(Vector<const char> message) { | 5039 RegExpTree* RegExpParser::ReportError(Vector<const char> message) { |
5036 failed_ = true; | 5040 failed_ = true; |
5037 *error_ = isolate()->factory()->NewStringFromAscii(message, NOT_TENURED); | 5041 *error_ = isolate()->factory()->NewStringFromAscii(message, NOT_TENURED); |
5038 // Zip to the end to make sure the no more input is read. | 5042 // Zip to the end to make sure the no more input is read. |
5039 current_ = kEndMarker; | 5043 current_ = kEndMarker; |
5040 next_pos_ = in()->length(); | 5044 next_pos_ = in()->length(); |
5041 return NULL; | 5045 return NULL; |
5042 } | 5046 } |
5043 | 5047 |
5044 | 5048 |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5915 ASSERT(info()->isolate()->has_pending_exception()); | 5919 ASSERT(info()->isolate()->has_pending_exception()); |
5916 } else { | 5920 } else { |
5917 result = ParseProgram(); | 5921 result = ParseProgram(); |
5918 } | 5922 } |
5919 } | 5923 } |
5920 info()->SetFunction(result); | 5924 info()->SetFunction(result); |
5921 return (result != NULL); | 5925 return (result != NULL); |
5922 } | 5926 } |
5923 | 5927 |
5924 } } // namespace v8::internal | 5928 } } // namespace v8::internal |
OLD | NEW |