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

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: added tests + fixed compilation flags (!) Created 6 years, 3 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 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 source_data[i].outer_prefix, 1121 source_data[i].outer_prefix,
1122 source_data[i].inner_source, 1122 source_data[i].inner_source,
1123 source_data[i].outer_suffix); 1123 source_data[i].outer_suffix);
1124 1124
1125 // Parse program source. 1125 // Parse program source.
1126 i::Handle<i::String> source = factory->NewStringFromUtf8( 1126 i::Handle<i::String> source = factory->NewStringFromUtf8(
1127 i::CStrVector(program.start())).ToHandleChecked(); 1127 i::CStrVector(program.start())).ToHandleChecked();
1128 CHECK_EQ(source->length(), kProgramSize); 1128 CHECK_EQ(source->length(), kProgramSize);
1129 i::Handle<i::Script> script = factory->NewScript(source); 1129 i::Handle<i::Script> script = factory->NewScript(source);
1130 i::CompilationInfoWithZone info(script); 1130 i::CompilationInfoWithZone info(script);
1131 i::Parser parser(&info); 1131 i::Parser parser(&info, isolate->stack_guard()->real_climit(),
1132 isolate->heap()->HashSeed());
1132 parser.set_allow_lazy(true); 1133 parser.set_allow_lazy(true);
1133 parser.set_allow_harmony_scoping(true); 1134 parser.set_allow_harmony_scoping(true);
1134 parser.set_allow_arrow_functions(true); 1135 parser.set_allow_arrow_functions(true);
1135 info.MarkAsGlobal(); 1136 info.MarkAsGlobal();
1136 info.SetStrictMode(source_data[i].strict_mode); 1137 info.SetStrictMode(source_data[i].strict_mode);
1137 parser.Parse(); 1138 parser.Parse();
1138 CHECK(info.function() != NULL); 1139 CHECK(info.function() != NULL);
1139 1140
1140 // Check scope types and positions. 1141 // Check scope types and positions.
1141 i::Scope* scope = info.function()->scope(); 1142 i::Scope* scope = info.function()->scope();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 CHECK_EQ(i::PreParser::kPreParseSuccess, result); 1257 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
1257 } 1258 }
1258 1259
1259 bool preparse_error = log.HasError(); 1260 bool preparse_error = log.HasError();
1260 1261
1261 // Parse the data 1262 // Parse the data
1262 i::FunctionLiteral* function; 1263 i::FunctionLiteral* function;
1263 { 1264 {
1264 i::Handle<i::Script> script = factory->NewScript(source); 1265 i::Handle<i::Script> script = factory->NewScript(source);
1265 i::CompilationInfoWithZone info(script); 1266 i::CompilationInfoWithZone info(script);
1266 i::Parser parser(&info); 1267 i::Parser parser(&info, isolate->stack_guard()->real_climit(),
1268 isolate->heap()->HashSeed());
1267 SetParserFlags(&parser, flags); 1269 SetParserFlags(&parser, flags);
1268 info.MarkAsGlobal(); 1270 info.MarkAsGlobal();
1269 parser.Parse(); 1271 parser.Parse();
1270 function = info.function(); 1272 function = info.function();
1271 } 1273 }
1272 1274
1273 // Check that preparsing fails iff parsing fails. 1275 // Check that preparsing fails iff parsing fails.
1274 if (function == NULL) { 1276 if (function == NULL) {
1275 // Extract exception from the parser. 1277 // Extract exception from the parser.
1276 CHECK(isolate->has_pending_exception()); 1278 CHECK(isolate->has_pending_exception());
(...skipping 1841 matching lines...) Expand 10 before | Expand all | Expand 10 after
3118 3120
3119 i::SNPrintF(program, "%s%s%s%s%s%s%s", prefix, outer_comment, outer, 3121 i::SNPrintF(program, "%s%s%s%s%s%s%s", prefix, outer_comment, outer,
3120 midfix, inner_comment, inner, suffix); 3122 midfix, inner_comment, inner, suffix);
3121 i::Handle<i::String> source = 3123 i::Handle<i::String> source =
3122 factory->InternalizeUtf8String(program.start()); 3124 factory->InternalizeUtf8String(program.start());
3123 source->PrintOn(stdout); 3125 source->PrintOn(stdout);
3124 printf("\n"); 3126 printf("\n");
3125 3127
3126 i::Handle<i::Script> script = factory->NewScript(source); 3128 i::Handle<i::Script> script = factory->NewScript(source);
3127 i::CompilationInfoWithZone info(script); 3129 i::CompilationInfoWithZone info(script);
3128 i::Parser parser(&info); 3130 i::Parser parser(&info, isolate->stack_guard()->real_climit(),
3131 isolate->heap()->HashSeed());
3129 parser.set_allow_harmony_scoping(true); 3132 parser.set_allow_harmony_scoping(true);
3130 CHECK(parser.Parse()); 3133 CHECK(parser.Parse());
3131 CHECK(i::Rewriter::Rewrite(&info)); 3134 CHECK(i::Rewriter::Rewrite(&info));
3132 CHECK(i::Scope::Analyze(&info)); 3135 CHECK(i::Scope::Analyze(&info));
3133 CHECK(info.function() != NULL); 3136 CHECK(info.function() != NULL);
3134 3137
3135 i::Scope* scope = info.function()->scope(); 3138 i::Scope* scope = info.function()->scope();
3136 CHECK_EQ(scope->inner_scopes()->length(), 1); 3139 CHECK_EQ(scope->inner_scopes()->length(), 1);
3137 i::Scope* inner_scope = scope->inner_scopes()->at(0); 3140 i::Scope* inner_scope = scope->inner_scopes()->at(0);
3138 const i::AstRawString* var_name = 3141 const i::AstRawString* var_name =
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
3373 const char* statement_data[] = { 3376 const char* statement_data[] = {
3374 "super = x", 3377 "super = x",
3375 "y = super", 3378 "y = super",
3376 "f(super)", 3379 "f(super)",
3377 NULL}; 3380 NULL};
3378 3381
3379 static const ParserFlag always_flags[] = {kAllowClasses}; 3382 static const ParserFlag always_flags[] = {kAllowClasses};
3380 RunParserSyncTest(context_data, statement_data, kError, NULL, 0, 3383 RunParserSyncTest(context_data, statement_data, kError, NULL, 0,
3381 always_flags, arraysize(always_flags)); 3384 always_flags, arraysize(always_flags));
3382 } 3385 }
OLDNEW
« test/cctest/test-api.cc ('K') | « test/cctest/test-api.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698