Index: runtime/vm/parser.cc |
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc |
index b41e0ef5c0577a0bb89730950c03d8c667f7239f..a4c7558dd8818b1d8334208eb1142bb2bacfc345 100644 |
--- a/runtime/vm/parser.cc |
+++ b/runtime/vm/parser.cc |
@@ -244,6 +244,7 @@ LocalVariable* ParsedFunction::EnsureExpressionTemp() { |
if (!has_expression_temp_var()) { |
LocalVariable* temp = |
new (Z) LocalVariable(function_.token_pos(), |
+ function_.token_pos(), |
Symbols::ExprTemp(), |
Object::dynamic_type()); |
ASSERT(temp != NULL); |
@@ -258,6 +259,7 @@ void ParsedFunction::EnsureFinallyReturnTemp(bool is_async) { |
if (!has_finally_return_temp_var()) { |
LocalVariable* temp = new(Z) LocalVariable( |
function_.token_pos(), |
+ function_.token_pos(), |
Symbols::FinallyRetVal(), |
Object::dynamic_type()); |
ASSERT(temp != NULL); |
@@ -3138,6 +3140,7 @@ SequenceNode* Parser::MakeImplicitConstructor(const Function& func) { |
LocalVariable* receiver = new LocalVariable( |
TokenPosition::kNoSource, |
+ TokenPosition::kNoSource, |
Symbols::This(), |
*ReceiverType(current_class())); |
current_block_->scope->InsertParameterAt(0, receiver); |
@@ -3186,6 +3189,7 @@ SequenceNode* Parser::MakeImplicitConstructor(const Function& func) { |
for (int i = 1; i < func.NumParameters(); i++) { |
LocalVariable* param = new LocalVariable( |
TokenPosition::kNoSource, |
+ TokenPosition::kNoSource, |
String::ZoneHandle(Z, func.ParameterNameAt(i)), |
Object::dynamic_type()); |
current_block_->scope->InsertParameterAt(i, param); |
@@ -7102,11 +7106,13 @@ void Parser::AddContinuationVariables() { |
// var :await_ctx_var; |
LocalVariable* await_jump_var = new (Z) LocalVariable( |
TokenPosition::kNoSource, |
+ TokenPosition::kNoSource, |
Symbols::AwaitJumpVar(), |
Object::dynamic_type()); |
current_block_->scope->AddVariable(await_jump_var); |
LocalVariable* await_ctx_var = new (Z) LocalVariable( |
TokenPosition::kNoSource, |
+ TokenPosition::kNoSource, |
Symbols::AwaitContextVar(), |
Object::dynamic_type()); |
current_block_->scope->AddVariable(await_ctx_var); |
@@ -7121,21 +7127,25 @@ void Parser::AddAsyncClosureVariables() { |
// var :async_completer; |
LocalVariable* async_op_var = new(Z) LocalVariable( |
TokenPosition::kNoSource, |
+ TokenPosition::kNoSource, |
Symbols::AsyncOperation(), |
Object::dynamic_type()); |
current_block_->scope->AddVariable(async_op_var); |
LocalVariable* async_then_callback_var = new(Z) LocalVariable( |
TokenPosition::kNoSource, |
+ TokenPosition::kNoSource, |
Symbols::AsyncThenCallback(), |
Object::dynamic_type()); |
current_block_->scope->AddVariable(async_then_callback_var); |
LocalVariable* async_catch_error_callback_var = new(Z) LocalVariable( |
TokenPosition::kNoSource, |
+ TokenPosition::kNoSource, |
Symbols::AsyncCatchErrorCallback(), |
Object::dynamic_type()); |
current_block_->scope->AddVariable(async_catch_error_callback_var); |
LocalVariable* async_completer = new(Z) LocalVariable( |
TokenPosition::kNoSource, |
+ TokenPosition::kNoSource, |
Symbols::AsyncCompleter(), |
Object::dynamic_type()); |
current_block_->scope->AddVariable(async_completer); |
@@ -7155,21 +7165,25 @@ void Parser::AddAsyncGeneratorVariables() { |
// the body of the async* function. They are used by the await operator. |
LocalVariable* controller_var = new(Z) LocalVariable( |
TokenPosition::kNoSource, |
+ TokenPosition::kNoSource, |
Symbols::Controller(), |
Object::dynamic_type()); |
current_block_->scope->AddVariable(controller_var); |
LocalVariable* async_op_var = new(Z) LocalVariable( |
TokenPosition::kNoSource, |
+ TokenPosition::kNoSource, |
Symbols::AsyncOperation(), |
Object::dynamic_type()); |
current_block_->scope->AddVariable(async_op_var); |
LocalVariable* async_then_callback_var = new(Z) LocalVariable( |
TokenPosition::kNoSource, |
+ TokenPosition::kNoSource, |
Symbols::AsyncThenCallback(), |
Object::dynamic_type()); |
current_block_->scope->AddVariable(async_then_callback_var); |
LocalVariable* async_catch_error_callback_var = new(Z) LocalVariable( |
TokenPosition::kNoSource, |
+ TokenPosition::kNoSource, |
Symbols::AsyncCatchErrorCallback(), |
Object::dynamic_type()); |
current_block_->scope->AddVariable(async_catch_error_callback_var); |
@@ -7658,7 +7672,10 @@ void Parser::AddFormalParamsToScope(const ParamList* params, |
ASSERT(!is_top_level_ || param_desc.type->IsResolved()); |
const String* name = param_desc.name; |
LocalVariable* parameter = new(Z) LocalVariable( |
- param_desc.name_pos, *name, *param_desc.type); |
+ param_desc.name_pos, |
+ param_desc.name_pos, |
+ *name, |
+ *param_desc.type); |
if (!scope->InsertParameterAt(i, parameter)) { |
ReportError(param_desc.name_pos, |
"name '%s' already exists in scope", |
@@ -7770,7 +7787,10 @@ AstNode* Parser::ParseVariableDeclaration(const AbstractType& type, |
is_const, kConsumeCascades, await_preamble); |
const TokenPosition expr_end_pos = TokenPos(); |
variable = new(Z) LocalVariable( |
- expr_end_pos, ident, type); |
+ ident_pos, |
+ expr_end_pos, |
+ ident, |
+ type); |
initialization = new(Z) StoreLocalNode( |
assign_pos, variable, expr); |
if (is_const) { |
@@ -7783,7 +7803,10 @@ AstNode* Parser::ParseVariableDeclaration(const AbstractType& type, |
} else { |
// Initialize variable with null. |
variable = new(Z) LocalVariable( |
- assign_pos, ident, type); |
+ ident_pos, |
+ assign_pos, |
+ ident, |
+ type); |
AstNode* null_expr = new(Z) LiteralNode(ident_pos, Object::null_instance()); |
initialization = new(Z) StoreLocalNode( |
ident_pos, variable, null_expr); |
@@ -7920,6 +7943,7 @@ AstNode* Parser::ParseFunctionStatement(bool is_literal) { |
result_type = Type::DynamicType(); |
const TokenPosition function_pos = TokenPos(); |
+ TokenPosition function_name_pos = TokenPosition::kNoSource; |
TokenPosition metadata_pos = TokenPosition::kNoSource; |
if (is_literal) { |
ASSERT(CurrentToken() == Token::kLPAREN || CurrentToken() == Token::kLT); |
@@ -7934,7 +7958,7 @@ AstNode* Parser::ParseFunctionStatement(bool is_literal) { |
// referring to a not yet declared function type parameter. |
result_type = ParseType(ClassFinalizer::kDoNotResolve); |
} |
- const TokenPosition name_pos = TokenPos(); |
+ function_name_pos = TokenPos(); |
variable_name = ExpectIdentifier("function name expected"); |
function_name = variable_name; |
@@ -7947,7 +7971,7 @@ AstNode* Parser::ParseFunctionStatement(bool is_literal) { |
ASSERT(!script_.IsNull()); |
intptr_t line_number; |
script_.GetTokenLocation(previous_pos, &line_number, NULL); |
- ReportError(name_pos, |
+ ReportError(function_name_pos, |
"identifier '%s' previously used in line %" Pd "", |
function_name->ToCString(), |
line_number); |
@@ -8026,7 +8050,8 @@ AstNode* Parser::ParseFunctionStatement(bool is_literal) { |
// Add the function variable to the scope before parsing the function in |
// order to allow self reference from inside the function. |
- function_variable = new(Z) LocalVariable(function_pos, |
+ function_variable = new(Z) LocalVariable(function_name_pos, |
+ function_pos, |
*variable_name, |
function_type); |
function_variable->set_is_final(); |
@@ -8838,7 +8863,7 @@ AstNode* Parser::ParseSwitchStatement(String* label_name) { |
expr_pos)); |
temp_var_type.SetIsFinalized(); |
LocalVariable* temp_variable = new(Z) LocalVariable( |
- expr_pos, Symbols::SwitchExpr(), temp_var_type); |
+ expr_pos, expr_pos, Symbols::SwitchExpr(), temp_var_type); |
current_block_->scope->AddVariable(temp_variable); |
AstNode* save_switch_expr = new(Z) StoreLocalNode( |
expr_pos, temp_variable, switch_expr); |
@@ -9128,7 +9153,7 @@ AstNode* Parser::ParseAwaitForStatement(String* label_name) { |
ctor_args); |
const AbstractType& iterator_type = Object::dynamic_type(); |
LocalVariable* iterator_var = new(Z) LocalVariable( |
- stream_expr_pos, Symbols::ForInIter(), iterator_type); |
+ stream_expr_pos, stream_expr_pos, Symbols::ForInIter(), iterator_type); |
current_block_->scope->AddVariable(iterator_var); |
AstNode* iterator_init = |
new(Z) StoreLocalNode(stream_expr_pos, iterator_var, ctor_call); |
@@ -9213,6 +9238,7 @@ AstNode* Parser::ParseAwaitForStatement(String* label_name) { |
// loop block, so it gets put in the loop context level. |
LocalVariable* loop_var = |
new(Z) LocalVariable(loop_var_assignment_pos, |
+ loop_var_assignment_pos, |
*loop_var_name, |
loop_var_type);; |
if (loop_var_is_final) { |
@@ -9388,6 +9414,7 @@ AstNode* Parser::ParseForInStatement(TokenPosition forin_pos, |
loop_var_type = ParseConstFinalVarOrType( |
I->type_checks() ? ClassFinalizer::kCanonicalize : |
ClassFinalizer::kIgnore); |
+ loop_var_pos = TokenPos(); |
loop_var_name = ExpectIdentifier("variable name expected"); |
} |
ExpectToken(Token::kIN); |
@@ -9411,6 +9438,7 @@ AstNode* Parser::ParseForInStatement(TokenPosition forin_pos, |
// until the loop variable is assigned to. |
const AbstractType& iterator_type = Object::dynamic_type(); |
LocalVariable* iterator_var = new(Z) LocalVariable( |
+ collection_pos, |
collection_pos, Symbols::ForInIter(), iterator_type); |
current_block_->scope->AddVariable(iterator_var); |
@@ -9448,7 +9476,8 @@ AstNode* Parser::ParseForInStatement(TokenPosition forin_pos, |
// The for loop variable is new for each iteration. |
// Create a variable and add it to the loop body scope. |
LocalVariable* loop_var = |
- new(Z) LocalVariable(loop_var_assignment_pos, |
+ new(Z) LocalVariable(loop_var_pos, |
+ loop_var_assignment_pos, |
*loop_var_name, |
loop_var_type);; |
if (loop_var_is_final) { |
@@ -9615,6 +9644,7 @@ void Parser::AddCatchParamsToScope(CatchParamDesc* exception_param, |
if (exception_param->name != NULL) { |
LocalVariable* var = new(Z) LocalVariable( |
exception_param->token_pos, |
+ exception_param->token_pos, |
*exception_param->name, |
*exception_param->type); |
var->set_is_final(); |
@@ -9625,6 +9655,7 @@ void Parser::AddCatchParamsToScope(CatchParamDesc* exception_param, |
if (stack_trace_param->name != NULL) { |
LocalVariable* var = new(Z) LocalVariable( |
stack_trace_param->token_pos, |
+ stack_trace_param->token_pos, |
*stack_trace_param->name, |
*stack_trace_param->type); |
var->set_is_final(); |
@@ -10034,6 +10065,7 @@ void Parser::SetupSavedTryContext(LocalVariable* saved_try_context) { |
last_used_try_index_ - 1)); |
LocalVariable* async_saved_try_ctx = new (Z) LocalVariable( |
TokenPosition::kNoSource, |
+ TokenPosition::kNoSource, |
async_saved_try_ctx_name, |
Object::dynamic_type()); |
ASSERT(async_temp_scope_ != NULL); |
@@ -10075,6 +10107,7 @@ void Parser::SetupExceptionVariables(LocalScope* try_scope, |
if (*context_var == NULL) { |
*context_var = new(Z) LocalVariable( |
TokenPos(), |
+ TokenPos(), |
Symbols::SavedTryContextVar(), |
Object::dynamic_type()); |
try_scope->AddVariable(*context_var); |
@@ -10083,6 +10116,7 @@ void Parser::SetupExceptionVariables(LocalScope* try_scope, |
if (*exception_var == NULL) { |
*exception_var = new(Z) LocalVariable( |
TokenPos(), |
+ TokenPos(), |
Symbols::ExceptionVar(), |
Object::dynamic_type()); |
try_scope->AddVariable(*exception_var); |
@@ -10091,6 +10125,7 @@ void Parser::SetupExceptionVariables(LocalScope* try_scope, |
if (*stack_trace_var == NULL) { |
*stack_trace_var = new(Z) LocalVariable( |
TokenPos(), |
+ TokenPos(), |
Symbols::StackTraceVar(), |
Object::dynamic_type()); |
try_scope->AddVariable(*stack_trace_var); |
@@ -10101,6 +10136,7 @@ void Parser::SetupExceptionVariables(LocalScope* try_scope, |
if (*saved_exception_var == NULL) { |
*saved_exception_var = new(Z) LocalVariable( |
TokenPos(), |
+ TokenPos(), |
Symbols::SavedExceptionVar(), |
Object::dynamic_type()); |
try_scope->AddVariable(*saved_exception_var); |
@@ -10110,6 +10146,7 @@ void Parser::SetupExceptionVariables(LocalScope* try_scope, |
if (*saved_stack_trace_var == NULL) { |
*saved_stack_trace_var = new(Z) LocalVariable( |
TokenPos(), |
+ TokenPos(), |
Symbols::SavedStackTraceVar(), |
Object::dynamic_type()); |
try_scope->AddVariable(*saved_stack_trace_var); |
@@ -11090,6 +11127,7 @@ LocalVariable* Parser::CreateTempConstVariable(TokenPosition token_pos, |
OS::SNPrint(name, 64, ":%s%" Pd "", s, token_pos.value()); |
LocalVariable* temp = new(Z) LocalVariable( |
token_pos, |
+ token_pos, |
String::ZoneHandle(Z, Symbols::New(T, name)), |
Object::dynamic_type()); |
temp->set_is_final(); |