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

Side by Side Diff: src/parser.cc

Issue 6603028: Merge revisions 7030:7051 from bleeding_edge to isolates branch.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 years, 9 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/objects.cc ('k') | src/regexp.js » ('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 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 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 ReportMessageAt(source_location, type, args); 802 ReportMessageAt(source_location, type, args);
803 } 803 }
804 804
805 805
806 void Parser::ReportMessageAt(Scanner::Location source_location, 806 void Parser::ReportMessageAt(Scanner::Location source_location,
807 const char* type, 807 const char* type,
808 Vector<const char*> args) { 808 Vector<const char*> args) {
809 MessageLocation location(script_, 809 MessageLocation location(script_,
810 source_location.beg_pos, 810 source_location.beg_pos,
811 source_location.end_pos); 811 source_location.end_pos);
812 Handle<JSArray> array = isolate()->factory()->NewJSArray(args.length()); 812 Factory* factory = isolate()->factory();
813 Handle<FixedArray> elements = factory->NewFixedArray(args.length());
813 for (int i = 0; i < args.length(); i++) { 814 for (int i = 0; i < args.length(); i++) {
814 SetElement(array, i, 815 Handle<String> arg_string = factory->NewStringFromUtf8(CStrVector(args[i]));
815 isolate()->factory()->NewStringFromUtf8(CStrVector(args[i]))); 816 elements->set(i, *arg_string);
816 } 817 }
817 Handle<Object> result = isolate()->factory()->NewSyntaxError(type, array); 818 Handle<JSArray> array = factory->NewJSArrayWithElements(elements);
819 Handle<Object> result = factory->NewSyntaxError(type, array);
818 isolate()->Throw(*result, &location); 820 isolate()->Throw(*result, &location);
819 } 821 }
820 822
821 823
822 void Parser::ReportMessageAt(Scanner::Location source_location, 824 void Parser::ReportMessageAt(Scanner::Location source_location,
823 const char* type, 825 const char* type,
824 Vector<Handle<String> > args) { 826 Vector<Handle<String> > args) {
825 MessageLocation location(script_, 827 MessageLocation location(script_,
826 source_location.beg_pos, 828 source_location.beg_pos,
827 source_location.end_pos); 829 source_location.end_pos);
828 Handle<JSArray> array = FACTORY->NewJSArray(args.length()); 830 Factory* factory = isolate()->factory();
831 Handle<FixedArray> elements = factory->NewFixedArray(args.length());
829 for (int i = 0; i < args.length(); i++) { 832 for (int i = 0; i < args.length(); i++) {
830 SetElement(array, i, args[i]); 833 elements->set(i, *args[i]);
831 } 834 }
832 Handle<Object> result = FACTORY->NewSyntaxError(type, array); 835 Handle<JSArray> array = factory->NewJSArrayWithElements(elements);
836 Handle<Object> result = factory->NewSyntaxError(type, array);
833 isolate()->Throw(*result, &location); 837 isolate()->Throw(*result, &location);
834 } 838 }
835 839
836 840
837 // Base class containing common code for the different finder classes used by 841 // Base class containing common code for the different finder classes used by
838 // the parser. 842 // the parser.
839 class ParserFinder { 843 class ParserFinder {
840 protected: 844 protected:
841 ParserFinder() {} 845 ParserFinder() {}
842 static Assignment* AsAssignment(Statement* stat) { 846 static Assignment* AsAssignment(Statement* stat) {
(...skipping 3201 matching lines...) Expand 10 before | Expand all | Expand 10 after
4044 message = "unexpected_token_identifier"; 4048 message = "unexpected_token_identifier";
4045 break; 4049 break;
4046 default: 4050 default:
4047 message = "unexpected_token"; 4051 message = "unexpected_token";
4048 name_opt = Token::String(token); 4052 name_opt = Token::String(token);
4049 ASSERT(name_opt != NULL); 4053 ASSERT(name_opt != NULL);
4050 break; 4054 break;
4051 } 4055 }
4052 4056
4053 Scanner::Location source_location = scanner_.location(); 4057 Scanner::Location source_location = scanner_.location();
4054 MessageLocation location(isolate()->factory()->NewScript(script), 4058 Factory* factory = isolate()->factory();
4059 MessageLocation location(factory->NewScript(script),
4055 source_location.beg_pos, 4060 source_location.beg_pos,
4056 source_location.end_pos); 4061 source_location.end_pos);
4057 int argc = (name_opt == NULL) ? 0 : 1; 4062 Handle<JSArray> array;
4058 Handle<JSArray> array = isolate()->factory()->NewJSArray(argc); 4063 if (name_opt == NULL) {
4059 if (name_opt != NULL) { 4064 array = factory->NewJSArray(0);
4060 SetElement( 4065 } else {
4061 array, 4066 Handle<String> name = factory->NewStringFromUtf8(CStrVector(name_opt));
4062 0, 4067 Handle<FixedArray> element = factory->NewFixedArray(1);
4063 isolate()->factory()->NewStringFromUtf8(CStrVector(name_opt))); 4068 element->set(0, *name);
4069 array = factory->NewJSArrayWithElements(element);
4064 } 4070 }
4065 Handle<Object> result = 4071 Handle<Object> result = factory->NewSyntaxError(message, array);
4066 isolate()->factory()->NewSyntaxError(message, array);
4067 isolate()->Throw(*result, &location); 4072 isolate()->Throw(*result, &location);
4068 return Handle<Object>::null(); 4073 return Handle<Object>::null();
4069 } 4074 }
4070 } 4075 }
4071 return result; 4076 return result;
4072 } 4077 }
4073 4078
4074 4079
4075 Handle<String> JsonParser::GetString() { 4080 Handle<String> JsonParser::GetString() {
4076 int literal_length = scanner_.literal_length(); 4081 int literal_length = scanner_.literal_length();
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
5159 info->is_global(), 5164 info->is_global(),
5160 info->StrictMode()); 5165 info->StrictMode());
5161 } 5166 }
5162 } 5167 }
5163 5168
5164 info->SetFunction(result); 5169 info->SetFunction(result);
5165 return (result != NULL); 5170 return (result != NULL);
5166 } 5171 }
5167 5172
5168 } } // namespace v8::internal 5173 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/regexp.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698