OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 int length = i::OS::SNPrintF(program, "%s%s%s", | 855 int length = i::OS::SNPrintF(program, "%s%s%s", |
856 source_data[i].outer_prefix, | 856 source_data[i].outer_prefix, |
857 source_data[i].inner_source, | 857 source_data[i].inner_source, |
858 source_data[i].outer_suffix); | 858 source_data[i].outer_suffix); |
859 CHECK(length == kProgramSize); | 859 CHECK(length == kProgramSize); |
860 | 860 |
861 // Parse program source. | 861 // Parse program source. |
862 i::Handle<i::String> source( | 862 i::Handle<i::String> source( |
863 FACTORY->NewStringFromAscii(i::CStrVector(program.start()))); | 863 FACTORY->NewStringFromAscii(i::CStrVector(program.start()))); |
864 i::Handle<i::Script> script = FACTORY->NewScript(source); | 864 i::Handle<i::Script> script = FACTORY->NewScript(source); |
865 i::Parser parser(script, false, NULL, NULL); | 865 i::Parser parser(script, i::kAllowLazy | i::EXTENDED_MODE, NULL, NULL); |
866 i::CompilationInfo info(script); | 866 i::CompilationInfo info(script); |
867 info.MarkAsGlobal(); | 867 info.MarkAsGlobal(); |
868 info.SetLanguageMode(source_data[i].language_mode); | 868 info.SetLanguageMode(source_data[i].language_mode); |
869 i::FunctionLiteral* function = parser.ParseProgram(&info); | 869 i::FunctionLiteral* function = parser.ParseProgram(&info); |
870 CHECK(function != NULL); | 870 CHECK(function != NULL); |
871 | 871 |
872 // Check scope types and positions. | 872 // Check scope types and positions. |
873 i::Scope* scope = function->scope(); | 873 i::Scope* scope = function->scope(); |
874 CHECK(scope->is_global_scope()); | 874 CHECK(scope->is_global_scope()); |
875 CHECK_EQ(scope->start_position(), 0); | 875 CHECK_EQ(scope->start_position(), 0); |
876 CHECK_EQ(scope->end_position(), kProgramSize); | 876 CHECK_EQ(scope->end_position(), kProgramSize); |
877 CHECK_EQ(scope->inner_scopes()->length(), 1); | 877 CHECK_EQ(scope->inner_scopes()->length(), 1); |
878 | 878 |
879 i::Scope* inner_scope = scope->inner_scopes()->at(0); | 879 i::Scope* inner_scope = scope->inner_scopes()->at(0); |
880 CHECK_EQ(inner_scope->type(), source_data[i].scope_type); | 880 CHECK_EQ(inner_scope->type(), source_data[i].scope_type); |
881 CHECK_EQ(inner_scope->start_position(), kPrefixLen); | 881 CHECK_EQ(inner_scope->start_position(), kPrefixLen); |
882 // The end position of a token is one position after the last | 882 // The end position of a token is one position after the last |
883 // character belonging to that token. | 883 // character belonging to that token. |
884 CHECK_EQ(inner_scope->end_position(), kPrefixLen + kInnerLen); | 884 CHECK_EQ(inner_scope->end_position(), kPrefixLen + kInnerLen); |
885 } | 885 } |
886 } | 886 } |
OLD | NEW |