Commit 1abf3ed0 authored by rossberg@chromium.org's avatar rossberg@chromium.org

Introduce collective --harmony flag.

Shorten --harmony-block-scoping to --harmony-scoping.

R=keuchel@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/8226017

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9589 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 819323f2
...@@ -1413,7 +1413,7 @@ void ObjectTemplate::SetInternalFieldCount(int value) { ...@@ -1413,7 +1413,7 @@ void ObjectTemplate::SetInternalFieldCount(int value) {
ScriptData* ScriptData::PreCompile(const char* input, int length) { ScriptData* ScriptData::PreCompile(const char* input, int length) {
i::Utf8ToUC16CharacterStream stream( i::Utf8ToUC16CharacterStream stream(
reinterpret_cast<const unsigned char*>(input), length); reinterpret_cast<const unsigned char*>(input), length);
return i::ParserApi::PreParse(&stream, NULL, i::FLAG_harmony_block_scoping); return i::ParserApi::PreParse(&stream, NULL, i::FLAG_harmony_scoping);
} }
...@@ -1422,10 +1422,10 @@ ScriptData* ScriptData::PreCompile(v8::Handle<String> source) { ...@@ -1422,10 +1422,10 @@ ScriptData* ScriptData::PreCompile(v8::Handle<String> source) {
if (str->IsExternalTwoByteString()) { if (str->IsExternalTwoByteString()) {
i::ExternalTwoByteStringUC16CharacterStream stream( i::ExternalTwoByteStringUC16CharacterStream stream(
i::Handle<i::ExternalTwoByteString>::cast(str), 0, str->length()); i::Handle<i::ExternalTwoByteString>::cast(str), 0, str->length());
return i::ParserApi::PreParse(&stream, NULL, i::FLAG_harmony_block_scoping); return i::ParserApi::PreParse(&stream, NULL, i::FLAG_harmony_scoping);
} else { } else {
i::GenericStringUC16CharacterStream stream(str, 0, str->length()); i::GenericStringUC16CharacterStream stream(str, 0, str->length());
return i::ParserApi::PreParse(&stream, NULL, i::FLAG_harmony_block_scoping); return i::ParserApi::PreParse(&stream, NULL, i::FLAG_harmony_scoping);
} }
} }
......
...@@ -2139,10 +2139,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag, ...@@ -2139,10 +2139,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag,
__ push(r1); __ push(r1);
// Push the strict mode flag. In harmony mode every eval call // Push the strict mode flag. In harmony mode every eval call
// is a strict mode eval call. // is a strict mode eval call.
StrictModeFlag strict_mode = strict_mode_flag(); StrictModeFlag strict_mode =
if (FLAG_harmony_block_scoping) { FLAG_harmony_scoping ? kStrictMode : strict_mode_flag();
strict_mode = kStrictMode;
}
__ mov(r1, Operand(Smi::FromInt(strict_mode))); __ mov(r1, Operand(Smi::FromInt(strict_mode)));
__ push(r1); __ push(r1);
......
...@@ -480,8 +480,7 @@ Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source, ...@@ -480,8 +480,7 @@ Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source,
// that would be compiled lazily anyway, so we skip the preparse step // that would be compiled lazily anyway, so we skip the preparse step
// in that case too. // in that case too.
ScriptDataImpl* pre_data = input_pre_data; ScriptDataImpl* pre_data = input_pre_data;
bool harmony_block_scoping = natives != NATIVES_CODE && bool harmony_scoping = natives != NATIVES_CODE && FLAG_harmony_scoping;
FLAG_harmony_block_scoping;
if (pre_data == NULL if (pre_data == NULL
&& source_length >= FLAG_min_preparse_length) { && source_length >= FLAG_min_preparse_length) {
if (source->IsExternalTwoByteString()) { if (source->IsExternalTwoByteString()) {
...@@ -489,12 +488,12 @@ Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source, ...@@ -489,12 +488,12 @@ Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source,
Handle<ExternalTwoByteString>::cast(source), 0, source->length()); Handle<ExternalTwoByteString>::cast(source), 0, source->length());
pre_data = ParserApi::PartialPreParse(&stream, pre_data = ParserApi::PartialPreParse(&stream,
extension, extension,
harmony_block_scoping); harmony_scoping);
} else { } else {
GenericStringUC16CharacterStream stream(source, 0, source->length()); GenericStringUC16CharacterStream stream(source, 0, source->length());
pre_data = ParserApi::PartialPreParse(&stream, pre_data = ParserApi::PartialPreParse(&stream,
extension, extension,
harmony_block_scoping); harmony_scoping);
} }
} }
......
...@@ -98,9 +98,10 @@ private: ...@@ -98,9 +98,10 @@ private:
// Flags for experimental language features. // Flags for experimental language features.
DEFINE_bool(harmony_typeof, false, "enable harmony semantics for typeof") DEFINE_bool(harmony_typeof, false, "enable harmony semantics for typeof")
DEFINE_bool(harmony_scoping, false, "enable harmony block scoping")
DEFINE_bool(harmony_proxies, false, "enable harmony proxies") DEFINE_bool(harmony_proxies, false, "enable harmony proxies")
DEFINE_bool(harmony_weakmaps, false, "enable harmony weak maps") DEFINE_bool(harmony_weakmaps, false, "enable harmony weak maps")
DEFINE_bool(harmony_block_scoping, false, "enable harmony block scoping") DEFINE_bool(harmony, false, "enable all harmony features")
// Flags for experimental implementation features. // Flags for experimental implementation features.
DEFINE_bool(unbox_double_arrays, true, "automatically unbox arrays of doubles") DEFINE_bool(unbox_double_arrays, true, "automatically unbox arrays of doubles")
......
...@@ -2143,10 +2143,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag, ...@@ -2143,10 +2143,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag,
// Push the strict mode flag. In harmony mode every eval call // Push the strict mode flag. In harmony mode every eval call
// is a strict mode eval call. // is a strict mode eval call.
StrictModeFlag strict_mode = strict_mode_flag(); StrictModeFlag strict_mode =
if (FLAG_harmony_block_scoping) { FLAG_harmony_scoping ? kStrictMode : strict_mode_flag();
strict_mode = kStrictMode;
}
__ push(Immediate(Smi::FromInt(strict_mode))); __ push(Immediate(Smi::FromInt(strict_mode)));
__ CallRuntime(flag == SKIP_CONTEXT_LOOKUP __ CallRuntime(flag == SKIP_CONTEXT_LOOKUP
......
...@@ -2136,10 +2136,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag, ...@@ -2136,10 +2136,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag,
__ push(a1); __ push(a1);
// Push the strict mode flag. In harmony mode every eval call // Push the strict mode flag. In harmony mode every eval call
// is a strict mode eval call. // is a strict mode eval call.
StrictModeFlag strict_mode = strict_mode_flag(); StrictModeFlag strict_mode =
if (FLAG_harmony_block_scoping) { FLAG_harmony_scoping ? kStrictMode : strict_mode_flag();
strict_mode = kStrictMode;
}
__ li(a1, Operand(Smi::FromInt(strict_mode))); __ li(a1, Operand(Smi::FromInt(strict_mode)));
__ push(a1); __ push(a1);
......
...@@ -587,7 +587,7 @@ Parser::Parser(Handle<Script> script, ...@@ -587,7 +587,7 @@ Parser::Parser(Handle<Script> script,
fni_(NULL), fni_(NULL),
stack_overflow_(false), stack_overflow_(false),
parenthesized_function_(false), parenthesized_function_(false),
harmony_block_scoping_(false) { harmony_scoping_(false) {
AstNode::ResetIds(); AstNode::ResetIds();
} }
...@@ -650,7 +650,7 @@ FunctionLiteral* Parser::DoParseProgram(Handle<String> source, ...@@ -650,7 +650,7 @@ FunctionLiteral* Parser::DoParseProgram(Handle<String> source,
CheckOctalLiteral(beg_loc, scanner().location().end_pos, &ok); CheckOctalLiteral(beg_loc, scanner().location().end_pos, &ok);
} }
if (ok && harmony_block_scoping_) { if (ok && harmony_scoping_) {
CheckConflictingVarDeclarations(scope, &ok); CheckConflictingVarDeclarations(scope, &ok);
} }
...@@ -817,9 +817,9 @@ void Parser::ReportMessageAt(Scanner::Location source_location, ...@@ -817,9 +817,9 @@ void Parser::ReportMessageAt(Scanner::Location source_location,
isolate()->Throw(*result, &location); isolate()->Throw(*result, &location);
} }
void Parser::SetHarmonyBlockScoping(bool block_scoping) { void Parser::SetHarmonyScoping(bool block_scoping) {
scanner().SetHarmonyBlockScoping(block_scoping); scanner().SetHarmonyScoping(block_scoping);
harmony_block_scoping_ = block_scoping; harmony_scoping_ = block_scoping;
} }
// Base class containing common code for the different finder classes used by // Base class containing common code for the different finder classes used by
...@@ -1390,7 +1390,7 @@ VariableProxy* Parser::Declare(Handle<String> name, ...@@ -1390,7 +1390,7 @@ VariableProxy* Parser::Declare(Handle<String> name,
ASSERT(var->mode() == VAR || ASSERT(var->mode() == VAR ||
var->mode() == CONST || var->mode() == CONST ||
var->mode() == LET); var->mode() == LET);
if (harmony_block_scoping_) { if (harmony_scoping_) {
// In harmony mode we treat re-declarations as early errors. See // In harmony mode we treat re-declarations as early errors. See
// ES5 16 for a definition of early errors. // ES5 16 for a definition of early errors.
SmartArrayPointer<char> c_string = name->ToCString(DISALLOW_NULLS); SmartArrayPointer<char> c_string = name->ToCString(DISALLOW_NULLS);
...@@ -1542,14 +1542,14 @@ Statement* Parser::ParseFunctionDeclaration(bool* ok) { ...@@ -1542,14 +1542,14 @@ Statement* Parser::ParseFunctionDeclaration(bool* ok) {
// Even if we're not at the top-level of the global or a function // Even if we're not at the top-level of the global or a function
// scope, we treat is as such and introduce the function with it's // scope, we treat is as such and introduce the function with it's
// initial value upon entering the corresponding scope. // initial value upon entering the corresponding scope.
VariableMode mode = harmony_block_scoping_ ? LET : VAR; VariableMode mode = harmony_scoping_ ? LET : VAR;
Declare(name, mode, fun, true, CHECK_OK); Declare(name, mode, fun, true, CHECK_OK);
return EmptyStatement(); return EmptyStatement();
} }
Block* Parser::ParseBlock(ZoneStringList* labels, bool* ok) { Block* Parser::ParseBlock(ZoneStringList* labels, bool* ok) {
if (harmony_block_scoping_) return ParseScopedBlock(labels, ok); if (harmony_scoping_) return ParseScopedBlock(labels, ok);
// Block :: // Block ::
// '{' Statement* '}' // '{' Statement* '}'
...@@ -2249,7 +2249,7 @@ TryStatement* Parser::ParseTryStatement(bool* ok) { ...@@ -2249,7 +2249,7 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
if (top_scope_->is_strict_mode()) { if (top_scope_->is_strict_mode()) {
catch_scope->EnableStrictMode(); catch_scope->EnableStrictMode();
} }
VariableMode mode = harmony_block_scoping_ ? LET : VAR; VariableMode mode = harmony_scoping_ ? LET : VAR;
catch_variable = catch_scope->DeclareLocal(name, mode); catch_variable = catch_scope->DeclareLocal(name, mode);
Scope* saved_scope = top_scope_; Scope* saved_scope = top_scope_;
...@@ -3714,8 +3714,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name, ...@@ -3714,8 +3714,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name,
// Function declarations are function scoped in normal mode, so they are // Function declarations are function scoped in normal mode, so they are
// hoisted. In harmony block scoping mode they are block scoped, so they // hoisted. In harmony block scoping mode they are block scoped, so they
// are not hoisted. // are not hoisted.
Scope* scope = (type == FunctionLiteral::DECLARATION && Scope* scope = (type == FunctionLiteral::DECLARATION && !harmony_scoping_)
!harmony_block_scoping_)
? NewScope(top_scope_->DeclarationScope(), Scope::FUNCTION_SCOPE, false) ? NewScope(top_scope_->DeclarationScope(), Scope::FUNCTION_SCOPE, false)
: NewScope(top_scope_, Scope::FUNCTION_SCOPE, inside_with()); : NewScope(top_scope_, Scope::FUNCTION_SCOPE, inside_with());
ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(8); ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(8);
...@@ -3757,8 +3756,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name, ...@@ -3757,8 +3756,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name,
reserved_loc = scanner().location(); reserved_loc = scanner().location();
} }
top_scope_->DeclareParameter(param_name, top_scope_->DeclareParameter(param_name, harmony_scoping_ ? LET : VAR);
harmony_block_scoping_ ? LET : VAR);
num_parameters++; num_parameters++;
if (num_parameters > kMaxNumFunctionParameters) { if (num_parameters > kMaxNumFunctionParameters) {
ReportMessageAt(scanner().location(), "too_many_parameters", ReportMessageAt(scanner().location(), "too_many_parameters",
...@@ -3885,7 +3883,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name, ...@@ -3885,7 +3883,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name,
} }
} }
if (harmony_block_scoping_) { if (harmony_scoping_) {
CheckConflictingVarDeclarations(scope, CHECK_OK); CheckConflictingVarDeclarations(scope, CHECK_OK);
} }
...@@ -5123,10 +5121,10 @@ int ScriptDataImpl::ReadNumber(byte** source) { ...@@ -5123,10 +5121,10 @@ int ScriptDataImpl::ReadNumber(byte** source) {
static ScriptDataImpl* DoPreParse(UC16CharacterStream* source, static ScriptDataImpl* DoPreParse(UC16CharacterStream* source,
bool allow_lazy, bool allow_lazy,
ParserRecorder* recorder, ParserRecorder* recorder,
bool harmony_block_scoping) { bool harmony_scoping) {
Isolate* isolate = Isolate::Current(); Isolate* isolate = Isolate::Current();
JavaScriptScanner scanner(isolate->unicode_cache()); JavaScriptScanner scanner(isolate->unicode_cache());
scanner.SetHarmonyBlockScoping(harmony_block_scoping); scanner.SetHarmonyScoping(harmony_scoping);
scanner.Initialize(source); scanner.Initialize(source);
intptr_t stack_limit = isolate->stack_guard()->real_climit(); intptr_t stack_limit = isolate->stack_guard()->real_climit();
if (!preparser::PreParser::PreParseProgram(&scanner, if (!preparser::PreParser::PreParseProgram(&scanner,
...@@ -5148,7 +5146,7 @@ static ScriptDataImpl* DoPreParse(UC16CharacterStream* source, ...@@ -5148,7 +5146,7 @@ static ScriptDataImpl* DoPreParse(UC16CharacterStream* source,
// even if the preparser data is only used once. // even if the preparser data is only used once.
ScriptDataImpl* ParserApi::PartialPreParse(UC16CharacterStream* source, ScriptDataImpl* ParserApi::PartialPreParse(UC16CharacterStream* source,
v8::Extension* extension, v8::Extension* extension,
bool harmony_block_scoping) { bool harmony_scoping) {
bool allow_lazy = FLAG_lazy && (extension == NULL); bool allow_lazy = FLAG_lazy && (extension == NULL);
if (!allow_lazy) { if (!allow_lazy) {
// Partial preparsing is only about lazily compiled functions. // Partial preparsing is only about lazily compiled functions.
...@@ -5156,17 +5154,17 @@ ScriptDataImpl* ParserApi::PartialPreParse(UC16CharacterStream* source, ...@@ -5156,17 +5154,17 @@ ScriptDataImpl* ParserApi::PartialPreParse(UC16CharacterStream* source,
return NULL; return NULL;
} }
PartialParserRecorder recorder; PartialParserRecorder recorder;
return DoPreParse(source, allow_lazy, &recorder, harmony_block_scoping); return DoPreParse(source, allow_lazy, &recorder, harmony_scoping);
} }
ScriptDataImpl* ParserApi::PreParse(UC16CharacterStream* source, ScriptDataImpl* ParserApi::PreParse(UC16CharacterStream* source,
v8::Extension* extension, v8::Extension* extension,
bool harmony_block_scoping) { bool harmony_scoping) {
Handle<Script> no_script; Handle<Script> no_script;
bool allow_lazy = FLAG_lazy && (extension == NULL); bool allow_lazy = FLAG_lazy && (extension == NULL);
CompleteParserRecorder recorder; CompleteParserRecorder recorder;
return DoPreParse(source, allow_lazy, &recorder, harmony_block_scoping); return DoPreParse(source, allow_lazy, &recorder, harmony_scoping);
} }
...@@ -5196,11 +5194,10 @@ bool ParserApi::Parse(CompilationInfo* info) { ...@@ -5196,11 +5194,10 @@ bool ParserApi::Parse(CompilationInfo* info) {
ASSERT(info->function() == NULL); ASSERT(info->function() == NULL);
FunctionLiteral* result = NULL; FunctionLiteral* result = NULL;
Handle<Script> script = info->script(); Handle<Script> script = info->script();
bool harmony_block_scoping = !info->is_native() && bool harmony_scoping = !info->is_native() && FLAG_harmony_scoping;
FLAG_harmony_block_scoping;
if (info->is_lazy()) { if (info->is_lazy()) {
Parser parser(script, true, NULL, NULL); Parser parser(script, true, NULL, NULL);
parser.SetHarmonyBlockScoping(harmony_block_scoping); parser.SetHarmonyScoping(harmony_scoping);
result = parser.ParseLazy(info); result = parser.ParseLazy(info);
} else { } else {
// Whether we allow %identifier(..) syntax. // Whether we allow %identifier(..) syntax.
...@@ -5211,7 +5208,7 @@ bool ParserApi::Parse(CompilationInfo* info) { ...@@ -5211,7 +5208,7 @@ bool ParserApi::Parse(CompilationInfo* info) {
allow_natives_syntax, allow_natives_syntax,
info->extension(), info->extension(),
pre_data); pre_data);
parser.SetHarmonyBlockScoping(harmony_block_scoping); parser.SetHarmonyScoping(harmony_scoping);
if (pre_data != NULL && pre_data->has_error()) { if (pre_data != NULL && pre_data->has_error()) {
Scanner::Location loc = pre_data->MessageLocation(); Scanner::Location loc = pre_data->MessageLocation();
const char* message = pre_data->BuildMessage(); const char* message = pre_data->BuildMessage();
......
...@@ -164,13 +164,13 @@ class ParserApi { ...@@ -164,13 +164,13 @@ class ParserApi {
// Generic preparser generating full preparse data. // Generic preparser generating full preparse data.
static ScriptDataImpl* PreParse(UC16CharacterStream* source, static ScriptDataImpl* PreParse(UC16CharacterStream* source,
v8::Extension* extension, v8::Extension* extension,
bool harmony_block_scoping); bool harmony_scoping);
// Preparser that only does preprocessing that makes sense if only used // Preparser that only does preprocessing that makes sense if only used
// immediately after. // immediately after.
static ScriptDataImpl* PartialPreParse(UC16CharacterStream* source, static ScriptDataImpl* PartialPreParse(UC16CharacterStream* source,
v8::Extension* extension, v8::Extension* extension,
bool harmony_block_scoping); bool harmony_scoping);
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
...@@ -436,7 +436,7 @@ class Parser { ...@@ -436,7 +436,7 @@ class Parser {
void ReportMessageAt(Scanner::Location loc, void ReportMessageAt(Scanner::Location loc,
const char* message, const char* message,
Vector<Handle<String> > args); Vector<Handle<String> > args);
void SetHarmonyBlockScoping(bool block_scoping); void SetHarmonyScoping(bool block_scoping);
private: private:
// Limit on number of function parameters is chosen arbitrarily. // Limit on number of function parameters is chosen arbitrarily.
...@@ -731,7 +731,7 @@ class Parser { ...@@ -731,7 +731,7 @@ class Parser {
// Heuristically that means that the function will be called immediately, // Heuristically that means that the function will be called immediately,
// so never lazily compile it. // so never lazily compile it.
bool parenthesized_function_; bool parenthesized_function_;
bool harmony_block_scoping_; bool harmony_scoping_;
friend class LexicalScope; friend class LexicalScope;
}; };
......
...@@ -293,7 +293,7 @@ PreParser::Statement PreParser::ParseBlock(bool* ok) { ...@@ -293,7 +293,7 @@ PreParser::Statement PreParser::ParseBlock(bool* ok) {
// //
Expect(i::Token::LBRACE, CHECK_OK); Expect(i::Token::LBRACE, CHECK_OK);
while (peek() != i::Token::RBRACE) { while (peek() != i::Token::RBRACE) {
if (harmony_block_scoping_) { if (harmony_scoping_) {
ParseSourceElement(CHECK_OK); ParseSourceElement(CHECK_OK);
} else { } else {
ParseStatement(CHECK_OK); ParseStatement(CHECK_OK);
......
...@@ -447,7 +447,7 @@ class PreParser { ...@@ -447,7 +447,7 @@ class PreParser {
stack_overflow_(false), stack_overflow_(false),
allow_lazy_(true), allow_lazy_(true),
parenthesized_function_(false), parenthesized_function_(false),
harmony_block_scoping_(scanner->HarmonyBlockScoping()) { } harmony_scoping_(scanner->HarmonyScoping()) { }
// Preparse the program. Only called in PreParseProgram after creating // Preparse the program. Only called in PreParseProgram after creating
// the instance. // the instance.
...@@ -608,7 +608,7 @@ class PreParser { ...@@ -608,7 +608,7 @@ class PreParser {
bool stack_overflow_; bool stack_overflow_;
bool allow_lazy_; bool allow_lazy_;
bool parenthesized_function_; bool parenthesized_function_;
bool harmony_block_scoping_; bool harmony_scoping_;
}; };
} } // v8::preparser } } // v8::preparser
......
...@@ -95,7 +95,7 @@ uc32 Scanner::ScanHexNumber(int expected_length) { ...@@ -95,7 +95,7 @@ uc32 Scanner::ScanHexNumber(int expected_length) {
JavaScriptScanner::JavaScriptScanner(UnicodeCache* scanner_contants) JavaScriptScanner::JavaScriptScanner(UnicodeCache* scanner_contants)
: Scanner(scanner_contants), : Scanner(scanner_contants),
octal_pos_(Location::invalid()), octal_pos_(Location::invalid()),
harmony_block_scoping_(false) { } harmony_scoping_(false) { }
void JavaScriptScanner::Initialize(UC16CharacterStream* source) { void JavaScriptScanner::Initialize(UC16CharacterStream* source) {
...@@ -872,7 +872,7 @@ uc32 JavaScriptScanner::ScanIdentifierUnicodeEscape() { ...@@ -872,7 +872,7 @@ uc32 JavaScriptScanner::ScanIdentifierUnicodeEscape() {
KEYWORD("instanceof", Token::INSTANCEOF) \ KEYWORD("instanceof", Token::INSTANCEOF) \
KEYWORD("interface", Token::FUTURE_STRICT_RESERVED_WORD) \ KEYWORD("interface", Token::FUTURE_STRICT_RESERVED_WORD) \
KEYWORD_GROUP('l') \ KEYWORD_GROUP('l') \
KEYWORD("let", harmony_block_scoping \ KEYWORD("let", harmony_scoping \
? Token::LET : Token::FUTURE_STRICT_RESERVED_WORD) \ ? Token::LET : Token::FUTURE_STRICT_RESERVED_WORD) \
KEYWORD_GROUP('n') \ KEYWORD_GROUP('n') \
KEYWORD("new", Token::NEW) \ KEYWORD("new", Token::NEW) \
...@@ -906,7 +906,7 @@ uc32 JavaScriptScanner::ScanIdentifierUnicodeEscape() { ...@@ -906,7 +906,7 @@ uc32 JavaScriptScanner::ScanIdentifierUnicodeEscape() {
static Token::Value KeywordOrIdentifierToken(const char* input, static Token::Value KeywordOrIdentifierToken(const char* input,
int input_length, int input_length,
bool harmony_block_scoping) { bool harmony_scoping) {
ASSERT(input_length >= 1); ASSERT(input_length >= 1);
const int kMinLength = 2; const int kMinLength = 2;
const int kMaxLength = 10; const int kMaxLength = 10;
...@@ -982,7 +982,7 @@ Token::Value JavaScriptScanner::ScanIdentifierOrKeyword() { ...@@ -982,7 +982,7 @@ Token::Value JavaScriptScanner::ScanIdentifierOrKeyword() {
Vector<const char> chars = next_.literal_chars->ascii_literal(); Vector<const char> chars = next_.literal_chars->ascii_literal();
return KeywordOrIdentifierToken(chars.start(), return KeywordOrIdentifierToken(chars.start(),
chars.length(), chars.length(),
harmony_block_scoping_); harmony_scoping_);
} }
return Token::IDENTIFIER; return Token::IDENTIFIER;
......
...@@ -509,11 +509,11 @@ class JavaScriptScanner : public Scanner { ...@@ -509,11 +509,11 @@ class JavaScriptScanner : public Scanner {
// tokens, which is what it is used for. // tokens, which is what it is used for.
void SeekForward(int pos); void SeekForward(int pos);
bool HarmonyBlockScoping() const { bool HarmonyScoping() const {
return harmony_block_scoping_; return harmony_scoping_;
} }
void SetHarmonyBlockScoping(bool block_scoping) { void SetHarmonyScoping(bool block_scoping) {
harmony_block_scoping_ = block_scoping; harmony_scoping_ = block_scoping;
} }
...@@ -556,7 +556,7 @@ class JavaScriptScanner : public Scanner { ...@@ -556,7 +556,7 @@ class JavaScriptScanner : public Scanner {
bool has_multiline_comment_before_next_; bool has_multiline_comment_before_next_;
// Whether we scan 'let' as a keyword for harmony block scoped // Whether we scan 'let' as a keyword for harmony block scoped
// let bindings. // let bindings.
bool harmony_block_scoping_; bool harmony_scoping_;
}; };
} } // namespace v8::internal } } // namespace v8::internal
......
...@@ -57,6 +57,15 @@ static EntropySource entropy_source; ...@@ -57,6 +57,15 @@ static EntropySource entropy_source;
bool V8::Initialize(Deserializer* des) { bool V8::Initialize(Deserializer* des) {
// Setting --harmony implies all other harmony flags.
// TODO(rossberg): Is there a better place to put this?
if (FLAG_harmony) {
FLAG_harmony_typeof = true;
FLAG_harmony_scoping = true;
FLAG_harmony_proxies = true;
FLAG_harmony_weakmaps = true;
}
InitializeOncePerProcess(); InitializeOncePerProcess();
// The current thread may not yet had entered an isolate to run. // The current thread may not yet had entered an isolate to run.
......
...@@ -2029,10 +2029,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag, ...@@ -2029,10 +2029,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag,
// Push the strict mode flag. In harmony mode every eval call // Push the strict mode flag. In harmony mode every eval call
// is a strict mode eval call. // is a strict mode eval call.
StrictModeFlag strict_mode = strict_mode_flag(); StrictModeFlag strict_mode =
if (FLAG_harmony_block_scoping) { FLAG_harmony_scoping ? kStrictMode : strict_mode_flag();
strict_mode = kStrictMode;
}
__ Push(Smi::FromInt(strict_mode)); __ Push(Smi::FromInt(strict_mode));
__ CallRuntime(flag == SKIP_CONTEXT_LOOKUP __ CallRuntime(flag == SKIP_CONTEXT_LOOKUP
......
...@@ -65,7 +65,7 @@ TEST(ScanKeywords) { ...@@ -65,7 +65,7 @@ TEST(ScanKeywords) {
i::Utf8ToUC16CharacterStream stream(keyword, length); i::Utf8ToUC16CharacterStream stream(keyword, length);
i::JavaScriptScanner scanner(&unicode_cache); i::JavaScriptScanner scanner(&unicode_cache);
// The scanner should parse 'let' as Token::LET for this test. // The scanner should parse 'let' as Token::LET for this test.
scanner.SetHarmonyBlockScoping(true); scanner.SetHarmonyScoping(true);
scanner.Initialize(&stream); scanner.Initialize(&stream);
CHECK_EQ(key_token.token, scanner.Next()); CHECK_EQ(key_token.token, scanner.Next());
CHECK_EQ(i::Token::EOS, scanner.Next()); CHECK_EQ(i::Token::EOS, scanner.Next());
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug --harmony-block-scoping // Flags: --expose-debug-as debug --harmony-scoping
// The functions used for testing backtraces. They are at the top to make the // The functions used for testing backtraces. They are at the top to make the
// testing of source line/column easier. // testing of source line/column easier.
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony-block-scoping // Flags: --harmony-scoping
// Test for conflicting variable bindings. // Test for conflicting variable bindings.
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony-block-scoping // Flags: --harmony-scoping
// We want to test the context chain shape. In each of the tests cases // We want to test the context chain shape. In each of the tests cases
// below, the outer with is to force a runtime lookup of the identifier 'x' // below, the outer with is to force a runtime lookup of the identifier 'x'
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony-block-scoping --allow-natives-syntax // Flags: --harmony-scoping --allow-natives-syntax
// Test that temporal dead zone semantics for function and block scoped // Test that temporal dead zone semantics for function and block scoped
// ket bindings are handled by the optimizing compiler. // ket bindings are handled by the optimizing compiler.
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony-block-scoping // Flags: --harmony-scoping
// Test let declarations in various settings. // Test let declarations in various settings.
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony-block-scoping // Flags: --harmony-scoping
// Test temporal dead zone semantics of let bound variables in // Test temporal dead zone semantics of let bound variables in
// function and block scopes. // function and block scopes.
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --harmony-block-scoping // Flags: --allow-natives-syntax --harmony-scoping
// Test functionality of block scopes. // Test functionality of block scopes.
// Hoisting of var declarations. // Hoisting of var declarations.
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug --harmony-block-scoping // Flags: --expose-debug-as debug --harmony-scoping
// The functions used for testing backtraces. They are at the top to make the // The functions used for testing backtraces. They are at the top to make the
// testing of source line/column easier. // testing of source line/column easier.
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug --harmony-block-scoping // Flags: --expose-debug-as debug --harmony-scoping
// Test debug evaluation for functions without local context, but with // Test debug evaluation for functions without local context, but with
// nested catch contexts. // nested catch contexts.
......
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