Use NativesFlag to allow/disallow natives syntax during compilation.
This way we can avoid changing the value of FLAG_allow_natives_syntax. Review URL: http://codereview.chromium.org/6694024 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7177 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
e8ff324583
commit
76b4113416
@ -529,6 +529,7 @@ Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source,
|
||||
info.MarkAsGlobal();
|
||||
info.SetExtension(extension);
|
||||
info.SetPreParseData(pre_data);
|
||||
if (natives == NATIVES_CODE) info.MarkAsAllowingNativesSyntax();
|
||||
result = MakeFunctionInfo(&info);
|
||||
if (extension == NULL && !result.is_null()) {
|
||||
CompilationCache::PutScript(source, result);
|
||||
|
@ -80,6 +80,12 @@ class CompilationInfo BASE_EMBEDDED {
|
||||
ASSERT(is_lazy());
|
||||
flags_ |= IsInLoop::encode(true);
|
||||
}
|
||||
void MarkAsAllowingNativesSyntax() {
|
||||
flags_ |= IsNativesSyntaxAllowed::encode(true);
|
||||
}
|
||||
bool allows_natives_syntax() const {
|
||||
return IsNativesSyntaxAllowed::decode(flags_);
|
||||
}
|
||||
void SetFunction(FunctionLiteral* literal) {
|
||||
ASSERT(function_ == NULL);
|
||||
function_ = literal;
|
||||
@ -174,6 +180,8 @@ class CompilationInfo BASE_EMBEDDED {
|
||||
class IsInLoop: public BitField<bool, 3, 1> {};
|
||||
// Strict mode - used in eager compilation.
|
||||
class IsStrict: public BitField<bool, 4, 1> {};
|
||||
// Native syntax (%-stuff) allowed?
|
||||
class IsNativesSyntaxAllowed: public BitField<bool, 5, 1> {};
|
||||
|
||||
unsigned flags_;
|
||||
|
||||
|
@ -764,15 +764,12 @@ bool Debug::CompileDebuggerScript(int index) {
|
||||
Handle<String> script_name = Factory::NewStringFromAscii(name);
|
||||
|
||||
// Compile the script.
|
||||
bool allow_natives_syntax = FLAG_allow_natives_syntax;
|
||||
FLAG_allow_natives_syntax = true;
|
||||
Handle<SharedFunctionInfo> function_info;
|
||||
function_info = Compiler::Compile(source_code,
|
||||
script_name,
|
||||
0, 0, NULL, NULL,
|
||||
Handle<String>::null(),
|
||||
NATIVES_CODE);
|
||||
FLAG_allow_natives_syntax = allow_natives_syntax;
|
||||
|
||||
// Silently ignore stack overflows during compilation.
|
||||
if (function_info.is_null()) {
|
||||
|
@ -5133,7 +5133,7 @@ bool ParserApi::Parse(CompilationInfo* info) {
|
||||
result = parser.ParseLazy(info);
|
||||
} else {
|
||||
bool allow_natives_syntax =
|
||||
FLAG_allow_natives_syntax || Bootstrapper::IsActive();
|
||||
info->allows_natives_syntax() || FLAG_allow_natives_syntax;
|
||||
ScriptDataImpl* pre_data = info->pre_parse_data();
|
||||
Parser parser(script, allow_natives_syntax, info->extension(), pre_data);
|
||||
if (pre_data != NULL && pre_data->has_error()) {
|
||||
|
Loading…
Reference in New Issue
Block a user