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

Side by Side Diff: runtime/vm/parser.cc

Issue 2419013004: Add local variable declaration token position to service protocol (Closed)
Patch Set: ... Created 4 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
« no previous file with comments | « runtime/vm/parser.h ('k') | runtime/vm/raw_object.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/parser.h" 5 #include "vm/parser.h"
6 #include "vm/flags.h" 6 #include "vm/flags.h"
7 7
8 #ifndef DART_PRECOMPILED_RUNTIME 8 #ifndef DART_PRECOMPILED_RUNTIME
9 9
10 #include "lib/invocation_mirror.h" 10 #include "lib/invocation_mirror.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 kernel_scopes_ = builder.BuildScopes(); 237 kernel_scopes_ = builder.BuildScopes();
238 } 238 }
239 return kernel_scopes_; 239 return kernel_scopes_;
240 } 240 }
241 241
242 242
243 LocalVariable* ParsedFunction::EnsureExpressionTemp() { 243 LocalVariable* ParsedFunction::EnsureExpressionTemp() {
244 if (!has_expression_temp_var()) { 244 if (!has_expression_temp_var()) {
245 LocalVariable* temp = 245 LocalVariable* temp =
246 new (Z) LocalVariable(function_.token_pos(), 246 new (Z) LocalVariable(function_.token_pos(),
247 function_.token_pos(),
247 Symbols::ExprTemp(), 248 Symbols::ExprTemp(),
248 Object::dynamic_type()); 249 Object::dynamic_type());
249 ASSERT(temp != NULL); 250 ASSERT(temp != NULL);
250 set_expression_temp_var(temp); 251 set_expression_temp_var(temp);
251 } 252 }
252 ASSERT(has_expression_temp_var()); 253 ASSERT(has_expression_temp_var());
253 return expression_temp_var(); 254 return expression_temp_var();
254 } 255 }
255 256
256 257
257 void ParsedFunction::EnsureFinallyReturnTemp(bool is_async) { 258 void ParsedFunction::EnsureFinallyReturnTemp(bool is_async) {
258 if (!has_finally_return_temp_var()) { 259 if (!has_finally_return_temp_var()) {
259 LocalVariable* temp = new(Z) LocalVariable( 260 LocalVariable* temp = new(Z) LocalVariable(
260 function_.token_pos(), 261 function_.token_pos(),
262 function_.token_pos(),
261 Symbols::FinallyRetVal(), 263 Symbols::FinallyRetVal(),
262 Object::dynamic_type()); 264 Object::dynamic_type());
263 ASSERT(temp != NULL); 265 ASSERT(temp != NULL);
264 temp->set_is_final(); 266 temp->set_is_final();
265 if (is_async) { 267 if (is_async) {
266 temp->set_is_captured(); 268 temp->set_is_captured();
267 } 269 }
268 set_finally_return_temp_var(temp); 270 set_finally_return_temp_var(temp);
269 } 271 }
270 ASSERT(has_finally_return_temp_var()); 272 ASSERT(has_finally_return_temp_var());
(...skipping 2860 matching lines...) Expand 10 before | Expand all | Expand 10 after
3131 3133
3132 3134
3133 SequenceNode* Parser::MakeImplicitConstructor(const Function& func) { 3135 SequenceNode* Parser::MakeImplicitConstructor(const Function& func) {
3134 ASSERT(func.IsGenerativeConstructor()); 3136 ASSERT(func.IsGenerativeConstructor());
3135 ASSERT(func.Owner() == current_class().raw()); 3137 ASSERT(func.Owner() == current_class().raw());
3136 const TokenPosition ctor_pos = TokenPos(); 3138 const TokenPosition ctor_pos = TokenPos();
3137 OpenFunctionBlock(func); 3139 OpenFunctionBlock(func);
3138 3140
3139 LocalVariable* receiver = new LocalVariable( 3141 LocalVariable* receiver = new LocalVariable(
3140 TokenPosition::kNoSource, 3142 TokenPosition::kNoSource,
3143 TokenPosition::kNoSource,
3141 Symbols::This(), 3144 Symbols::This(),
3142 *ReceiverType(current_class())); 3145 *ReceiverType(current_class()));
3143 current_block_->scope->InsertParameterAt(0, receiver); 3146 current_block_->scope->InsertParameterAt(0, receiver);
3144 3147
3145 // Parse expressions of instance fields that have an explicit 3148 // Parse expressions of instance fields that have an explicit
3146 // initializer expression. 3149 // initializer expression.
3147 // The receiver must not be visible to field initializer expressions. 3150 // The receiver must not be visible to field initializer expressions.
3148 receiver->set_invisible(true); 3151 receiver->set_invisible(true);
3149 GrowableArray<Field*> initialized_fields; 3152 GrowableArray<Field*> initialized_fields;
3150 ParseInitializedInstanceFields( 3153 ParseInitializedInstanceFields(
(...skipping 28 matching lines...) Expand all
3179 "constructor of the class extending the mixin application", 3182 "constructor of the class extending the mixin application",
3180 String::Handle(Z, super_class.Name()).ToCString()); 3183 String::Handle(Z, super_class.Name()).ToCString());
3181 } 3184 }
3182 3185
3183 // Prepare user-defined arguments to be forwarded to super call. 3186 // Prepare user-defined arguments to be forwarded to super call.
3184 // The first user-defined argument is at position 1. 3187 // The first user-defined argument is at position 1.
3185 forwarding_args = new ArgumentListNode(ST(ctor_pos)); 3188 forwarding_args = new ArgumentListNode(ST(ctor_pos));
3186 for (int i = 1; i < func.NumParameters(); i++) { 3189 for (int i = 1; i < func.NumParameters(); i++) {
3187 LocalVariable* param = new LocalVariable( 3190 LocalVariable* param = new LocalVariable(
3188 TokenPosition::kNoSource, 3191 TokenPosition::kNoSource,
3192 TokenPosition::kNoSource,
3189 String::ZoneHandle(Z, func.ParameterNameAt(i)), 3193 String::ZoneHandle(Z, func.ParameterNameAt(i)),
3190 Object::dynamic_type()); 3194 Object::dynamic_type());
3191 current_block_->scope->InsertParameterAt(i, param); 3195 current_block_->scope->InsertParameterAt(i, param);
3192 forwarding_args->Add(new LoadLocalNode(ST(ctor_pos), param)); 3196 forwarding_args->Add(new LoadLocalNode(ST(ctor_pos), param));
3193 } 3197 }
3194 } 3198 }
3195 3199
3196 AstNode* super_call = GenerateSuperConstructorCall( 3200 AstNode* super_call = GenerateSuperConstructorCall(
3197 current_class(), 3201 current_class(),
3198 ctor_pos, 3202 ctor_pos,
(...skipping 3896 matching lines...) Expand 10 before | Expand all | Expand 10 after
7095 return closure.raw(); 7099 return closure.raw();
7096 } 7100 }
7097 7101
7098 7102
7099 void Parser::AddContinuationVariables() { 7103 void Parser::AddContinuationVariables() {
7100 // Add to current block's scope: 7104 // Add to current block's scope:
7101 // var :await_jump_var; 7105 // var :await_jump_var;
7102 // var :await_ctx_var; 7106 // var :await_ctx_var;
7103 LocalVariable* await_jump_var = new (Z) LocalVariable( 7107 LocalVariable* await_jump_var = new (Z) LocalVariable(
7104 TokenPosition::kNoSource, 7108 TokenPosition::kNoSource,
7109 TokenPosition::kNoSource,
7105 Symbols::AwaitJumpVar(), 7110 Symbols::AwaitJumpVar(),
7106 Object::dynamic_type()); 7111 Object::dynamic_type());
7107 current_block_->scope->AddVariable(await_jump_var); 7112 current_block_->scope->AddVariable(await_jump_var);
7108 LocalVariable* await_ctx_var = new (Z) LocalVariable( 7113 LocalVariable* await_ctx_var = new (Z) LocalVariable(
7109 TokenPosition::kNoSource, 7114 TokenPosition::kNoSource,
7115 TokenPosition::kNoSource,
7110 Symbols::AwaitContextVar(), 7116 Symbols::AwaitContextVar(),
7111 Object::dynamic_type()); 7117 Object::dynamic_type());
7112 current_block_->scope->AddVariable(await_ctx_var); 7118 current_block_->scope->AddVariable(await_ctx_var);
7113 } 7119 }
7114 7120
7115 7121
7116 void Parser::AddAsyncClosureVariables() { 7122 void Parser::AddAsyncClosureVariables() {
7117 // Add to current block's scope: 7123 // Add to current block's scope:
7118 // var :async_op; 7124 // var :async_op;
7119 // var :async_then_callback; 7125 // var :async_then_callback;
7120 // var :async_catch_error_callback; 7126 // var :async_catch_error_callback;
7121 // var :async_completer; 7127 // var :async_completer;
7122 LocalVariable* async_op_var = new(Z) LocalVariable( 7128 LocalVariable* async_op_var = new(Z) LocalVariable(
7123 TokenPosition::kNoSource, 7129 TokenPosition::kNoSource,
7130 TokenPosition::kNoSource,
7124 Symbols::AsyncOperation(), 7131 Symbols::AsyncOperation(),
7125 Object::dynamic_type()); 7132 Object::dynamic_type());
7126 current_block_->scope->AddVariable(async_op_var); 7133 current_block_->scope->AddVariable(async_op_var);
7127 LocalVariable* async_then_callback_var = new(Z) LocalVariable( 7134 LocalVariable* async_then_callback_var = new(Z) LocalVariable(
7128 TokenPosition::kNoSource, 7135 TokenPosition::kNoSource,
7136 TokenPosition::kNoSource,
7129 Symbols::AsyncThenCallback(), 7137 Symbols::AsyncThenCallback(),
7130 Object::dynamic_type()); 7138 Object::dynamic_type());
7131 current_block_->scope->AddVariable(async_then_callback_var); 7139 current_block_->scope->AddVariable(async_then_callback_var);
7132 LocalVariable* async_catch_error_callback_var = new(Z) LocalVariable( 7140 LocalVariable* async_catch_error_callback_var = new(Z) LocalVariable(
7133 TokenPosition::kNoSource, 7141 TokenPosition::kNoSource,
7142 TokenPosition::kNoSource,
7134 Symbols::AsyncCatchErrorCallback(), 7143 Symbols::AsyncCatchErrorCallback(),
7135 Object::dynamic_type()); 7144 Object::dynamic_type());
7136 current_block_->scope->AddVariable(async_catch_error_callback_var); 7145 current_block_->scope->AddVariable(async_catch_error_callback_var);
7137 LocalVariable* async_completer = new(Z) LocalVariable( 7146 LocalVariable* async_completer = new(Z) LocalVariable(
7138 TokenPosition::kNoSource, 7147 TokenPosition::kNoSource,
7148 TokenPosition::kNoSource,
7139 Symbols::AsyncCompleter(), 7149 Symbols::AsyncCompleter(),
7140 Object::dynamic_type()); 7150 Object::dynamic_type());
7141 current_block_->scope->AddVariable(async_completer); 7151 current_block_->scope->AddVariable(async_completer);
7142 } 7152 }
7143 7153
7144 7154
7145 void Parser::AddAsyncGeneratorVariables() { 7155 void Parser::AddAsyncGeneratorVariables() {
7146 // Add to current block's scope: 7156 // Add to current block's scope:
7147 // var :controller; 7157 // var :controller;
7148 // The :controller variable is used by the async generator closure to 7158 // The :controller variable is used by the async generator closure to
7149 // store the StreamController object to which the yielded expressions 7159 // store the StreamController object to which the yielded expressions
7150 // are added. 7160 // are added.
7151 // var :async_op; 7161 // var :async_op;
7152 // var :async_then_callback; 7162 // var :async_then_callback;
7153 // var :async_catch_error_callback; 7163 // var :async_catch_error_callback;
7154 // These variables are used to store the async generator closure containing 7164 // These variables are used to store the async generator closure containing
7155 // the body of the async* function. They are used by the await operator. 7165 // the body of the async* function. They are used by the await operator.
7156 LocalVariable* controller_var = new(Z) LocalVariable( 7166 LocalVariable* controller_var = new(Z) LocalVariable(
7157 TokenPosition::kNoSource, 7167 TokenPosition::kNoSource,
7168 TokenPosition::kNoSource,
7158 Symbols::Controller(), 7169 Symbols::Controller(),
7159 Object::dynamic_type()); 7170 Object::dynamic_type());
7160 current_block_->scope->AddVariable(controller_var); 7171 current_block_->scope->AddVariable(controller_var);
7161 LocalVariable* async_op_var = new(Z) LocalVariable( 7172 LocalVariable* async_op_var = new(Z) LocalVariable(
7162 TokenPosition::kNoSource, 7173 TokenPosition::kNoSource,
7174 TokenPosition::kNoSource,
7163 Symbols::AsyncOperation(), 7175 Symbols::AsyncOperation(),
7164 Object::dynamic_type()); 7176 Object::dynamic_type());
7165 current_block_->scope->AddVariable(async_op_var); 7177 current_block_->scope->AddVariable(async_op_var);
7166 LocalVariable* async_then_callback_var = new(Z) LocalVariable( 7178 LocalVariable* async_then_callback_var = new(Z) LocalVariable(
7167 TokenPosition::kNoSource, 7179 TokenPosition::kNoSource,
7180 TokenPosition::kNoSource,
7168 Symbols::AsyncThenCallback(), 7181 Symbols::AsyncThenCallback(),
7169 Object::dynamic_type()); 7182 Object::dynamic_type());
7170 current_block_->scope->AddVariable(async_then_callback_var); 7183 current_block_->scope->AddVariable(async_then_callback_var);
7171 LocalVariable* async_catch_error_callback_var = new(Z) LocalVariable( 7184 LocalVariable* async_catch_error_callback_var = new(Z) LocalVariable(
7172 TokenPosition::kNoSource, 7185 TokenPosition::kNoSource,
7186 TokenPosition::kNoSource,
7173 Symbols::AsyncCatchErrorCallback(), 7187 Symbols::AsyncCatchErrorCallback(),
7174 Object::dynamic_type()); 7188 Object::dynamic_type());
7175 current_block_->scope->AddVariable(async_catch_error_callback_var); 7189 current_block_->scope->AddVariable(async_catch_error_callback_var);
7176 } 7190 }
7177 7191
7178 7192
7179 RawFunction* Parser::OpenAsyncGeneratorFunction( 7193 RawFunction* Parser::OpenAsyncGeneratorFunction(
7180 TokenPosition async_func_pos) { 7194 TokenPosition async_func_pos) {
7181 TRACE_PARSER("OpenAsyncGeneratorFunction"); 7195 TRACE_PARSER("OpenAsyncGeneratorFunction");
7182 AddContinuationVariables(); 7196 AddContinuationVariables();
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
7651 void Parser::AddFormalParamsToScope(const ParamList* params, 7665 void Parser::AddFormalParamsToScope(const ParamList* params,
7652 LocalScope* scope) { 7666 LocalScope* scope) {
7653 ASSERT((params != NULL) && (params->parameters != NULL)); 7667 ASSERT((params != NULL) && (params->parameters != NULL));
7654 ASSERT(scope != NULL); 7668 ASSERT(scope != NULL);
7655 const int num_parameters = params->parameters->length(); 7669 const int num_parameters = params->parameters->length();
7656 for (int i = 0; i < num_parameters; i++) { 7670 for (int i = 0; i < num_parameters; i++) {
7657 ParamDesc& param_desc = (*params->parameters)[i]; 7671 ParamDesc& param_desc = (*params->parameters)[i];
7658 ASSERT(!is_top_level_ || param_desc.type->IsResolved()); 7672 ASSERT(!is_top_level_ || param_desc.type->IsResolved());
7659 const String* name = param_desc.name; 7673 const String* name = param_desc.name;
7660 LocalVariable* parameter = new(Z) LocalVariable( 7674 LocalVariable* parameter = new(Z) LocalVariable(
7661 param_desc.name_pos, *name, *param_desc.type); 7675 param_desc.name_pos,
7676 param_desc.name_pos,
7677 *name,
7678 *param_desc.type);
7662 if (!scope->InsertParameterAt(i, parameter)) { 7679 if (!scope->InsertParameterAt(i, parameter)) {
7663 ReportError(param_desc.name_pos, 7680 ReportError(param_desc.name_pos,
7664 "name '%s' already exists in scope", 7681 "name '%s' already exists in scope",
7665 param_desc.name->ToCString()); 7682 param_desc.name->ToCString());
7666 } 7683 }
7667 param_desc.var = parameter; 7684 param_desc.var = parameter;
7668 if (param_desc.is_final) { 7685 if (param_desc.is_final) {
7669 parameter->set_is_final(); 7686 parameter->set_is_final();
7670 } 7687 }
7671 if (FLAG_initializing_formal_access) { 7688 if (FLAG_initializing_formal_access) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
7763 const TokenPosition assign_pos = TokenPos(); 7780 const TokenPosition assign_pos = TokenPos();
7764 AstNode* initialization = NULL; 7781 AstNode* initialization = NULL;
7765 LocalVariable* variable = NULL; 7782 LocalVariable* variable = NULL;
7766 if (CurrentToken() == Token::kASSIGN) { 7783 if (CurrentToken() == Token::kASSIGN) {
7767 // Variable initialization. 7784 // Variable initialization.
7768 ConsumeToken(); 7785 ConsumeToken();
7769 AstNode* expr = ParseAwaitableExpr( 7786 AstNode* expr = ParseAwaitableExpr(
7770 is_const, kConsumeCascades, await_preamble); 7787 is_const, kConsumeCascades, await_preamble);
7771 const TokenPosition expr_end_pos = TokenPos(); 7788 const TokenPosition expr_end_pos = TokenPos();
7772 variable = new(Z) LocalVariable( 7789 variable = new(Z) LocalVariable(
7773 expr_end_pos, ident, type); 7790 ident_pos,
7791 expr_end_pos,
7792 ident,
7793 type);
7774 initialization = new(Z) StoreLocalNode( 7794 initialization = new(Z) StoreLocalNode(
7775 assign_pos, variable, expr); 7795 assign_pos, variable, expr);
7776 if (is_const) { 7796 if (is_const) {
7777 ASSERT(expr->IsLiteralNode()); 7797 ASSERT(expr->IsLiteralNode());
7778 variable->SetConstValue(expr->AsLiteralNode()->literal()); 7798 variable->SetConstValue(expr->AsLiteralNode()->literal());
7779 } 7799 }
7780 } else if (is_final || is_const) { 7800 } else if (is_final || is_const) {
7781 ReportError(ident_pos, 7801 ReportError(ident_pos,
7782 "missing initialization of 'final' or 'const' variable"); 7802 "missing initialization of 'final' or 'const' variable");
7783 } else { 7803 } else {
7784 // Initialize variable with null. 7804 // Initialize variable with null.
7785 variable = new(Z) LocalVariable( 7805 variable = new(Z) LocalVariable(
7786 assign_pos, ident, type); 7806 ident_pos,
7807 assign_pos,
7808 ident,
7809 type);
7787 AstNode* null_expr = new(Z) LiteralNode(ident_pos, Object::null_instance()); 7810 AstNode* null_expr = new(Z) LiteralNode(ident_pos, Object::null_instance());
7788 initialization = new(Z) StoreLocalNode( 7811 initialization = new(Z) StoreLocalNode(
7789 ident_pos, variable, null_expr); 7812 ident_pos, variable, null_expr);
7790 } 7813 }
7791 7814
7792 ASSERT(current_block_ != NULL); 7815 ASSERT(current_block_ != NULL);
7793 const TokenPosition previous_pos = 7816 const TokenPosition previous_pos =
7794 current_block_->scope->PreviousReferencePos(ident); 7817 current_block_->scope->PreviousReferencePos(ident);
7795 if (previous_pos.IsReal()) { 7818 if (previous_pos.IsReal()) {
7796 ASSERT(!script_.IsNull()); 7819 ASSERT(!script_.IsNull());
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
7913 7936
7914 AstNode* Parser::ParseFunctionStatement(bool is_literal) { 7937 AstNode* Parser::ParseFunctionStatement(bool is_literal) {
7915 TRACE_PARSER("ParseFunctionStatement"); 7938 TRACE_PARSER("ParseFunctionStatement");
7916 AbstractType& result_type = AbstractType::Handle(Z); 7939 AbstractType& result_type = AbstractType::Handle(Z);
7917 const String* variable_name = NULL; 7940 const String* variable_name = NULL;
7918 const String* function_name = NULL; 7941 const String* function_name = NULL;
7919 7942
7920 result_type = Type::DynamicType(); 7943 result_type = Type::DynamicType();
7921 7944
7922 const TokenPosition function_pos = TokenPos(); 7945 const TokenPosition function_pos = TokenPos();
7946 TokenPosition function_name_pos = TokenPosition::kNoSource;
7923 TokenPosition metadata_pos = TokenPosition::kNoSource; 7947 TokenPosition metadata_pos = TokenPosition::kNoSource;
7924 if (is_literal) { 7948 if (is_literal) {
7925 ASSERT(CurrentToken() == Token::kLPAREN || CurrentToken() == Token::kLT); 7949 ASSERT(CurrentToken() == Token::kLPAREN || CurrentToken() == Token::kLT);
7926 function_name = &Symbols::AnonymousClosure(); 7950 function_name = &Symbols::AnonymousClosure();
7927 } else { 7951 } else {
7928 metadata_pos = SkipMetadata(); 7952 metadata_pos = SkipMetadata();
7929 if (CurrentToken() == Token::kVOID) { 7953 if (CurrentToken() == Token::kVOID) {
7930 ConsumeToken(); 7954 ConsumeToken();
7931 result_type = Type::VoidType(); 7955 result_type = Type::VoidType();
7932 } else if (IsFunctionReturnType()) { 7956 } else if (IsFunctionReturnType()) {
7933 // It is too early to resolve the type here, since it can be a result type 7957 // It is too early to resolve the type here, since it can be a result type
7934 // referring to a not yet declared function type parameter. 7958 // referring to a not yet declared function type parameter.
7935 result_type = ParseType(ClassFinalizer::kDoNotResolve); 7959 result_type = ParseType(ClassFinalizer::kDoNotResolve);
7936 } 7960 }
7937 const TokenPosition name_pos = TokenPos(); 7961 function_name_pos = TokenPos();
7938 variable_name = ExpectIdentifier("function name expected"); 7962 variable_name = ExpectIdentifier("function name expected");
7939 function_name = variable_name; 7963 function_name = variable_name;
7940 7964
7941 // Check that the function name has not been referenced 7965 // Check that the function name has not been referenced
7942 // before this declaration. 7966 // before this declaration.
7943 ASSERT(current_block_ != NULL); 7967 ASSERT(current_block_ != NULL);
7944 const TokenPosition previous_pos = 7968 const TokenPosition previous_pos =
7945 current_block_->scope->PreviousReferencePos(*function_name); 7969 current_block_->scope->PreviousReferencePos(*function_name);
7946 if (previous_pos.IsReal()) { 7970 if (previous_pos.IsReal()) {
7947 ASSERT(!script_.IsNull()); 7971 ASSERT(!script_.IsNull());
7948 intptr_t line_number; 7972 intptr_t line_number;
7949 script_.GetTokenLocation(previous_pos, &line_number, NULL); 7973 script_.GetTokenLocation(previous_pos, &line_number, NULL);
7950 ReportError(name_pos, 7974 ReportError(function_name_pos,
7951 "identifier '%s' previously used in line %" Pd "", 7975 "identifier '%s' previously used in line %" Pd "",
7952 function_name->ToCString(), 7976 function_name->ToCString(),
7953 line_number); 7977 line_number);
7954 } 7978 }
7955 } 7979 }
7956 7980
7957 // Check whether we have parsed this closure function before, in a previous 7981 // Check whether we have parsed this closure function before, in a previous
7958 // compilation. If so, reuse the function object, else create a new one 7982 // compilation. If so, reuse the function object, else create a new one
7959 // and register it in the current class. 7983 // and register it in the current class.
7960 // Note that we cannot share the same closure function between the closurized 7984 // Note that we cannot share the same closure function between the closurized
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
8019 const Class& unknown_scope_class = Class::Handle(Z, 8043 const Class& unknown_scope_class = Class::Handle(Z,
8020 I->object_store()->closure_class()); 8044 I->object_store()->closure_class());
8021 function_type = Type::New(unknown_scope_class, 8045 function_type = Type::New(unknown_scope_class,
8022 TypeArguments::Handle(Z), 8046 TypeArguments::Handle(Z),
8023 function_pos); 8047 function_pos);
8024 function_type.set_signature(function); 8048 function_type.set_signature(function);
8025 function_type.SetIsFinalized(); // No finalization needed. 8049 function_type.SetIsFinalized(); // No finalization needed.
8026 8050
8027 // Add the function variable to the scope before parsing the function in 8051 // Add the function variable to the scope before parsing the function in
8028 // order to allow self reference from inside the function. 8052 // order to allow self reference from inside the function.
8029 function_variable = new(Z) LocalVariable(function_pos, 8053 function_variable = new(Z) LocalVariable(function_name_pos,
8054 function_pos,
8030 *variable_name, 8055 *variable_name,
8031 function_type); 8056 function_type);
8032 function_variable->set_is_final(); 8057 function_variable->set_is_final();
8033 ASSERT(current_block_ != NULL); 8058 ASSERT(current_block_ != NULL);
8034 ASSERT(current_block_->scope != NULL); 8059 ASSERT(current_block_->scope != NULL);
8035 if (!current_block_->scope->AddVariable(function_variable)) { 8060 if (!current_block_->scope->AddVariable(function_variable)) {
8036 LocalVariable* existing_var = 8061 LocalVariable* existing_var =
8037 current_block_->scope->LookupVariable(function_variable->name(), 8062 current_block_->scope->LookupVariable(function_variable->name(),
8038 true); 8063 true);
8039 ASSERT(existing_var != NULL); 8064 ASSERT(existing_var != NULL);
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
8831 // variable is set to dynamic. It will later be patched to match the 8856 // variable is set to dynamic. It will later be patched to match the
8832 // type of the case clause expressions. Therefore, we have to allocate 8857 // type of the case clause expressions. Therefore, we have to allocate
8833 // a new type representing dynamic and can't reuse the canonical 8858 // a new type representing dynamic and can't reuse the canonical
8834 // type object for dynamic. 8859 // type object for dynamic.
8835 const Type& temp_var_type = Type::ZoneHandle(Z, 8860 const Type& temp_var_type = Type::ZoneHandle(Z,
8836 Type::New(Class::Handle(Z, Object::dynamic_class()), 8861 Type::New(Class::Handle(Z, Object::dynamic_class()),
8837 TypeArguments::Handle(Z), 8862 TypeArguments::Handle(Z),
8838 expr_pos)); 8863 expr_pos));
8839 temp_var_type.SetIsFinalized(); 8864 temp_var_type.SetIsFinalized();
8840 LocalVariable* temp_variable = new(Z) LocalVariable( 8865 LocalVariable* temp_variable = new(Z) LocalVariable(
8841 expr_pos, Symbols::SwitchExpr(), temp_var_type); 8866 expr_pos, expr_pos, Symbols::SwitchExpr(), temp_var_type);
8842 current_block_->scope->AddVariable(temp_variable); 8867 current_block_->scope->AddVariable(temp_variable);
8843 AstNode* save_switch_expr = new(Z) StoreLocalNode( 8868 AstNode* save_switch_expr = new(Z) StoreLocalNode(
8844 expr_pos, temp_variable, switch_expr); 8869 expr_pos, temp_variable, switch_expr);
8845 current_block_->statements->Add(save_switch_expr); 8870 current_block_->statements->Add(save_switch_expr);
8846 8871
8847 // Parse case clauses 8872 // Parse case clauses
8848 bool default_seen = false; 8873 bool default_seen = false;
8849 GrowableArray<LiteralNode*> case_expr_values; 8874 GrowableArray<LiteralNode*> case_expr_values;
8850 while (true) { 8875 while (true) {
8851 // Check for statement label 8876 // Check for statement label
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
9121 ASSERT(!iterator_ctor.IsNull()); 9146 ASSERT(!iterator_ctor.IsNull());
9122 ArgumentListNode* ctor_args = new (Z) ArgumentListNode(stream_expr_pos); 9147 ArgumentListNode* ctor_args = new (Z) ArgumentListNode(stream_expr_pos);
9123 ctor_args->Add(stream_expr); 9148 ctor_args->Add(stream_expr);
9124 ConstructorCallNode* ctor_call = 9149 ConstructorCallNode* ctor_call =
9125 new (Z) ConstructorCallNode(stream_expr_pos, 9150 new (Z) ConstructorCallNode(stream_expr_pos,
9126 TypeArguments::ZoneHandle(Z), 9151 TypeArguments::ZoneHandle(Z),
9127 iterator_ctor, 9152 iterator_ctor,
9128 ctor_args); 9153 ctor_args);
9129 const AbstractType& iterator_type = Object::dynamic_type(); 9154 const AbstractType& iterator_type = Object::dynamic_type();
9130 LocalVariable* iterator_var = new(Z) LocalVariable( 9155 LocalVariable* iterator_var = new(Z) LocalVariable(
9131 stream_expr_pos, Symbols::ForInIter(), iterator_type); 9156 stream_expr_pos, stream_expr_pos, Symbols::ForInIter(), iterator_type);
9132 current_block_->scope->AddVariable(iterator_var); 9157 current_block_->scope->AddVariable(iterator_var);
9133 AstNode* iterator_init = 9158 AstNode* iterator_init =
9134 new(Z) StoreLocalNode(stream_expr_pos, iterator_var, ctor_call); 9159 new(Z) StoreLocalNode(stream_expr_pos, iterator_var, ctor_call);
9135 current_block_->statements->Add(iterator_init); 9160 current_block_->statements->Add(iterator_init);
9136 9161
9137 // We need to ensure that the stream is cancelled after the loop. 9162 // We need to ensure that the stream is cancelled after the loop.
9138 // Thus, wrap the loop in a try-finally that calls :for-in-iter.close() 9163 // Thus, wrap the loop in a try-finally that calls :for-in-iter.close()
9139 // in the finally clause. It is harmless to call close() if the stream 9164 // in the finally clause. It is harmless to call close() if the stream
9140 // is already cancelled (when moveNext() returns false). 9165 // is already cancelled (when moveNext() returns false).
9141 // Note: even though this is async code, we do not need to set up 9166 // Note: even though this is async code, we do not need to set up
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
9206 9231
9207 // Generate assignment of next iterator value to loop variable. 9232 // Generate assignment of next iterator value to loop variable.
9208 AstNode* loop_var_assignment = NULL; 9233 AstNode* loop_var_assignment = NULL;
9209 if (new_loop_var) { 9234 if (new_loop_var) {
9210 // The for loop variable is new for each iteration. 9235 // The for loop variable is new for each iteration.
9211 // Create a variable and add it to the loop body scope. 9236 // Create a variable and add it to the loop body scope.
9212 // Note that the variable token position needs to be inside the 9237 // Note that the variable token position needs to be inside the
9213 // loop block, so it gets put in the loop context level. 9238 // loop block, so it gets put in the loop context level.
9214 LocalVariable* loop_var = 9239 LocalVariable* loop_var =
9215 new(Z) LocalVariable(loop_var_assignment_pos, 9240 new(Z) LocalVariable(loop_var_assignment_pos,
9241 loop_var_assignment_pos,
9216 *loop_var_name, 9242 *loop_var_name,
9217 loop_var_type);; 9243 loop_var_type);;
9218 if (loop_var_is_final) { 9244 if (loop_var_is_final) {
9219 loop_var->set_is_final(); 9245 loop_var->set_is_final();
9220 } 9246 }
9221 current_block_->scope->AddVariable(loop_var); 9247 current_block_->scope->AddVariable(loop_var);
9222 loop_var_assignment = new(Z) StoreLocalNode( 9248 loop_var_assignment = new(Z) StoreLocalNode(
9223 loop_var_assignment_pos, loop_var, iterator_current); 9249 loop_var_assignment_pos, loop_var, iterator_current);
9224 } else { 9250 } else {
9225 AstNode* loop_var_primary = 9251 AstNode* loop_var_primary =
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
9381 loop_var_pos = TokenPos(); 9407 loop_var_pos = TokenPos();
9382 loop_var_name = ExpectIdentifier("variable name expected"); 9408 loop_var_name = ExpectIdentifier("variable name expected");
9383 } else { 9409 } else {
9384 // The case without a type is handled above, so require a type here. 9410 // The case without a type is handled above, so require a type here.
9385 // Delay creation of the local variable until we know its actual 9411 // Delay creation of the local variable until we know its actual
9386 // position, which is inside the loop body. 9412 // position, which is inside the loop body.
9387 new_loop_var = true; 9413 new_loop_var = true;
9388 loop_var_type = ParseConstFinalVarOrType( 9414 loop_var_type = ParseConstFinalVarOrType(
9389 I->type_checks() ? ClassFinalizer::kCanonicalize : 9415 I->type_checks() ? ClassFinalizer::kCanonicalize :
9390 ClassFinalizer::kIgnore); 9416 ClassFinalizer::kIgnore);
9417 loop_var_pos = TokenPos();
9391 loop_var_name = ExpectIdentifier("variable name expected"); 9418 loop_var_name = ExpectIdentifier("variable name expected");
9392 } 9419 }
9393 ExpectToken(Token::kIN); 9420 ExpectToken(Token::kIN);
9394 9421
9395 // Ensure that the block token range contains the call to moveNext and it 9422 // Ensure that the block token range contains the call to moveNext and it
9396 // also starts the block at a different token position than the following 9423 // also starts the block at a different token position than the following
9397 // loop block. Both blocks can allocate contexts and if they have a matching 9424 // loop block. Both blocks can allocate contexts and if they have a matching
9398 // token position range, it can be an issue (cf. bug 26941). 9425 // token position range, it can be an issue (cf. bug 26941).
9399 OpenBlock(); // Implicit block around while loop. 9426 OpenBlock(); // Implicit block around while loop.
9400 9427
9401 const TokenPosition collection_pos = TokenPos(); 9428 const TokenPosition collection_pos = TokenPos();
9402 AstNode* collection_expr = 9429 AstNode* collection_expr =
9403 ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL); 9430 ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL);
9404 ExpectToken(Token::kRPAREN); 9431 ExpectToken(Token::kRPAREN);
9405 9432
9406 // Generate implicit iterator variable and add to scope. 9433 // Generate implicit iterator variable and add to scope.
9407 // We could set the type of the implicit iterator variable to Iterator<T> 9434 // We could set the type of the implicit iterator variable to Iterator<T>
9408 // where T is the type of the for loop variable. However, the type error 9435 // where T is the type of the for loop variable. However, the type error
9409 // would refer to the compiler generated iterator and could confuse the user. 9436 // would refer to the compiler generated iterator and could confuse the user.
9410 // It is better to leave the iterator untyped and postpone the type error 9437 // It is better to leave the iterator untyped and postpone the type error
9411 // until the loop variable is assigned to. 9438 // until the loop variable is assigned to.
9412 const AbstractType& iterator_type = Object::dynamic_type(); 9439 const AbstractType& iterator_type = Object::dynamic_type();
9413 LocalVariable* iterator_var = new(Z) LocalVariable( 9440 LocalVariable* iterator_var = new(Z) LocalVariable(
9441 collection_pos,
9414 collection_pos, Symbols::ForInIter(), iterator_type); 9442 collection_pos, Symbols::ForInIter(), iterator_type);
9415 current_block_->scope->AddVariable(iterator_var); 9443 current_block_->scope->AddVariable(iterator_var);
9416 9444
9417 // Generate initialization of iterator variable. 9445 // Generate initialization of iterator variable.
9418 ArgumentListNode* no_args = new(Z) ArgumentListNode(collection_pos); 9446 ArgumentListNode* no_args = new(Z) ArgumentListNode(collection_pos);
9419 AstNode* get_iterator = new(Z) InstanceGetterNode( 9447 AstNode* get_iterator = new(Z) InstanceGetterNode(
9420 collection_pos, collection_expr, Symbols::Iterator()); 9448 collection_pos, collection_expr, Symbols::Iterator());
9421 AstNode* iterator_init = 9449 AstNode* iterator_init =
9422 new(Z) StoreLocalNode(collection_pos, iterator_var, get_iterator); 9450 new(Z) StoreLocalNode(collection_pos, iterator_var, get_iterator);
9423 current_block_->statements->Add(iterator_init); 9451 current_block_->statements->Add(iterator_init);
(...skipping 17 matching lines...) Expand all
9441 loop_var_assignment_pos, 9469 loop_var_assignment_pos,
9442 new(Z) LoadLocalNode(loop_var_assignment_pos, iterator_var), 9470 new(Z) LoadLocalNode(loop_var_assignment_pos, iterator_var),
9443 Symbols::Current()); 9471 Symbols::Current());
9444 9472
9445 // Generate assignment of next iterator value to loop variable. 9473 // Generate assignment of next iterator value to loop variable.
9446 AstNode* loop_var_assignment = NULL; 9474 AstNode* loop_var_assignment = NULL;
9447 if (new_loop_var) { 9475 if (new_loop_var) {
9448 // The for loop variable is new for each iteration. 9476 // The for loop variable is new for each iteration.
9449 // Create a variable and add it to the loop body scope. 9477 // Create a variable and add it to the loop body scope.
9450 LocalVariable* loop_var = 9478 LocalVariable* loop_var =
9451 new(Z) LocalVariable(loop_var_assignment_pos, 9479 new(Z) LocalVariable(loop_var_pos,
9480 loop_var_assignment_pos,
9452 *loop_var_name, 9481 *loop_var_name,
9453 loop_var_type);; 9482 loop_var_type);;
9454 if (loop_var_is_final) { 9483 if (loop_var_is_final) {
9455 loop_var->set_is_final(); 9484 loop_var->set_is_final();
9456 } 9485 }
9457 current_block_->scope->AddVariable(loop_var); 9486 current_block_->scope->AddVariable(loop_var);
9458 loop_var_assignment = new(Z) StoreLocalNode( 9487 loop_var_assignment = new(Z) StoreLocalNode(
9459 loop_var_assignment_pos, loop_var, iterator_current); 9488 loop_var_assignment_pos, loop_var, iterator_current);
9460 } else { 9489 } else {
9461 AstNode* loop_var_primary = 9490 AstNode* loop_var_primary =
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
9608 } 9637 }
9609 9638
9610 9639
9611 // Populate local scope of the catch block with the catch parameters. 9640 // Populate local scope of the catch block with the catch parameters.
9612 void Parser::AddCatchParamsToScope(CatchParamDesc* exception_param, 9641 void Parser::AddCatchParamsToScope(CatchParamDesc* exception_param,
9613 CatchParamDesc* stack_trace_param, 9642 CatchParamDesc* stack_trace_param,
9614 LocalScope* scope) { 9643 LocalScope* scope) {
9615 if (exception_param->name != NULL) { 9644 if (exception_param->name != NULL) {
9616 LocalVariable* var = new(Z) LocalVariable( 9645 LocalVariable* var = new(Z) LocalVariable(
9617 exception_param->token_pos, 9646 exception_param->token_pos,
9647 exception_param->token_pos,
9618 *exception_param->name, 9648 *exception_param->name,
9619 *exception_param->type); 9649 *exception_param->type);
9620 var->set_is_final(); 9650 var->set_is_final();
9621 bool added_to_scope = scope->AddVariable(var); 9651 bool added_to_scope = scope->AddVariable(var);
9622 ASSERT(added_to_scope); 9652 ASSERT(added_to_scope);
9623 exception_param->var = var; 9653 exception_param->var = var;
9624 } 9654 }
9625 if (stack_trace_param->name != NULL) { 9655 if (stack_trace_param->name != NULL) {
9626 LocalVariable* var = new(Z) LocalVariable( 9656 LocalVariable* var = new(Z) LocalVariable(
9627 stack_trace_param->token_pos, 9657 stack_trace_param->token_pos,
9658 stack_trace_param->token_pos,
9628 *stack_trace_param->name, 9659 *stack_trace_param->name,
9629 *stack_trace_param->type); 9660 *stack_trace_param->type);
9630 var->set_is_final(); 9661 var->set_is_final();
9631 bool added_to_scope = scope->AddVariable(var); 9662 bool added_to_scope = scope->AddVariable(var);
9632 if (!added_to_scope) { 9663 if (!added_to_scope) {
9633 // The name of the exception param is reused for the stack trace param. 9664 // The name of the exception param is reused for the stack trace param.
9634 ReportError(stack_trace_param->token_pos, 9665 ReportError(stack_trace_param->token_pos,
9635 "name '%s' already exists in scope", 9666 "name '%s' already exists in scope",
9636 stack_trace_param->name->ToCString()); 9667 stack_trace_param->name->ToCString());
9637 } 9668 }
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
10027 10058
10028 10059
10029 void Parser::SetupSavedTryContext(LocalVariable* saved_try_context) { 10060 void Parser::SetupSavedTryContext(LocalVariable* saved_try_context) {
10030 const String& async_saved_try_ctx_name = String::ZoneHandle(Z, 10061 const String& async_saved_try_ctx_name = String::ZoneHandle(Z,
10031 Symbols::NewFormatted(T, 10062 Symbols::NewFormatted(T,
10032 "%s%d", 10063 "%s%d",
10033 Symbols::AsyncSavedTryCtxVarPrefix().ToCString(), 10064 Symbols::AsyncSavedTryCtxVarPrefix().ToCString(),
10034 last_used_try_index_ - 1)); 10065 last_used_try_index_ - 1));
10035 LocalVariable* async_saved_try_ctx = new (Z) LocalVariable( 10066 LocalVariable* async_saved_try_ctx = new (Z) LocalVariable(
10036 TokenPosition::kNoSource, 10067 TokenPosition::kNoSource,
10068 TokenPosition::kNoSource,
10037 async_saved_try_ctx_name, 10069 async_saved_try_ctx_name,
10038 Object::dynamic_type()); 10070 Object::dynamic_type());
10039 ASSERT(async_temp_scope_ != NULL); 10071 ASSERT(async_temp_scope_ != NULL);
10040 async_temp_scope_->AddVariable(async_saved_try_ctx); 10072 async_temp_scope_->AddVariable(async_saved_try_ctx);
10041 ASSERT(saved_try_context != NULL); 10073 ASSERT(saved_try_context != NULL);
10042 current_block_->statements->Add(new(Z) StoreLocalNode( 10074 current_block_->statements->Add(new(Z) StoreLocalNode(
10043 TokenPosition::kNoSource, 10075 TokenPosition::kNoSource,
10044 async_saved_try_ctx, 10076 async_saved_try_ctx,
10045 new(Z) LoadLocalNode(TokenPosition::kNoSource, saved_try_context))); 10077 new(Z) LoadLocalNode(TokenPosition::kNoSource, saved_try_context)));
10046 } 10078 }
(...skipping 21 matching lines...) Expand all
10068 LocalVariable** context_var, 10100 LocalVariable** context_var,
10069 LocalVariable** exception_var, 10101 LocalVariable** exception_var,
10070 LocalVariable** stack_trace_var, 10102 LocalVariable** stack_trace_var,
10071 LocalVariable** saved_exception_var, 10103 LocalVariable** saved_exception_var,
10072 LocalVariable** saved_stack_trace_var) { 10104 LocalVariable** saved_stack_trace_var) {
10073 // Consecutive try statements share the same set of variables. 10105 // Consecutive try statements share the same set of variables.
10074 *context_var = try_scope->LocalLookupVariable(Symbols::SavedTryContextVar()); 10106 *context_var = try_scope->LocalLookupVariable(Symbols::SavedTryContextVar());
10075 if (*context_var == NULL) { 10107 if (*context_var == NULL) {
10076 *context_var = new(Z) LocalVariable( 10108 *context_var = new(Z) LocalVariable(
10077 TokenPos(), 10109 TokenPos(),
10110 TokenPos(),
10078 Symbols::SavedTryContextVar(), 10111 Symbols::SavedTryContextVar(),
10079 Object::dynamic_type()); 10112 Object::dynamic_type());
10080 try_scope->AddVariable(*context_var); 10113 try_scope->AddVariable(*context_var);
10081 } 10114 }
10082 *exception_var = try_scope->LocalLookupVariable(Symbols::ExceptionVar()); 10115 *exception_var = try_scope->LocalLookupVariable(Symbols::ExceptionVar());
10083 if (*exception_var == NULL) { 10116 if (*exception_var == NULL) {
10084 *exception_var = new(Z) LocalVariable( 10117 *exception_var = new(Z) LocalVariable(
10085 TokenPos(), 10118 TokenPos(),
10119 TokenPos(),
10086 Symbols::ExceptionVar(), 10120 Symbols::ExceptionVar(),
10087 Object::dynamic_type()); 10121 Object::dynamic_type());
10088 try_scope->AddVariable(*exception_var); 10122 try_scope->AddVariable(*exception_var);
10089 } 10123 }
10090 *stack_trace_var = try_scope->LocalLookupVariable(Symbols::StackTraceVar()); 10124 *stack_trace_var = try_scope->LocalLookupVariable(Symbols::StackTraceVar());
10091 if (*stack_trace_var == NULL) { 10125 if (*stack_trace_var == NULL) {
10092 *stack_trace_var = new(Z) LocalVariable( 10126 *stack_trace_var = new(Z) LocalVariable(
10093 TokenPos(), 10127 TokenPos(),
10128 TokenPos(),
10094 Symbols::StackTraceVar(), 10129 Symbols::StackTraceVar(),
10095 Object::dynamic_type()); 10130 Object::dynamic_type());
10096 try_scope->AddVariable(*stack_trace_var); 10131 try_scope->AddVariable(*stack_trace_var);
10097 } 10132 }
10098 if (is_async) { 10133 if (is_async) {
10099 *saved_exception_var = try_scope->LocalLookupVariable( 10134 *saved_exception_var = try_scope->LocalLookupVariable(
10100 Symbols::SavedExceptionVar()); 10135 Symbols::SavedExceptionVar());
10101 if (*saved_exception_var == NULL) { 10136 if (*saved_exception_var == NULL) {
10102 *saved_exception_var = new(Z) LocalVariable( 10137 *saved_exception_var = new(Z) LocalVariable(
10103 TokenPos(), 10138 TokenPos(),
10139 TokenPos(),
10104 Symbols::SavedExceptionVar(), 10140 Symbols::SavedExceptionVar(),
10105 Object::dynamic_type()); 10141 Object::dynamic_type());
10106 try_scope->AddVariable(*saved_exception_var); 10142 try_scope->AddVariable(*saved_exception_var);
10107 } 10143 }
10108 *saved_stack_trace_var = try_scope->LocalLookupVariable( 10144 *saved_stack_trace_var = try_scope->LocalLookupVariable(
10109 Symbols::SavedStackTraceVar()); 10145 Symbols::SavedStackTraceVar());
10110 if (*saved_stack_trace_var == NULL) { 10146 if (*saved_stack_trace_var == NULL) {
10111 *saved_stack_trace_var = new(Z) LocalVariable( 10147 *saved_stack_trace_var = new(Z) LocalVariable(
10112 TokenPos(), 10148 TokenPos(),
10149 TokenPos(),
10113 Symbols::SavedStackTraceVar(), 10150 Symbols::SavedStackTraceVar(),
10114 Object::dynamic_type()); 10151 Object::dynamic_type());
10115 try_scope->AddVariable(*saved_stack_trace_var); 10152 try_scope->AddVariable(*saved_stack_trace_var);
10116 } 10153 }
10117 } 10154 }
10118 } 10155 }
10119 10156
10120 10157
10121 AstNode* Parser::ParseTryStatement(String* label_name) { 10158 AstNode* Parser::ParseTryStatement(String* label_name) {
10122 TRACE_PARSER("ParseTryStatement"); 10159 TRACE_PARSER("ParseTryStatement");
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
11083 parsed_function()->EnsureExpressionTemp(); 11120 parsed_function()->EnsureExpressionTemp();
11084 } 11121 }
11085 11122
11086 11123
11087 LocalVariable* Parser::CreateTempConstVariable(TokenPosition token_pos, 11124 LocalVariable* Parser::CreateTempConstVariable(TokenPosition token_pos,
11088 const char* s) { 11125 const char* s) {
11089 char name[64]; 11126 char name[64];
11090 OS::SNPrint(name, 64, ":%s%" Pd "", s, token_pos.value()); 11127 OS::SNPrint(name, 64, ":%s%" Pd "", s, token_pos.value());
11091 LocalVariable* temp = new(Z) LocalVariable( 11128 LocalVariable* temp = new(Z) LocalVariable(
11092 token_pos, 11129 token_pos,
11130 token_pos,
11093 String::ZoneHandle(Z, Symbols::New(T, name)), 11131 String::ZoneHandle(Z, Symbols::New(T, name)),
11094 Object::dynamic_type()); 11132 Object::dynamic_type());
11095 temp->set_is_final(); 11133 temp->set_is_final();
11096 current_block_->scope->AddVariable(temp); 11134 current_block_->scope->AddVariable(temp);
11097 return temp; 11135 return temp;
11098 } 11136 }
11099 11137
11100 11138
11101 AstNode* Parser::OptimizeBinaryOpNode(TokenPosition op_pos, 11139 AstNode* Parser::OptimizeBinaryOpNode(TokenPosition op_pos,
11102 Token::Kind binary_op, 11140 Token::Kind binary_op,
(...skipping 4007 matching lines...) Expand 10 before | Expand all | Expand 10 after
15110 const ArgumentListNode& function_args, 15148 const ArgumentListNode& function_args,
15111 const LocalVariable* temp_for_last_arg, 15149 const LocalVariable* temp_for_last_arg,
15112 bool is_super_invocation) { 15150 bool is_super_invocation) {
15113 UNREACHABLE(); 15151 UNREACHABLE();
15114 return NULL; 15152 return NULL;
15115 } 15153 }
15116 15154
15117 } // namespace dart 15155 } // namespace dart
15118 15156
15119 #endif // DART_PRECOMPILED_RUNTIME 15157 #endif // DART_PRECOMPILED_RUNTIME
OLDNEW
« no previous file with comments | « runtime/vm/parser.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698