Commit 76b41134 authored by vitalyr@chromium.org's avatar vitalyr@chromium.org

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
parent e8ff3245
...@@ -529,6 +529,7 @@ Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source, ...@@ -529,6 +529,7 @@ Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source,
info.MarkAsGlobal(); info.MarkAsGlobal();
info.SetExtension(extension); info.SetExtension(extension);
info.SetPreParseData(pre_data); info.SetPreParseData(pre_data);
if (natives == NATIVES_CODE) info.MarkAsAllowingNativesSyntax();
result = MakeFunctionInfo(&info); result = MakeFunctionInfo(&info);
if (extension == NULL && !result.is_null()) { if (extension == NULL && !result.is_null()) {
CompilationCache::PutScript(source, result); CompilationCache::PutScript(source, result);
......
...@@ -80,6 +80,12 @@ class CompilationInfo BASE_EMBEDDED { ...@@ -80,6 +80,12 @@ class CompilationInfo BASE_EMBEDDED {
ASSERT(is_lazy()); ASSERT(is_lazy());
flags_ |= IsInLoop::encode(true); flags_ |= IsInLoop::encode(true);
} }
void MarkAsAllowingNativesSyntax() {
flags_ |= IsNativesSyntaxAllowed::encode(true);
}
bool allows_natives_syntax() const {
return IsNativesSyntaxAllowed::decode(flags_);
}
void SetFunction(FunctionLiteral* literal) { void SetFunction(FunctionLiteral* literal) {
ASSERT(function_ == NULL); ASSERT(function_ == NULL);
function_ = literal; function_ = literal;
...@@ -174,6 +180,8 @@ class CompilationInfo BASE_EMBEDDED { ...@@ -174,6 +180,8 @@ class CompilationInfo BASE_EMBEDDED {
class IsInLoop: public BitField<bool, 3, 1> {}; class IsInLoop: public BitField<bool, 3, 1> {};
// Strict mode - used in eager compilation. // Strict mode - used in eager compilation.
class IsStrict: public BitField<bool, 4, 1> {}; class IsStrict: public BitField<bool, 4, 1> {};
// Native syntax (%-stuff) allowed?
class IsNativesSyntaxAllowed: public BitField<bool, 5, 1> {};
unsigned flags_; unsigned flags_;
......
...@@ -764,15 +764,12 @@ bool Debug::CompileDebuggerScript(int index) { ...@@ -764,15 +764,12 @@ bool Debug::CompileDebuggerScript(int index) {
Handle<String> script_name = Factory::NewStringFromAscii(name); Handle<String> script_name = Factory::NewStringFromAscii(name);
// Compile the script. // Compile the script.
bool allow_natives_syntax = FLAG_allow_natives_syntax;
FLAG_allow_natives_syntax = true;
Handle<SharedFunctionInfo> function_info; Handle<SharedFunctionInfo> function_info;
function_info = Compiler::Compile(source_code, function_info = Compiler::Compile(source_code,
script_name, script_name,
0, 0, NULL, NULL, 0, 0, NULL, NULL,
Handle<String>::null(), Handle<String>::null(),
NATIVES_CODE); NATIVES_CODE);
FLAG_allow_natives_syntax = allow_natives_syntax;
// Silently ignore stack overflows during compilation. // Silently ignore stack overflows during compilation.
if (function_info.is_null()) { if (function_info.is_null()) {
......
...@@ -5133,7 +5133,7 @@ bool ParserApi::Parse(CompilationInfo* info) { ...@@ -5133,7 +5133,7 @@ bool ParserApi::Parse(CompilationInfo* info) {
result = parser.ParseLazy(info); result = parser.ParseLazy(info);
} else { } else {
bool allow_natives_syntax = 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(); ScriptDataImpl* pre_data = info->pre_parse_data();
Parser parser(script, allow_natives_syntax, info->extension(), pre_data); Parser parser(script, allow_natives_syntax, info->extension(), pre_data);
if (pre_data != NULL && pre_data->has_error()) { if (pre_data != NULL && pre_data->has_error()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment