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

Side by Side Diff: src/compiler.cc

Issue 8306024: Make native syntax an early error in the preparser. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Unified enums Created 9 years, 2 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 | « no previous file | src/parser.h » ('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 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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 if (result.is_null()) { 473 if (result.is_null()) {
474 // No cache entry found. Do pre-parsing, if it makes sense, and compile 474 // No cache entry found. Do pre-parsing, if it makes sense, and compile
475 // the script. 475 // the script.
476 // Building preparse data that is only used immediately after is only a 476 // Building preparse data that is only used immediately after is only a
477 // saving if we might skip building the AST for lazily compiled functions. 477 // saving if we might skip building the AST for lazily compiled functions.
478 // I.e., preparse data isn't relevant when the lazy flag is off, and 478 // I.e., preparse data isn't relevant when the lazy flag is off, and
479 // for small sources, odds are that there aren't many functions 479 // for small sources, odds are that there aren't many functions
480 // that would be compiled lazily anyway, so we skip the preparse step 480 // that would be compiled lazily anyway, so we skip the preparse step
481 // in that case too. 481 // in that case too.
482 ScriptDataImpl* pre_data = input_pre_data; 482 ScriptDataImpl* pre_data = input_pre_data;
483 bool harmony_scoping = natives != NATIVES_CODE && FLAG_harmony_scoping; 483 int flags = kNoParsingFlags;
484 if ((natives == NATIVES_CODE) || FLAG_allow_natives_syntax) {
485 flags |= kAllowNativesSyntax;
486 }
487 if (natives != NATIVES_CODE && FLAG_harmony_scoping) {
488 flags |= kHarmonyScoping;
489 }
484 if (pre_data == NULL 490 if (pre_data == NULL
485 && source_length >= FLAG_min_preparse_length) { 491 && source_length >= FLAG_min_preparse_length) {
486 if (source->IsExternalTwoByteString()) { 492 if (source->IsExternalTwoByteString()) {
487 ExternalTwoByteStringUC16CharacterStream stream( 493 ExternalTwoByteStringUC16CharacterStream stream(
488 Handle<ExternalTwoByteString>::cast(source), 0, source->length()); 494 Handle<ExternalTwoByteString>::cast(source), 0, source->length());
489 pre_data = ParserApi::PartialPreParse(&stream, 495 pre_data = ParserApi::PartialPreParse(&stream, extension, flags);
490 extension,
491 harmony_scoping);
492 } else { 496 } else {
493 GenericStringUC16CharacterStream stream(source, 0, source->length()); 497 GenericStringUC16CharacterStream stream(source, 0, source->length());
494 pre_data = ParserApi::PartialPreParse(&stream, 498 pre_data = ParserApi::PartialPreParse(&stream, extension, flags);
495 extension,
496 harmony_scoping);
497 } 499 }
498 } 500 }
499 501
500 // Create a script object describing the script to be compiled. 502 // Create a script object describing the script to be compiled.
501 Handle<Script> script = FACTORY->NewScript(source); 503 Handle<Script> script = FACTORY->NewScript(source);
502 if (natives == NATIVES_CODE) { 504 if (natives == NATIVES_CODE) {
503 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); 505 script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
504 } 506 }
505 if (!script_name.is_null()) { 507 if (!script_name.is_null()) {
506 script->set_name(*script_name); 508 script->set_name(*script_name);
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 } 788 }
787 } 789 }
788 790
789 GDBJIT(AddCode(Handle<String>(shared->DebugName()), 791 GDBJIT(AddCode(Handle<String>(shared->DebugName()),
790 Handle<Script>(info->script()), 792 Handle<Script>(info->script()),
791 Handle<Code>(info->code()), 793 Handle<Code>(info->code()),
792 info)); 794 info));
793 } 795 }
794 796
795 } } // namespace v8::internal 797 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698