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

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

Issue 716833002: Various clean-ups after top-level lexical declarations are done. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: CR feedback Created 6 years, 1 month 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 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 isolate->unicode_cache()}; 1013 isolate->unicode_cache()};
1014 i::Parser parser(&info, &parse_info); 1014 i::Parser parser(&info, &parse_info);
1015 parser.set_allow_arrow_functions(true); 1015 parser.set_allow_arrow_functions(true);
1016 parser.set_allow_harmony_scoping(true); 1016 parser.set_allow_harmony_scoping(true);
1017 info.MarkAsGlobal(); 1017 info.MarkAsGlobal();
1018 parser.Parse(); 1018 parser.Parse();
1019 CHECK(i::Rewriter::Rewrite(&info)); 1019 CHECK(i::Rewriter::Rewrite(&info));
1020 CHECK(i::Scope::Analyze(&info)); 1020 CHECK(i::Scope::Analyze(&info));
1021 CHECK(info.function() != NULL); 1021 CHECK(info.function() != NULL);
1022 1022
1023 i::Scope* global_scope = info.function()->scope(); 1023 i::Scope* script_scope = info.function()->scope();
1024 CHECK(global_scope->is_global_scope()); 1024 CHECK(script_scope->is_script_scope());
1025 CHECK_EQ(1, global_scope->inner_scopes()->length()); 1025 CHECK_EQ(1, script_scope->inner_scopes()->length());
1026 1026
1027 i::Scope* scope = global_scope->inner_scopes()->at(0); 1027 i::Scope* scope = script_scope->inner_scopes()->at(0);
1028 CHECK_EQ(source_data[i].uses_this, scope->uses_this()); 1028 CHECK_EQ(source_data[i].uses_this, scope->uses_this());
1029 CHECK_EQ(source_data[i].uses_arguments, scope->uses_arguments()); 1029 CHECK_EQ(source_data[i].uses_arguments, scope->uses_arguments());
1030 CHECK_EQ(source_data[i].inner_uses_this, scope->inner_uses_this()); 1030 CHECK_EQ(source_data[i].inner_uses_this, scope->inner_uses_this());
1031 CHECK_EQ(source_data[i].inner_uses_arguments, 1031 CHECK_EQ(source_data[i].inner_uses_arguments,
1032 scope->inner_uses_arguments()); 1032 scope->inner_uses_arguments());
1033 } 1033 }
1034 } 1034 }
1035 } 1035 }
1036 1036
1037 1037
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 parser.set_allow_lazy(true); 1255 parser.set_allow_lazy(true);
1256 parser.set_allow_harmony_scoping(true); 1256 parser.set_allow_harmony_scoping(true);
1257 parser.set_allow_arrow_functions(true); 1257 parser.set_allow_arrow_functions(true);
1258 info.MarkAsGlobal(); 1258 info.MarkAsGlobal();
1259 info.SetStrictMode(source_data[i].strict_mode); 1259 info.SetStrictMode(source_data[i].strict_mode);
1260 parser.Parse(); 1260 parser.Parse();
1261 CHECK(info.function() != NULL); 1261 CHECK(info.function() != NULL);
1262 1262
1263 // Check scope types and positions. 1263 // Check scope types and positions.
1264 i::Scope* scope = info.function()->scope(); 1264 i::Scope* scope = info.function()->scope();
1265 CHECK(scope->is_global_scope()); 1265 CHECK(scope->is_script_scope());
1266 CHECK_EQ(scope->start_position(), 0); 1266 CHECK_EQ(scope->start_position(), 0);
1267 CHECK_EQ(scope->end_position(), kProgramSize); 1267 CHECK_EQ(scope->end_position(), kProgramSize);
1268 CHECK_EQ(scope->inner_scopes()->length(), 1); 1268 CHECK_EQ(scope->inner_scopes()->length(), 1);
1269 1269
1270 i::Scope* inner_scope = scope->inner_scopes()->at(0); 1270 i::Scope* inner_scope = scope->inner_scopes()->at(0);
1271 CHECK_EQ(inner_scope->scope_type(), source_data[i].scope_type); 1271 CHECK_EQ(inner_scope->scope_type(), source_data[i].scope_type);
1272 CHECK_EQ(inner_scope->start_position(), kPrefixLen); 1272 CHECK_EQ(inner_scope->start_position(), kPrefixLen);
1273 // The end position of a token is one position after the last 1273 // The end position of a token is one position after the last
1274 // character belonging to that token. 1274 // character belonging to that token.
1275 CHECK_EQ(inner_scope->end_position(), kPrefixLen + kInnerLen); 1275 CHECK_EQ(inner_scope->end_position(), kPrefixLen + kInnerLen);
(...skipping 1777 matching lines...) Expand 10 before | Expand all | Expand 10 after
3053 i::Zone zone(isolate); 3053 i::Zone zone(isolate);
3054 v8::Local<v8::Value> v = CompileRun(src); 3054 v8::Local<v8::Value> v = CompileRun(src);
3055 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); 3055 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
3056 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); 3056 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
3057 i::Context* context = f->context(); 3057 i::Context* context = f->context();
3058 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); 3058 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed());
3059 avf.Internalize(isolate); 3059 avf.Internalize(isolate);
3060 const i::AstRawString* name = avf.GetOneByteString("result"); 3060 const i::AstRawString* name = avf.GetOneByteString("result");
3061 i::Handle<i::String> str = name->string(); 3061 i::Handle<i::String> str = name->string();
3062 CHECK(str->IsInternalizedString()); 3062 CHECK(str->IsInternalizedString());
3063 i::Scope* global_scope = 3063 i::Scope* script_scope =
3064 new (&zone) i::Scope(NULL, i::GLOBAL_SCOPE, &avf, &zone); 3064 new (&zone) i::Scope(NULL, i::SCRIPT_SCOPE, &avf, &zone);
3065 global_scope->Initialize(); 3065 script_scope->Initialize();
3066 i::Scope* s = i::Scope::DeserializeScopeChain(context, global_scope, &zone); 3066 i::Scope* s = i::Scope::DeserializeScopeChain(context, script_scope, &zone);
3067 DCHECK(s != global_scope); 3067 DCHECK(s != script_scope);
3068 DCHECK(name != NULL); 3068 DCHECK(name != NULL);
3069 3069
3070 // Get result from h's function context (that is f's context) 3070 // Get result from h's function context (that is f's context)
3071 i::Variable* var = s->Lookup(name); 3071 i::Variable* var = s->Lookup(name);
3072 3072
3073 CHECK(var != NULL); 3073 CHECK(var != NULL);
3074 // Maybe assigned should survive deserialization 3074 // Maybe assigned should survive deserialization
3075 CHECK(var->maybe_assigned() == i::kMaybeAssigned); 3075 CHECK(var->maybe_assigned() == i::kMaybeAssigned);
3076 // TODO(sigurds) Figure out if is_used should survive context serialization. 3076 // TODO(sigurds) Figure out if is_used should survive context serialization.
3077 } 3077 }
(...skipping 22 matching lines...) Expand all
3100 source->PrintOn(stdout); 3100 source->PrintOn(stdout);
3101 printf("\n"); 3101 printf("\n");
3102 i::Zone zone(isolate); 3102 i::Zone zone(isolate);
3103 v8::Local<v8::Value> v = CompileRun(src); 3103 v8::Local<v8::Value> v = CompileRun(src);
3104 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); 3104 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
3105 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); 3105 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
3106 i::Context* context = f->context(); 3106 i::Context* context = f->context();
3107 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); 3107 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed());
3108 avf.Internalize(isolate); 3108 avf.Internalize(isolate);
3109 3109
3110 i::Scope* global_scope = 3110 i::Scope* script_scope =
3111 new (&zone) i::Scope(NULL, i::GLOBAL_SCOPE, &avf, &zone); 3111 new (&zone) i::Scope(NULL, i::SCRIPT_SCOPE, &avf, &zone);
3112 global_scope->Initialize(); 3112 script_scope->Initialize();
3113 i::Scope* s = i::Scope::DeserializeScopeChain(context, global_scope, &zone); 3113 i::Scope* s = i::Scope::DeserializeScopeChain(context, script_scope, &zone);
3114 DCHECK(s != global_scope); 3114 DCHECK(s != script_scope);
3115 const i::AstRawString* name_x = avf.GetOneByteString("x"); 3115 const i::AstRawString* name_x = avf.GetOneByteString("x");
3116 3116
3117 // Get result from f's function context (that is g's outer context) 3117 // Get result from f's function context (that is g's outer context)
3118 i::Variable* var_x = s->Lookup(name_x); 3118 i::Variable* var_x = s->Lookup(name_x);
3119 CHECK(var_x != NULL); 3119 CHECK(var_x != NULL);
3120 CHECK(var_x->maybe_assigned() == i::kMaybeAssigned); 3120 CHECK(var_x->maybe_assigned() == i::kMaybeAssigned);
3121 } 3121 }
3122 3122
3123 3123
3124 TEST(ExportsMaybeAssigned) { 3124 TEST(ExportsMaybeAssigned) {
(...skipping 22 matching lines...) Expand all
3147 source->PrintOn(stdout); 3147 source->PrintOn(stdout);
3148 printf("\n"); 3148 printf("\n");
3149 i::Zone zone(isolate); 3149 i::Zone zone(isolate);
3150 v8::Local<v8::Value> v = CompileRun(src); 3150 v8::Local<v8::Value> v = CompileRun(src);
3151 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); 3151 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
3152 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); 3152 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
3153 i::Context* context = f->context(); 3153 i::Context* context = f->context();
3154 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); 3154 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed());
3155 avf.Internalize(isolate); 3155 avf.Internalize(isolate);
3156 3156
3157 i::Scope* global_scope = 3157 i::Scope* script_scope =
3158 new (&zone) i::Scope(NULL, i::GLOBAL_SCOPE, &avf, &zone); 3158 new (&zone) i::Scope(NULL, i::SCRIPT_SCOPE, &avf, &zone);
3159 global_scope->Initialize(); 3159 script_scope->Initialize();
3160 i::Scope* s = i::Scope::DeserializeScopeChain(context, global_scope, &zone); 3160 i::Scope* s = i::Scope::DeserializeScopeChain(context, script_scope, &zone);
3161 DCHECK(s != global_scope); 3161 DCHECK(s != script_scope);
3162 const i::AstRawString* name_x = avf.GetOneByteString("x"); 3162 const i::AstRawString* name_x = avf.GetOneByteString("x");
3163 const i::AstRawString* name_f = avf.GetOneByteString("f"); 3163 const i::AstRawString* name_f = avf.GetOneByteString("f");
3164 const i::AstRawString* name_y = avf.GetOneByteString("y"); 3164 const i::AstRawString* name_y = avf.GetOneByteString("y");
3165 const i::AstRawString* name_B = avf.GetOneByteString("B"); 3165 const i::AstRawString* name_B = avf.GetOneByteString("B");
3166 const i::AstRawString* name_C = avf.GetOneByteString("C"); 3166 const i::AstRawString* name_C = avf.GetOneByteString("C");
3167 3167
3168 // Get result from h's function context (that is f's context) 3168 // Get result from h's function context (that is f's context)
3169 i::Variable* var_x = s->Lookup(name_x); 3169 i::Variable* var_x = s->Lookup(name_x);
3170 CHECK(var_x != NULL); 3170 CHECK(var_x != NULL);
3171 CHECK(var_x->maybe_assigned() == i::kMaybeAssigned); 3171 CHECK(var_x->maybe_assigned() == i::kMaybeAssigned);
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after
4301 const char* data[] = { 4301 const char* data[] = {
4302 "var foob\\u123r = 0;", 4302 "var foob\\u123r = 0;",
4303 "var \\u123roo = 0;", 4303 "var \\u123roo = 0;",
4304 "\"foob\\u123rr\"", 4304 "\"foob\\u123rr\"",
4305 // No escapes allowed in regexp flags 4305 // No escapes allowed in regexp flags
4306 "/regex/\\u0069g", 4306 "/regex/\\u0069g",
4307 "/regex/\\u006g", 4307 "/regex/\\u006g",
4308 NULL}; 4308 NULL};
4309 RunParserSyncTest(context_data, data, kError); 4309 RunParserSyncTest(context_data, data, kError);
4310 } 4310 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698