OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 ReportMessageAt(source_location, type, args); | 796 ReportMessageAt(source_location, type, args); |
797 } | 797 } |
798 | 798 |
799 | 799 |
800 void Parser::ReportMessageAt(Scanner::Location source_location, | 800 void Parser::ReportMessageAt(Scanner::Location source_location, |
801 const char* type, | 801 const char* type, |
802 Vector<const char*> args) { | 802 Vector<const char*> args) { |
803 MessageLocation location(script_, | 803 MessageLocation location(script_, |
804 source_location.beg_pos, | 804 source_location.beg_pos, |
805 source_location.end_pos); | 805 source_location.end_pos); |
806 Handle<JSArray> array = Factory::NewJSArray(args.length()); | 806 Handle<FixedArray> elements = Factory::NewFixedArray(args.length()); |
807 for (int i = 0; i < args.length(); i++) { | 807 for (int i = 0; i < args.length(); i++) { |
808 SetElement(array, i, Factory::NewStringFromUtf8(CStrVector(args[i]))); | 808 Handle<String> arg_string = Factory::NewStringFromUtf8(CStrVector(args[i])); |
| 809 elements->set(i, *arg_string); |
809 } | 810 } |
| 811 Handle<JSArray> array = Factory::NewJSArrayWithElements(elements); |
810 Handle<Object> result = Factory::NewSyntaxError(type, array); | 812 Handle<Object> result = Factory::NewSyntaxError(type, array); |
811 Top::Throw(*result, &location); | 813 Top::Throw(*result, &location); |
812 } | 814 } |
813 | 815 |
814 | 816 |
815 void Parser::ReportMessageAt(Scanner::Location source_location, | 817 void Parser::ReportMessageAt(Scanner::Location source_location, |
816 const char* type, | 818 const char* type, |
817 Vector<Handle<String> > args) { | 819 Vector<Handle<String> > args) { |
818 MessageLocation location(script_, | 820 MessageLocation location(script_, |
819 source_location.beg_pos, | 821 source_location.beg_pos, |
820 source_location.end_pos); | 822 source_location.end_pos); |
821 Handle<JSArray> array = Factory::NewJSArray(args.length()); | 823 Handle<FixedArray> elements = Factory::NewFixedArray(args.length()); |
822 for (int i = 0; i < args.length(); i++) { | 824 for (int i = 0; i < args.length(); i++) { |
823 SetElement(array, i, args[i]); | 825 elements->set(i, *args[i]); |
824 } | 826 } |
| 827 Handle<JSArray> array = Factory::NewJSArrayWithElements(elements); |
825 Handle<Object> result = Factory::NewSyntaxError(type, array); | 828 Handle<Object> result = Factory::NewSyntaxError(type, array); |
826 Top::Throw(*result, &location); | 829 Top::Throw(*result, &location); |
827 } | 830 } |
828 | 831 |
829 | 832 |
830 // Base class containing common code for the different finder classes used by | 833 // Base class containing common code for the different finder classes used by |
831 // the parser. | 834 // the parser. |
832 class ParserFinder { | 835 class ParserFinder { |
833 protected: | 836 protected: |
834 ParserFinder() {} | 837 ParserFinder() {} |
(...skipping 3193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4028 message = "unexpected_token"; | 4031 message = "unexpected_token"; |
4029 name_opt = Token::String(token); | 4032 name_opt = Token::String(token); |
4030 ASSERT(name_opt != NULL); | 4033 ASSERT(name_opt != NULL); |
4031 break; | 4034 break; |
4032 } | 4035 } |
4033 | 4036 |
4034 Scanner::Location source_location = scanner_.location(); | 4037 Scanner::Location source_location = scanner_.location(); |
4035 MessageLocation location(Factory::NewScript(script), | 4038 MessageLocation location(Factory::NewScript(script), |
4036 source_location.beg_pos, | 4039 source_location.beg_pos, |
4037 source_location.end_pos); | 4040 source_location.end_pos); |
4038 int argc = (name_opt == NULL) ? 0 : 1; | 4041 Handle<JSArray> array; |
4039 Handle<JSArray> array = Factory::NewJSArray(argc); | 4042 if (name_opt == NULL) { |
4040 if (name_opt != NULL) { | 4043 array = Factory::NewJSArray(0); |
4041 SetElement(array, | 4044 } else { |
4042 0, | 4045 Handle<String> name = Factory::NewStringFromUtf8(CStrVector(name_opt)); |
4043 Factory::NewStringFromUtf8(CStrVector(name_opt))); | 4046 Handle<FixedArray> element = Factory::NewFixedArray(1); |
| 4047 element->set(0, *name); |
| 4048 array = Factory::NewJSArrayWithElements(element); |
4044 } | 4049 } |
4045 Handle<Object> result = Factory::NewSyntaxError(message, array); | 4050 Handle<Object> result = Factory::NewSyntaxError(message, array); |
4046 Top::Throw(*result, &location); | 4051 Top::Throw(*result, &location); |
4047 return Handle<Object>::null(); | 4052 return Handle<Object>::null(); |
4048 } | 4053 } |
4049 } | 4054 } |
4050 return result; | 4055 return result; |
4051 } | 4056 } |
4052 | 4057 |
4053 | 4058 |
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5156 info->is_global(), | 5161 info->is_global(), |
5157 info->StrictMode()); | 5162 info->StrictMode()); |
5158 } | 5163 } |
5159 } | 5164 } |
5160 | 5165 |
5161 info->SetFunction(result); | 5166 info->SetFunction(result); |
5162 return (result != NULL); | 5167 return (result != NULL); |
5163 } | 5168 } |
5164 | 5169 |
5165 } } // namespace v8::internal | 5170 } } // namespace v8::internal |
OLD | NEW |