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

Side by Side Diff: test/cctest/test-parsing.cc

Issue 366153002: Add script streaming API (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: special chars fix Created 6 years, 4 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
OLDNEW
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 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 source_data[i].outer_prefix, 1120 source_data[i].outer_prefix,
1121 source_data[i].inner_source, 1121 source_data[i].inner_source,
1122 source_data[i].outer_suffix); 1122 source_data[i].outer_suffix);
1123 1123
1124 // Parse program source. 1124 // Parse program source.
1125 i::Handle<i::String> source = factory->NewStringFromUtf8( 1125 i::Handle<i::String> source = factory->NewStringFromUtf8(
1126 i::CStrVector(program.start())).ToHandleChecked(); 1126 i::CStrVector(program.start())).ToHandleChecked();
1127 CHECK_EQ(source->length(), kProgramSize); 1127 CHECK_EQ(source->length(), kProgramSize);
1128 i::Handle<i::Script> script = factory->NewScript(source); 1128 i::Handle<i::Script> script = factory->NewScript(source);
1129 i::CompilationInfoWithZone info(script); 1129 i::CompilationInfoWithZone info(script);
1130 i::Parser parser(&info); 1130 i::Parser parser(&info, isolate->stack_guard()->real_climit(),
1131 isolate->heap()->HashSeed());
1131 parser.set_allow_lazy(true); 1132 parser.set_allow_lazy(true);
1132 parser.set_allow_harmony_scoping(true); 1133 parser.set_allow_harmony_scoping(true);
1133 parser.set_allow_arrow_functions(true); 1134 parser.set_allow_arrow_functions(true);
1134 info.MarkAsGlobal(); 1135 info.MarkAsGlobal();
1135 info.SetStrictMode(source_data[i].strict_mode); 1136 info.SetStrictMode(source_data[i].strict_mode);
1136 parser.Parse(); 1137 parser.Parse();
1137 CHECK(info.function() != NULL); 1138 CHECK(info.function() != NULL);
1138 1139
1139 // Check scope types and positions. 1140 // Check scope types and positions.
1140 i::Scope* scope = info.function()->scope(); 1141 i::Scope* scope = info.function()->scope();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 1254 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
1254 } 1255 }
1255 1256
1256 bool preparse_error = log.HasError(); 1257 bool preparse_error = log.HasError();
1257 1258
1258 // Parse the data 1259 // Parse the data
1259 i::FunctionLiteral* function; 1260 i::FunctionLiteral* function;
1260 { 1261 {
1261 i::Handle<i::Script> script = factory->NewScript(source); 1262 i::Handle<i::Script> script = factory->NewScript(source);
1262 i::CompilationInfoWithZone info(script); 1263 i::CompilationInfoWithZone info(script);
1263 i::Parser parser(&info); 1264 i::Parser parser(&info, isolate->stack_guard()->real_climit(),
1265 isolate->heap()->HashSeed());
1264 SetParserFlags(&parser, flags); 1266 SetParserFlags(&parser, flags);
1265 info.MarkAsGlobal(); 1267 info.MarkAsGlobal();
1266 parser.Parse(); 1268 parser.Parse();
1267 function = info.function(); 1269 function = info.function();
1268 } 1270 }
1269 1271
1270 // Check that preparsing fails iff parsing fails. 1272 // Check that preparsing fails iff parsing fails.
1271 if (function == NULL) { 1273 if (function == NULL) {
1272 // Extract exception from the parser. 1274 // Extract exception from the parser.
1273 CHECK(isolate->has_pending_exception()); 1275 CHECK(isolate->has_pending_exception());
(...skipping 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after
3125 3127
3126 i::SNPrintF(program, "%s%s%s%s%s%s%s", prefix, outer_comment, outer, 3128 i::SNPrintF(program, "%s%s%s%s%s%s%s", prefix, outer_comment, outer,
3127 midfix, inner_comment, inner, suffix); 3129 midfix, inner_comment, inner, suffix);
3128 i::Handle<i::String> source = 3130 i::Handle<i::String> source =
3129 factory->InternalizeUtf8String(program.start()); 3131 factory->InternalizeUtf8String(program.start());
3130 source->PrintOn(stdout); 3132 source->PrintOn(stdout);
3131 printf("\n"); 3133 printf("\n");
3132 3134
3133 i::Handle<i::Script> script = factory->NewScript(source); 3135 i::Handle<i::Script> script = factory->NewScript(source);
3134 i::CompilationInfoWithZone info(script); 3136 i::CompilationInfoWithZone info(script);
3135 i::Parser parser(&info); 3137 i::Parser parser(&info, isolate->stack_guard()->real_climit(),
3138 isolate->heap()->HashSeed());
3136 parser.set_allow_harmony_scoping(true); 3139 parser.set_allow_harmony_scoping(true);
3137 CHECK(parser.Parse()); 3140 CHECK(parser.Parse());
3138 CHECK(i::Rewriter::Rewrite(&info)); 3141 CHECK(i::Rewriter::Rewrite(&info));
3139 CHECK(i::Scope::Analyze(&info)); 3142 CHECK(i::Scope::Analyze(&info));
3140 CHECK(info.function() != NULL); 3143 CHECK(info.function() != NULL);
3141 3144
3142 i::Scope* scope = info.function()->scope(); 3145 i::Scope* scope = info.function()->scope();
3143 CHECK_EQ(scope->inner_scopes()->length(), 1); 3146 CHECK_EQ(scope->inner_scopes()->length(), 1);
3144 i::Scope* inner_scope = scope->inner_scopes()->at(0); 3147 i::Scope* inner_scope = scope->inner_scopes()->at(0);
3145 const i::AstRawString* var_name = 3148 const i::AstRawString* var_name =
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
3336 3339
3337 // Arrow has more precedence, this is the same as: foo ? bar : (baz = {}) 3340 // Arrow has more precedence, this is the same as: foo ? bar : (baz = {})
3338 "foo ? bar : baz => {}", 3341 "foo ? bar : baz => {}",
3339 NULL 3342 NULL
3340 }; 3343 };
3341 3344
3342 static const ParserFlag always_flags[] = {kAllowArrowFunctions}; 3345 static const ParserFlag always_flags[] = {kAllowArrowFunctions};
3343 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, 3346 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
3344 always_flags, ARRAY_SIZE(always_flags)); 3347 always_flags, ARRAY_SIZE(always_flags));
3345 } 3348 }
OLDNEW
« include/v8.h ('K') | « src/scanner-character-streams.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698