| OLD | NEW |
| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 } | 179 } |
| 180 ASSERT(has_expression_temp_var()); | 180 ASSERT(has_expression_temp_var()); |
| 181 return expression_temp_var(); | 181 return expression_temp_var(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 | 184 |
| 185 void ParsedFunction::EnsureFinallyReturnTemp(bool is_async) { | 185 void ParsedFunction::EnsureFinallyReturnTemp(bool is_async) { |
| 186 if (!has_finally_return_temp_var()) { | 186 if (!has_finally_return_temp_var()) { |
| 187 LocalVariable* temp = new(Z) LocalVariable( | 187 LocalVariable* temp = new(Z) LocalVariable( |
| 188 function_.token_pos(), | 188 function_.token_pos(), |
| 189 String::ZoneHandle(Z, Symbols::New(":finally_ret_val")), | 189 Symbols::FinallyRetVal(), |
| 190 Object::dynamic_type()); | 190 Object::dynamic_type()); |
| 191 ASSERT(temp != NULL); | 191 ASSERT(temp != NULL); |
| 192 temp->set_is_final(); | 192 temp->set_is_final(); |
| 193 if (is_async) { | 193 if (is_async) { |
| 194 temp->set_is_captured(); | 194 temp->set_is_captured(); |
| 195 } | 195 } |
| 196 set_finally_return_temp_var(temp); | 196 set_finally_return_temp_var(temp); |
| 197 } | 197 } |
| 198 ASSERT(has_finally_return_temp_var()); | 198 ASSERT(has_finally_return_temp_var()); |
| 199 } | 199 } |
| (...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1226 | 1226 |
| 1227 | 1227 |
| 1228 ParsedFunction* Parser::ParseStaticFieldInitializer(const Field& field) { | 1228 ParsedFunction* Parser::ParseStaticFieldInitializer(const Field& field) { |
| 1229 ASSERT(field.is_static()); | 1229 ASSERT(field.is_static()); |
| 1230 Thread* thread = Thread::Current(); | 1230 Thread* thread = Thread::Current(); |
| 1231 // TODO(koda): Should there be a StackZone here? | 1231 // TODO(koda): Should there be a StackZone here? |
| 1232 Zone* zone = thread->zone(); | 1232 Zone* zone = thread->zone(); |
| 1233 | 1233 |
| 1234 const String& field_name = String::Handle(zone, field.name()); | 1234 const String& field_name = String::Handle(zone, field.name()); |
| 1235 String& init_name = String::Handle(zone, | 1235 String& init_name = String::Handle(zone, |
| 1236 Symbols::FromConcat(Symbols::InitPrefix(), field_name)); | 1236 Symbols::FromConcat(thread, Symbols::InitPrefix(), field_name)); |
| 1237 | 1237 |
| 1238 const Script& script = Script::Handle(zone, field.Script()); | 1238 const Script& script = Script::Handle(zone, field.Script()); |
| 1239 Object& initializer_owner = Object::Handle(field.Owner()); | 1239 Object& initializer_owner = Object::Handle(field.Owner()); |
| 1240 initializer_owner = | 1240 initializer_owner = |
| 1241 PatchClass::New(Class::Handle(field.Owner()), script); | 1241 PatchClass::New(Class::Handle(field.Owner()), script); |
| 1242 | 1242 |
| 1243 const Function& initializer = Function::ZoneHandle(zone, | 1243 const Function& initializer = Function::ZoneHandle(zone, |
| 1244 Function::New(init_name, | 1244 Function::New(init_name, |
| 1245 RawFunction::kImplicitStaticFinalGetter, | 1245 RawFunction::kImplicitStaticFinalGetter, |
| 1246 true, // static | 1246 true, // static |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1567 ParamList params; | 1567 ParamList params; |
| 1568 // Receiver first. | 1568 // Receiver first. |
| 1569 TokenPosition token_pos = func.token_pos(); | 1569 TokenPosition token_pos = func.token_pos(); |
| 1570 params.AddReceiver(ReceiverType(current_class()), token_pos); | 1570 params.AddReceiver(ReceiverType(current_class()), token_pos); |
| 1571 // Remaining positional parameters. | 1571 // Remaining positional parameters. |
| 1572 intptr_t i = 1; | 1572 intptr_t i = 1; |
| 1573 for (; i < desc.PositionalCount(); ++i) { | 1573 for (; i < desc.PositionalCount(); ++i) { |
| 1574 ParamDesc p; | 1574 ParamDesc p; |
| 1575 char name[64]; | 1575 char name[64]; |
| 1576 OS::SNPrint(name, 64, ":p%" Pd, i); | 1576 OS::SNPrint(name, 64, ":p%" Pd, i); |
| 1577 p.name = &String::ZoneHandle(Z, Symbols::New(name)); | 1577 p.name = &String::ZoneHandle(Z, Symbols::New(T, name)); |
| 1578 p.type = &Object::dynamic_type(); | 1578 p.type = &Object::dynamic_type(); |
| 1579 params.parameters->Add(p); | 1579 params.parameters->Add(p); |
| 1580 params.num_fixed_parameters++; | 1580 params.num_fixed_parameters++; |
| 1581 } | 1581 } |
| 1582 ASSERT(desc.PositionalCount() == params.num_fixed_parameters); | 1582 ASSERT(desc.PositionalCount() == params.num_fixed_parameters); |
| 1583 | 1583 |
| 1584 // Named parameters. | 1584 // Named parameters. |
| 1585 for (; i < desc.Count(); ++i) { | 1585 for (; i < desc.Count(); ++i) { |
| 1586 ParamDesc p; | 1586 ParamDesc p; |
| 1587 intptr_t index = i - desc.PositionalCount(); | 1587 intptr_t index = i - desc.PositionalCount(); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 Isolate::Current()->object_store()->closure_class()); | 1681 Isolate::Current()->object_store()->closure_class()); |
| 1682 | 1682 |
| 1683 const Class& owner = Class::Handle(Z, func.Owner()); | 1683 const Class& owner = Class::Handle(Z, func.Owner()); |
| 1684 ASSERT(!owner.IsNull()); | 1684 ASSERT(!owner.IsNull()); |
| 1685 const String& name = String::Handle(Z, func.name()); | 1685 const String& name = String::Handle(Z, func.name()); |
| 1686 AstNode* function_object = NULL; | 1686 AstNode* function_object = NULL; |
| 1687 if (owner.raw() == closure_cls.raw() && name.Equals(Symbols::Call())) { | 1687 if (owner.raw() == closure_cls.raw() && name.Equals(Symbols::Call())) { |
| 1688 function_object = receiver; | 1688 function_object = receiver; |
| 1689 } else { | 1689 } else { |
| 1690 const String& getter_name = String::ZoneHandle(Z, | 1690 const String& getter_name = String::ZoneHandle(Z, |
| 1691 Symbols::New(String::Handle(Z, Field::GetterSymbol(name)))); | 1691 Field::GetterSymbol(name)); |
| 1692 function_object = new(Z) InstanceCallNode( | 1692 function_object = new(Z) InstanceCallNode( |
| 1693 token_pos, receiver, getter_name, no_args); | 1693 token_pos, receiver, getter_name, no_args); |
| 1694 } | 1694 } |
| 1695 | 1695 |
| 1696 // Pass arguments 1..n to the closure call. | 1696 // Pass arguments 1..n to the closure call. |
| 1697 ArgumentListNode* args = new(Z) ArgumentListNode(token_pos); | 1697 ArgumentListNode* args = new(Z) ArgumentListNode(token_pos); |
| 1698 const Array& names = Array::Handle( | 1698 const Array& names = Array::Handle( |
| 1699 Z, Array::New(desc.NamedCount(), Heap::kOld)); | 1699 Z, Array::New(desc.NamedCount(), Heap::kOld)); |
| 1700 // Positional parameters. | 1700 // Positional parameters. |
| 1701 intptr_t i = 1; | 1701 intptr_t i = 1; |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2084 const String& name, | 2084 const String& name, |
| 2085 ArgumentListNode* arguments, | 2085 ArgumentListNode* arguments, |
| 2086 bool resolve_getter, | 2086 bool resolve_getter, |
| 2087 bool* is_no_such_method) { | 2087 bool* is_no_such_method) { |
| 2088 const Class& super_class = Class::Handle(Z, current_class().SuperClass()); | 2088 const Class& super_class = Class::Handle(Z, current_class().SuperClass()); |
| 2089 if (super_class.IsNull()) { | 2089 if (super_class.IsNull()) { |
| 2090 ReportError(token_pos, "class '%s' does not have a superclass", | 2090 ReportError(token_pos, "class '%s' does not have a superclass", |
| 2091 String::Handle(Z, current_class().Name()).ToCString()); | 2091 String::Handle(Z, current_class().Name()).ToCString()); |
| 2092 } | 2092 } |
| 2093 Function& super_func = Function::Handle(Z, | 2093 Function& super_func = Function::Handle(Z, |
| 2094 Resolver::ResolveDynamicAnyArgs(super_class, name)); | 2094 Resolver::ResolveDynamicAnyArgs(Z, super_class, name)); |
| 2095 if (!super_func.IsNull() && | 2095 if (!super_func.IsNull() && |
| 2096 !super_func.AreValidArguments(arguments->length(), | 2096 !super_func.AreValidArguments(arguments->length(), |
| 2097 arguments->names(), | 2097 arguments->names(), |
| 2098 NULL)) { | 2098 NULL)) { |
| 2099 super_func = Function::null(); | 2099 super_func = Function::null(); |
| 2100 } else if (super_func.IsNull() && resolve_getter) { | 2100 } else if (super_func.IsNull() && resolve_getter) { |
| 2101 const String& getter_name = String::ZoneHandle(Z, Field::GetterName(name)); | 2101 const String& getter_name = String::ZoneHandle(Z, Field::GetterName(name)); |
| 2102 super_func = Resolver::ResolveDynamicAnyArgs(super_class, getter_name); | 2102 super_func = Resolver::ResolveDynamicAnyArgs(Z, super_class, getter_name); |
| 2103 ASSERT(super_func.IsNull() || | 2103 ASSERT(super_func.IsNull() || |
| 2104 (super_func.kind() != RawFunction::kImplicitStaticFinalGetter)); | 2104 (super_func.kind() != RawFunction::kImplicitStaticFinalGetter)); |
| 2105 } | 2105 } |
| 2106 if (super_func.IsNull()) { | 2106 if (super_func.IsNull()) { |
| 2107 super_func = | 2107 super_func = Resolver::ResolveDynamicAnyArgs(Z, |
| 2108 Resolver::ResolveDynamicAnyArgs(super_class, Symbols::NoSuchMethod()); | 2108 super_class, Symbols::NoSuchMethod()); |
| 2109 ASSERT(!super_func.IsNull()); | 2109 ASSERT(!super_func.IsNull()); |
| 2110 *is_no_such_method = true; | 2110 *is_no_such_method = true; |
| 2111 } else { | 2111 } else { |
| 2112 *is_no_such_method = false; | 2112 *is_no_such_method = false; |
| 2113 } | 2113 } |
| 2114 return super_func.raw(); | 2114 return super_func.raw(); |
| 2115 } | 2115 } |
| 2116 | 2116 |
| 2117 | 2117 |
| 2118 StaticCallNode* Parser::BuildInvocationMirrorAllocation( | 2118 StaticCallNode* Parser::BuildInvocationMirrorAllocation( |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2232 } | 2232 } |
| 2233 | 2233 |
| 2234 | 2234 |
| 2235 AstNode* Parser::BuildUnarySuperOperator(Token::Kind op, PrimaryNode* super) { | 2235 AstNode* Parser::BuildUnarySuperOperator(Token::Kind op, PrimaryNode* super) { |
| 2236 ASSERT(super->IsSuper()); | 2236 ASSERT(super->IsSuper()); |
| 2237 AstNode* super_op = NULL; | 2237 AstNode* super_op = NULL; |
| 2238 const TokenPosition super_pos = super->token_pos(); | 2238 const TokenPosition super_pos = super->token_pos(); |
| 2239 if ((op == Token::kNEGATE) || | 2239 if ((op == Token::kNEGATE) || |
| 2240 (op == Token::kBIT_NOT)) { | 2240 (op == Token::kBIT_NOT)) { |
| 2241 // Resolve the operator function in the superclass. | 2241 // Resolve the operator function in the superclass. |
| 2242 const String& operator_function_name = | 2242 const String& operator_function_name = Symbols::Token(op); |
| 2243 String::ZoneHandle(Z, Symbols::New(Token::Str(op))); | |
| 2244 ArgumentListNode* op_arguments = new ArgumentListNode(super_pos); | 2243 ArgumentListNode* op_arguments = new ArgumentListNode(super_pos); |
| 2245 AstNode* receiver = LoadReceiver(super_pos); | 2244 AstNode* receiver = LoadReceiver(super_pos); |
| 2246 op_arguments->Add(receiver); | 2245 op_arguments->Add(receiver); |
| 2247 const bool kResolveGetter = false; | 2246 const bool kResolveGetter = false; |
| 2248 bool is_no_such_method = false; | 2247 bool is_no_such_method = false; |
| 2249 const Function& super_operator = Function::ZoneHandle(Z, | 2248 const Function& super_operator = Function::ZoneHandle(Z, |
| 2250 GetSuperFunction(super_pos, | 2249 GetSuperFunction(super_pos, |
| 2251 operator_function_name, | 2250 operator_function_name, |
| 2252 op_arguments, | 2251 op_arguments, |
| 2253 kResolveGetter, | 2252 kResolveGetter, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2293 | 2292 |
| 2294 ASSERT(Token::Precedence(op) >= Token::Precedence(Token::kEQ)); | 2293 ASSERT(Token::Precedence(op) >= Token::Precedence(Token::kEQ)); |
| 2295 AstNode* other_operand = ParseBinaryExpr(Token::Precedence(op) + 1); | 2294 AstNode* other_operand = ParseBinaryExpr(Token::Precedence(op) + 1); |
| 2296 | 2295 |
| 2297 ArgumentListNode* op_arguments = new ArgumentListNode(operator_pos); | 2296 ArgumentListNode* op_arguments = new ArgumentListNode(operator_pos); |
| 2298 AstNode* receiver = LoadReceiver(operator_pos); | 2297 AstNode* receiver = LoadReceiver(operator_pos); |
| 2299 op_arguments->Add(receiver); | 2298 op_arguments->Add(receiver); |
| 2300 op_arguments->Add(other_operand); | 2299 op_arguments->Add(other_operand); |
| 2301 | 2300 |
| 2302 // Resolve the operator function in the superclass. | 2301 // Resolve the operator function in the superclass. |
| 2303 const String& operator_function_name = | 2302 const String& operator_function_name = Symbols::Token(op); |
| 2304 String::ZoneHandle(Z, Symbols::New(Token::Str(op))); | |
| 2305 const bool kResolveGetter = false; | 2303 const bool kResolveGetter = false; |
| 2306 bool is_no_such_method = false; | 2304 bool is_no_such_method = false; |
| 2307 const Function& super_operator = Function::ZoneHandle(Z, | 2305 const Function& super_operator = Function::ZoneHandle(Z, |
| 2308 GetSuperFunction(operator_pos, | 2306 GetSuperFunction(operator_pos, |
| 2309 operator_function_name, | 2307 operator_function_name, |
| 2310 op_arguments, | 2308 op_arguments, |
| 2311 kResolveGetter, | 2309 kResolveGetter, |
| 2312 &is_no_such_method)); | 2310 &is_no_such_method)); |
| 2313 if (is_no_such_method) { | 2311 if (is_no_such_method) { |
| 2314 op_arguments = BuildNoSuchMethodArguments( | 2312 op_arguments = BuildNoSuchMethodArguments( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2352 if (super_class.IsNull()) { | 2350 if (super_class.IsNull()) { |
| 2353 ReportError("class '%s' does not have a superclass", | 2351 ReportError("class '%s' does not have a superclass", |
| 2354 String::Handle(Z, current_class().Name()).ToCString()); | 2352 String::Handle(Z, current_class().Name()).ToCString()); |
| 2355 } | 2353 } |
| 2356 AstNode* implicit_argument = LoadReceiver(field_pos); | 2354 AstNode* implicit_argument = LoadReceiver(field_pos); |
| 2357 | 2355 |
| 2358 const String& getter_name = | 2356 const String& getter_name = |
| 2359 String::ZoneHandle(Z, Field::LookupGetterSymbol(field_name)); | 2357 String::ZoneHandle(Z, Field::LookupGetterSymbol(field_name)); |
| 2360 Function& super_getter = Function::ZoneHandle(Z); | 2358 Function& super_getter = Function::ZoneHandle(Z); |
| 2361 if (!getter_name.IsNull()) { | 2359 if (!getter_name.IsNull()) { |
| 2362 super_getter = Resolver::ResolveDynamicAnyArgs(super_class, getter_name); | 2360 super_getter = Resolver::ResolveDynamicAnyArgs(Z, super_class, getter_name); |
| 2363 } | 2361 } |
| 2364 if (super_getter.IsNull()) { | 2362 if (super_getter.IsNull()) { |
| 2365 const String& setter_name = | 2363 const String& setter_name = |
| 2366 String::ZoneHandle(Z, Field::LookupSetterSymbol(field_name)); | 2364 String::ZoneHandle(Z, Field::LookupSetterSymbol(field_name)); |
| 2367 Function& super_setter = Function::ZoneHandle(Z); | 2365 Function& super_setter = Function::ZoneHandle(Z); |
| 2368 if (!setter_name.IsNull()) { | 2366 if (!setter_name.IsNull()) { |
| 2369 super_setter = Resolver::ResolveDynamicAnyArgs(super_class, setter_name); | 2367 super_setter = Resolver::ResolveDynamicAnyArgs(Z, |
| 2368 super_class, setter_name); |
| 2370 } | 2369 } |
| 2371 if (super_setter.IsNull()) { | 2370 if (super_setter.IsNull()) { |
| 2372 // Check if this is an access to an implicit closure using 'super'. | 2371 // Check if this is an access to an implicit closure using 'super'. |
| 2373 // If a function exists of the specified field_name then try | 2372 // If a function exists of the specified field_name then try |
| 2374 // accessing it as a getter, at runtime we will handle this by | 2373 // accessing it as a getter, at runtime we will handle this by |
| 2375 // creating an implicit closure of the function and returning it. | 2374 // creating an implicit closure of the function and returning it. |
| 2376 const Function& super_function = Function::ZoneHandle(Z, | 2375 const Function& super_function = Function::ZoneHandle(Z, |
| 2377 Resolver::ResolveDynamicAnyArgs(super_class, field_name)); | 2376 Resolver::ResolveDynamicAnyArgs(Z, super_class, field_name)); |
| 2378 if (!super_function.IsNull()) { | 2377 if (!super_function.IsNull()) { |
| 2379 // In case CreateAssignmentNode is called later on this | 2378 // In case CreateAssignmentNode is called later on this |
| 2380 // CreateImplicitClosureNode, it will be replaced by a StaticSetterNode. | 2379 // CreateImplicitClosureNode, it will be replaced by a StaticSetterNode. |
| 2381 return CreateImplicitClosureNode(super_function, | 2380 return CreateImplicitClosureNode(super_function, |
| 2382 field_pos, | 2381 field_pos, |
| 2383 implicit_argument); | 2382 implicit_argument); |
| 2384 } | 2383 } |
| 2385 // No function or field exists of the specified field_name. | 2384 // No function or field exists of the specified field_name. |
| 2386 // Emit a StaticGetterNode anyway, so that noSuchMethod gets called. | 2385 // Emit a StaticGetterNode anyway, so that noSuchMethod gets called. |
| 2387 } | 2386 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2399 const Class& super_class = Class::Handle(Z, cls.SuperClass()); | 2398 const Class& super_class = Class::Handle(Z, cls.SuperClass()); |
| 2400 // Omit the implicit super() if there is no super class (i.e. | 2399 // Omit the implicit super() if there is no super class (i.e. |
| 2401 // we're not compiling class Object), or if the super class is an | 2400 // we're not compiling class Object), or if the super class is an |
| 2402 // artificially generated "wrapper class" that has no constructor. | 2401 // artificially generated "wrapper class" that has no constructor. |
| 2403 if (super_class.IsNull() || | 2402 if (super_class.IsNull() || |
| 2404 (super_class.num_native_fields() > 0 && | 2403 (super_class.num_native_fields() > 0 && |
| 2405 Class::Handle(Z, super_class.SuperClass()).IsObjectClass())) { | 2404 Class::Handle(Z, super_class.SuperClass()).IsObjectClass())) { |
| 2406 return NULL; | 2405 return NULL; |
| 2407 } | 2406 } |
| 2408 String& super_ctor_name = String::Handle(Z, super_class.Name()); | 2407 String& super_ctor_name = String::Handle(Z, super_class.Name()); |
| 2409 super_ctor_name = Symbols::FromConcat(super_ctor_name, Symbols::Dot()); | 2408 super_ctor_name = Symbols::FromDot(T, super_ctor_name); |
| 2410 | 2409 |
| 2411 ArgumentListNode* arguments = new ArgumentListNode(supercall_pos); | 2410 ArgumentListNode* arguments = new ArgumentListNode(supercall_pos); |
| 2412 // Implicit 'this' parameter is the first argument. | 2411 // Implicit 'this' parameter is the first argument. |
| 2413 AstNode* implicit_argument = new LoadLocalNode(supercall_pos, receiver); | 2412 AstNode* implicit_argument = new LoadLocalNode(supercall_pos, receiver); |
| 2414 arguments->Add(implicit_argument); | 2413 arguments->Add(implicit_argument); |
| 2415 | 2414 |
| 2416 // If this is a super call in a forwarding constructor, add the user- | 2415 // If this is a super call in a forwarding constructor, add the user- |
| 2417 // defined arguments to the super call and adjust the the super | 2416 // defined arguments to the super call and adjust the the super |
| 2418 // constructor name to the respective named constructor if necessary. | 2417 // constructor name to the respective named constructor if necessary. |
| 2419 if (forwarding_args != NULL) { | 2418 if (forwarding_args != NULL) { |
| 2420 for (int i = 0; i < forwarding_args->length(); i++) { | 2419 for (int i = 0; i < forwarding_args->length(); i++) { |
| 2421 arguments->Add(forwarding_args->NodeAt(i)); | 2420 arguments->Add(forwarding_args->NodeAt(i)); |
| 2422 } | 2421 } |
| 2423 String& ctor_name = String::Handle(Z, current_function().name()); | 2422 String& ctor_name = String::Handle(Z, current_function().name()); |
| 2424 String& class_name = String::Handle(Z, cls.Name()); | 2423 String& class_name = String::Handle(Z, cls.Name()); |
| 2425 if (ctor_name.Length() > class_name.Length() + 1) { | 2424 if (ctor_name.Length() > class_name.Length() + 1) { |
| 2426 // Generating a forwarding call to a named constructor 'C.n'. | 2425 // Generating a forwarding call to a named constructor 'C.n'. |
| 2427 // Add the constructor name 'n' to the super constructor. | 2426 // Add the constructor name 'n' to the super constructor. |
| 2428 const intptr_t kLen = class_name.Length() + 1; | 2427 const intptr_t kLen = class_name.Length() + 1; |
| 2429 ctor_name = Symbols::New(ctor_name, kLen, ctor_name.Length() - kLen); | 2428 ctor_name = Symbols::New(T, ctor_name, kLen, ctor_name.Length() - kLen); |
| 2430 super_ctor_name = Symbols::FromConcat(super_ctor_name, ctor_name); | 2429 super_ctor_name = Symbols::FromConcat(T, super_ctor_name, ctor_name); |
| 2431 } | 2430 } |
| 2432 } | 2431 } |
| 2433 | 2432 |
| 2434 // Resolve super constructor function and check arguments. | 2433 // Resolve super constructor function and check arguments. |
| 2435 const Function& super_ctor = Function::ZoneHandle(Z, | 2434 const Function& super_ctor = Function::ZoneHandle(Z, |
| 2436 super_class.LookupConstructor(super_ctor_name)); | 2435 super_class.LookupConstructor(super_ctor_name)); |
| 2437 if (super_ctor.IsNull()) { | 2436 if (super_ctor.IsNull()) { |
| 2438 ReportError(supercall_pos, | 2437 ReportError(supercall_pos, |
| 2439 "unresolved implicit call to super constructor '%s()'", | 2438 "unresolved implicit call to super constructor '%s()'", |
| 2440 String::Handle(Z, super_class.Name()).ToCString()); | 2439 String::Handle(Z, super_class.Name()).ToCString()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2458 | 2457 |
| 2459 StaticCallNode* Parser::ParseSuperInitializer(const Class& cls, | 2458 StaticCallNode* Parser::ParseSuperInitializer(const Class& cls, |
| 2460 LocalVariable* receiver) { | 2459 LocalVariable* receiver) { |
| 2461 TRACE_PARSER("ParseSuperInitializer"); | 2460 TRACE_PARSER("ParseSuperInitializer"); |
| 2462 ASSERT(CurrentToken() == Token::kSUPER); | 2461 ASSERT(CurrentToken() == Token::kSUPER); |
| 2463 const TokenPosition supercall_pos = TokenPos(); | 2462 const TokenPosition supercall_pos = TokenPos(); |
| 2464 ConsumeToken(); | 2463 ConsumeToken(); |
| 2465 const Class& super_class = Class::Handle(Z, cls.SuperClass()); | 2464 const Class& super_class = Class::Handle(Z, cls.SuperClass()); |
| 2466 ASSERT(!super_class.IsNull()); | 2465 ASSERT(!super_class.IsNull()); |
| 2467 String& ctor_name = String::Handle(Z, super_class.Name()); | 2466 String& ctor_name = String::Handle(Z, super_class.Name()); |
| 2468 ctor_name = Symbols::FromConcat(ctor_name, Symbols::Dot()); | 2467 ctor_name = String::Concat(ctor_name, Symbols::Dot()); |
| 2469 if (CurrentToken() == Token::kPERIOD) { | 2468 if (CurrentToken() == Token::kPERIOD) { |
| 2470 ConsumeToken(); | 2469 ConsumeToken(); |
| 2471 ctor_name = Symbols::FromConcat( | 2470 ctor_name = Symbols::FromConcat(T, |
| 2472 ctor_name, *ExpectIdentifier("constructor name expected")); | 2471 ctor_name, *ExpectIdentifier("constructor name expected")); |
| 2473 } | 2472 } |
| 2474 CheckToken(Token::kLPAREN, "parameter list expected"); | 2473 CheckToken(Token::kLPAREN, "parameter list expected"); |
| 2475 | 2474 |
| 2476 ArgumentListNode* arguments = new ArgumentListNode(supercall_pos); | 2475 ArgumentListNode* arguments = new ArgumentListNode(supercall_pos); |
| 2477 // 'this' parameter is the first argument to super class constructor. | 2476 // 'this' parameter is the first argument to super class constructor. |
| 2478 AstNode* implicit_argument = new LoadLocalNode(supercall_pos, receiver); | 2477 AstNode* implicit_argument = new LoadLocalNode(supercall_pos, receiver); |
| 2479 arguments->Add(implicit_argument); | 2478 arguments->Add(implicit_argument); |
| 2480 | 2479 |
| 2481 // 'this' parameter must not be accessible to the other super call arguments. | 2480 // 'this' parameter must not be accessible to the other super call arguments. |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2855 const TokenPosition call_pos = TokenPos(); | 2854 const TokenPosition call_pos = TokenPos(); |
| 2856 ConsumeToken(); | 2855 ConsumeToken(); |
| 2857 String& ctor_name = String::Handle(Z, cls.Name()); | 2856 String& ctor_name = String::Handle(Z, cls.Name()); |
| 2858 GrowableHandlePtrArray<const String> pieces(Z, 3); | 2857 GrowableHandlePtrArray<const String> pieces(Z, 3); |
| 2859 pieces.Add(ctor_name); | 2858 pieces.Add(ctor_name); |
| 2860 pieces.Add(Symbols::Dot()); | 2859 pieces.Add(Symbols::Dot()); |
| 2861 if (CurrentToken() == Token::kPERIOD) { | 2860 if (CurrentToken() == Token::kPERIOD) { |
| 2862 ConsumeToken(); | 2861 ConsumeToken(); |
| 2863 pieces.Add(*ExpectIdentifier("constructor name expected")); | 2862 pieces.Add(*ExpectIdentifier("constructor name expected")); |
| 2864 } | 2863 } |
| 2865 ctor_name = Symbols::FromConcatAll(pieces); | 2864 ctor_name = Symbols::FromConcatAll(T, pieces); |
| 2866 CheckToken(Token::kLPAREN, "parameter list expected"); | 2865 CheckToken(Token::kLPAREN, "parameter list expected"); |
| 2867 | 2866 |
| 2868 ArgumentListNode* arguments = new ArgumentListNode(call_pos); | 2867 ArgumentListNode* arguments = new ArgumentListNode(call_pos); |
| 2869 // 'this' parameter is the first argument to constructor. | 2868 // 'this' parameter is the first argument to constructor. |
| 2870 AstNode* implicit_argument = new LoadLocalNode(call_pos, receiver); | 2869 AstNode* implicit_argument = new LoadLocalNode(call_pos, receiver); |
| 2871 arguments->Add(implicit_argument); | 2870 arguments->Add(implicit_argument); |
| 2872 | 2871 |
| 2873 receiver->set_invisible(true); | 2872 receiver->set_invisible(true); |
| 2874 ParseActualParameters(arguments, kAllowConst); | 2873 ParseActualParameters(arguments, kAllowConst); |
| 2875 receiver->set_invisible(false); | 2874 receiver->set_invisible(false); |
| (...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3615 } | 3614 } |
| 3616 | 3615 |
| 3617 // Now that we know the parameter list, we can distinguish between the | 3616 // Now that we know the parameter list, we can distinguish between the |
| 3618 // unary and binary operator -. | 3617 // unary and binary operator -. |
| 3619 if (method->has_operator) { | 3618 if (method->has_operator) { |
| 3620 if ((method->operator_token == Token::kSUB) && | 3619 if ((method->operator_token == Token::kSUB) && |
| 3621 (method->params.num_fixed_parameters == 1)) { | 3620 (method->params.num_fixed_parameters == 1)) { |
| 3622 // Patch up name for unary operator - so it does not clash with the | 3621 // Patch up name for unary operator - so it does not clash with the |
| 3623 // name for binary operator -. | 3622 // name for binary operator -. |
| 3624 method->operator_token = Token::kNEGATE; | 3623 method->operator_token = Token::kNEGATE; |
| 3625 *method->name = Symbols::New(Token::Str(Token::kNEGATE)); | 3624 *method->name = Symbols::Token(Token::kNEGATE).raw(); |
| 3626 } | 3625 } |
| 3627 CheckOperatorArity(*method); | 3626 CheckOperatorArity(*method); |
| 3628 } | 3627 } |
| 3629 | 3628 |
| 3630 // Mangle the name for getter and setter functions and check function | 3629 // Mangle the name for getter and setter functions and check function |
| 3631 // arity. | 3630 // arity. |
| 3632 if (method->IsGetter() || method->IsSetter()) { | 3631 if (method->IsGetter() || method->IsSetter()) { |
| 3633 int expected_num_parameters = 0; | 3632 int expected_num_parameters = 0; |
| 3634 if (method->IsGetter()) { | 3633 if (method->IsGetter()) { |
| 3635 expected_num_parameters = (method->has_static) ? 0 : 1; | 3634 expected_num_parameters = (method->has_static) ? 0 : 1; |
| 3636 method->dict_name = method->name; | 3635 method->dict_name = method->name; |
| 3637 method->name = &String::ZoneHandle(Z, Field::GetterSymbol(*method->name)); | 3636 method->name = &String::ZoneHandle(Z, Field::GetterSymbol(*method->name)); |
| 3638 } else { | 3637 } else { |
| 3639 ASSERT(method->IsSetter()); | 3638 ASSERT(method->IsSetter()); |
| 3640 expected_num_parameters = (method->has_static) ? 1 : 2; | 3639 expected_num_parameters = (method->has_static) ? 1 : 2; |
| 3641 method->dict_name = &String::ZoneHandle(Z, | 3640 method->dict_name = &String::ZoneHandle(Z, |
| 3642 Symbols::FromConcat(*method->name, Symbols::Equals())); | 3641 Symbols::FromConcat(T, *method->name, Symbols::Equals())); |
| 3643 method->name = &String::ZoneHandle(Z, Field::SetterSymbol(*method->name)); | 3642 method->name = &String::ZoneHandle(Z, Field::SetterSymbol(*method->name)); |
| 3644 } | 3643 } |
| 3645 if ((method->params.num_fixed_parameters != expected_num_parameters) || | 3644 if ((method->params.num_fixed_parameters != expected_num_parameters) || |
| 3646 (method->params.num_optional_parameters != 0)) { | 3645 (method->params.num_optional_parameters != 0)) { |
| 3647 ReportError(method->name_pos, "illegal %s parameters", | 3646 ReportError(method->name_pos, "illegal %s parameters", |
| 3648 method->IsGetter() ? "getter" : "setter"); | 3647 method->IsGetter() ? "getter" : "setter"); |
| 3649 } | 3648 } |
| 3650 } | 3649 } |
| 3651 | 3650 |
| 3652 // Parse redirecting factory constructor. | 3651 // Parse redirecting factory constructor. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3717 ConsumeToken(); // Colon. | 3716 ConsumeToken(); // Colon. |
| 3718 ExpectToken(Token::kTHIS); | 3717 ExpectToken(Token::kTHIS); |
| 3719 GrowableHandlePtrArray<const String> pieces(Z, 3); | 3718 GrowableHandlePtrArray<const String> pieces(Z, 3); |
| 3720 pieces.Add(members->class_name()); | 3719 pieces.Add(members->class_name()); |
| 3721 pieces.Add(Symbols::Dot()); | 3720 pieces.Add(Symbols::Dot()); |
| 3722 if (CurrentToken() == Token::kPERIOD) { | 3721 if (CurrentToken() == Token::kPERIOD) { |
| 3723 ConsumeToken(); | 3722 ConsumeToken(); |
| 3724 pieces.Add(*ExpectIdentifier("constructor name expected")); | 3723 pieces.Add(*ExpectIdentifier("constructor name expected")); |
| 3725 } | 3724 } |
| 3726 String& redir_name = | 3725 String& redir_name = |
| 3727 String::ZoneHandle(Z, Symbols::FromConcatAll(pieces)); | 3726 String::ZoneHandle(Z, Symbols::FromConcatAll(T, pieces)); |
| 3728 | 3727 |
| 3729 method->redirect_name = &redir_name; | 3728 method->redirect_name = &redir_name; |
| 3730 CheckToken(Token::kLPAREN); | 3729 CheckToken(Token::kLPAREN); |
| 3731 SkipToMatchingParenthesis(); | 3730 SkipToMatchingParenthesis(); |
| 3732 } else { | 3731 } else { |
| 3733 SkipInitializers(); | 3732 SkipInitializers(); |
| 3734 } | 3733 } |
| 3735 } | 3734 } |
| 3736 | 3735 |
| 3737 // Only constructors can redirect to another method. | 3736 // Only constructors can redirect to another method. |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4248 member.kind = RawFunction::kConstructor; | 4247 member.kind = RawFunction::kConstructor; |
| 4249 GrowableHandlePtrArray<const String> to_concat(Z, 3); | 4248 GrowableHandlePtrArray<const String> to_concat(Z, 3); |
| 4250 to_concat.Add(*member.name); | 4249 to_concat.Add(*member.name); |
| 4251 to_concat.Add(Symbols::Dot()); | 4250 to_concat.Add(Symbols::Dot()); |
| 4252 if (CurrentToken() == Token::kPERIOD) { | 4251 if (CurrentToken() == Token::kPERIOD) { |
| 4253 // Named constructor. | 4252 // Named constructor. |
| 4254 ConsumeToken(); | 4253 ConsumeToken(); |
| 4255 member.dict_name = ExpectIdentifier("identifier expected"); | 4254 member.dict_name = ExpectIdentifier("identifier expected"); |
| 4256 to_concat.Add(*member.dict_name); | 4255 to_concat.Add(*member.dict_name); |
| 4257 } | 4256 } |
| 4258 *member.name = Symbols::FromConcatAll(to_concat); | 4257 *member.name = Symbols::FromConcatAll(T, to_concat); |
| 4259 CheckToken(Token::kLPAREN); | 4258 CheckToken(Token::kLPAREN); |
| 4260 } else if ((CurrentToken() == Token::kGET) && !member.has_var && | 4259 } else if ((CurrentToken() == Token::kGET) && !member.has_var && |
| 4261 (LookaheadToken(1) != Token::kLPAREN) && | 4260 (LookaheadToken(1) != Token::kLPAREN) && |
| 4262 (LookaheadToken(1) != Token::kASSIGN) && | 4261 (LookaheadToken(1) != Token::kASSIGN) && |
| 4263 (LookaheadToken(1) != Token::kCOMMA) && | 4262 (LookaheadToken(1) != Token::kCOMMA) && |
| 4264 (LookaheadToken(1) != Token::kSEMICOLON)) { | 4263 (LookaheadToken(1) != Token::kSEMICOLON)) { |
| 4265 ConsumeToken(); | 4264 ConsumeToken(); |
| 4266 member.kind = RawFunction::kGetterFunction; | 4265 member.kind = RawFunction::kGetterFunction; |
| 4267 member.name_pos = this->TokenPos(); | 4266 member.name_pos = this->TokenPos(); |
| 4268 member.name = ExpectIdentifier("identifier expected"); | 4267 member.name = ExpectIdentifier("identifier expected"); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 4291 if (!Token::CanBeOverloaded(CurrentToken())) { | 4290 if (!Token::CanBeOverloaded(CurrentToken())) { |
| 4292 ReportError("invalid operator overloading"); | 4291 ReportError("invalid operator overloading"); |
| 4293 } | 4292 } |
| 4294 if (member.has_static) { | 4293 if (member.has_static) { |
| 4295 ReportError("operator overloading functions cannot be static"); | 4294 ReportError("operator overloading functions cannot be static"); |
| 4296 } | 4295 } |
| 4297 member.operator_token = CurrentToken(); | 4296 member.operator_token = CurrentToken(); |
| 4298 member.has_operator = true; | 4297 member.has_operator = true; |
| 4299 member.kind = RawFunction::kRegularFunction; | 4298 member.kind = RawFunction::kRegularFunction; |
| 4300 member.name_pos = this->TokenPos(); | 4299 member.name_pos = this->TokenPos(); |
| 4301 member.name = | 4300 member.name = &String::ZoneHandle(Z, Symbols::Token(member.operator_token)); |
| 4302 &String::ZoneHandle(Z, Symbols::New(Token::Str(member.operator_token))); | |
| 4303 ConsumeToken(); | 4301 ConsumeToken(); |
| 4304 } else if (IsIdentifier()) { | 4302 } else if (IsIdentifier()) { |
| 4305 member.name = CurrentLiteral(); | 4303 member.name = CurrentLiteral(); |
| 4306 member.name_pos = TokenPos(); | 4304 member.name_pos = TokenPos(); |
| 4307 ConsumeToken(); | 4305 ConsumeToken(); |
| 4308 } else { | 4306 } else { |
| 4309 ReportError("identifier expected"); | 4307 ReportError("identifier expected"); |
| 4310 } | 4308 } |
| 4311 | 4309 |
| 4312 ASSERT(member.name != NULL); | 4310 ASSERT(member.name != NULL); |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4752 const Smi& ordinal_value = Smi::Handle(Z, Smi::New(i)); | 4750 const Smi& ordinal_value = Smi::Handle(Z, Smi::New(i)); |
| 4753 enum_value.SetStaticValue(ordinal_value, true); | 4751 enum_value.SetStaticValue(ordinal_value, true); |
| 4754 enum_value.RecordStore(ordinal_value); | 4752 enum_value.RecordStore(ordinal_value); |
| 4755 i++; | 4753 i++; |
| 4756 | 4754 |
| 4757 // For the user-visible name of the enumeration value, we need to | 4755 // For the user-visible name of the enumeration value, we need to |
| 4758 // unmangle private names. | 4756 // unmangle private names. |
| 4759 if (enum_ident->CharAt(0) == '_') { | 4757 if (enum_ident->CharAt(0) == '_') { |
| 4760 *enum_ident = String::ScrubName(*enum_ident); | 4758 *enum_ident = String::ScrubName(*enum_ident); |
| 4761 } | 4759 } |
| 4762 enum_value_name = Symbols::FromConcat(name_prefix, *enum_ident); | 4760 enum_value_name = Symbols::FromConcat(T, name_prefix, *enum_ident); |
| 4763 enum_names.Add(enum_value_name, Heap::kOld); | 4761 enum_names.Add(enum_value_name, Heap::kOld); |
| 4764 | 4762 |
| 4765 ConsumeToken(); // Enum value name. | 4763 ConsumeToken(); // Enum value name. |
| 4766 if (CurrentToken() == Token::kCOMMA) { | 4764 if (CurrentToken() == Token::kCOMMA) { |
| 4767 ConsumeToken(); | 4765 ConsumeToken(); |
| 4768 } | 4766 } |
| 4769 } | 4767 } |
| 4770 ExpectToken(Token::kRBRACE); | 4768 ExpectToken(Token::kRBRACE); |
| 4771 | 4769 |
| 4772 const Class& helper_class = | 4770 const Class& helper_class = |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4819 cls.AddFields(enum_members.fields()); | 4817 cls.AddFields(enum_members.fields()); |
| 4820 const Array& functions = Array::Handle(Z, enum_members.MakeFunctionsArray()); | 4818 const Array& functions = Array::Handle(Z, enum_members.MakeFunctionsArray()); |
| 4821 cls.SetFunctions(functions); | 4819 cls.SetFunctions(functions); |
| 4822 } | 4820 } |
| 4823 | 4821 |
| 4824 | 4822 |
| 4825 // Add an implicit constructor to the given class. | 4823 // Add an implicit constructor to the given class. |
| 4826 void Parser::AddImplicitConstructor(const Class& cls) { | 4824 void Parser::AddImplicitConstructor(const Class& cls) { |
| 4827 // The implicit constructor is unnamed, has no explicit parameter. | 4825 // The implicit constructor is unnamed, has no explicit parameter. |
| 4828 String& ctor_name = String::ZoneHandle(Z, cls.Name()); | 4826 String& ctor_name = String::ZoneHandle(Z, cls.Name()); |
| 4829 ctor_name = Symbols::FromConcat(ctor_name, Symbols::Dot()); | 4827 ctor_name = Symbols::FromDot(T, ctor_name); |
| 4830 // To indicate that this is an implicit constructor, we set the | 4828 // To indicate that this is an implicit constructor, we set the |
| 4831 // token position and end token position of the function | 4829 // token position and end token position of the function |
| 4832 // to the token position of the class. | 4830 // to the token position of the class. |
| 4833 Function& ctor = Function::Handle(Z, | 4831 Function& ctor = Function::Handle(Z, |
| 4834 Function::New(ctor_name, | 4832 Function::New(ctor_name, |
| 4835 RawFunction::kConstructor, | 4833 RawFunction::kConstructor, |
| 4836 /* is_static = */ false, | 4834 /* is_static = */ false, |
| 4837 /* is_const = */ false, | 4835 /* is_const = */ false, |
| 4838 /* is_abstract = */ false, | 4836 /* is_abstract = */ false, |
| 4839 /* is_external = */ false, | 4837 /* is_external = */ false, |
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5771 ConsumeToken(); | 5769 ConsumeToken(); |
| 5772 String& lib_name = *ExpectIdentifier("library name expected"); | 5770 String& lib_name = *ExpectIdentifier("library name expected"); |
| 5773 if (CurrentToken() == Token::kPERIOD) { | 5771 if (CurrentToken() == Token::kPERIOD) { |
| 5774 GrowableHandlePtrArray<const String> pieces(Z, 3); | 5772 GrowableHandlePtrArray<const String> pieces(Z, 3); |
| 5775 pieces.Add(lib_name); | 5773 pieces.Add(lib_name); |
| 5776 while (CurrentToken() == Token::kPERIOD) { | 5774 while (CurrentToken() == Token::kPERIOD) { |
| 5777 ConsumeToken(); | 5775 ConsumeToken(); |
| 5778 pieces.Add(Symbols::Dot()); | 5776 pieces.Add(Symbols::Dot()); |
| 5779 pieces.Add(*ExpectIdentifier("malformed library name")); | 5777 pieces.Add(*ExpectIdentifier("malformed library name")); |
| 5780 } | 5778 } |
| 5781 lib_name = Symbols::FromConcatAll(pieces); | 5779 lib_name = Symbols::FromConcatAll(T, pieces); |
| 5782 } | 5780 } |
| 5783 library_.SetName(lib_name); | 5781 library_.SetName(lib_name); |
| 5784 ExpectSemicolon(); | 5782 ExpectSemicolon(); |
| 5785 } | 5783 } |
| 5786 | 5784 |
| 5787 | 5785 |
| 5788 void Parser::ParseIdentList(GrowableObjectArray* names) { | 5786 void Parser::ParseIdentList(GrowableObjectArray* names) { |
| 5789 if (!IsIdentifier()) { | 5787 if (!IsIdentifier()) { |
| 5790 ReportError("identifier expected"); | 5788 ReportError("identifier expected"); |
| 5791 } | 5789 } |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6581 const Function& found_func = Function::Handle( | 6579 const Function& found_func = Function::Handle( |
| 6582 Z, I->LookupClosureFunction(innermost_function(), func_pos)); | 6580 Z, I->LookupClosureFunction(innermost_function(), func_pos)); |
| 6583 if (!found_func.IsNull()) { | 6581 if (!found_func.IsNull()) { |
| 6584 ASSERT(found_func.IsSyncGenClosure()); | 6582 ASSERT(found_func.IsSyncGenClosure()); |
| 6585 body = found_func.raw(); | 6583 body = found_func.raw(); |
| 6586 body_closure_name = body.name(); | 6584 body_closure_name = body.name(); |
| 6587 } else { | 6585 } else { |
| 6588 // Create the closure containing the body of this generator function. | 6586 // Create the closure containing the body of this generator function. |
| 6589 String& generator_name = String::Handle(Z, innermost_function().name()); | 6587 String& generator_name = String::Handle(Z, innermost_function().name()); |
| 6590 body_closure_name = | 6588 body_closure_name = |
| 6591 Symbols::NewFormatted("<%s_sync_body>", generator_name.ToCString()); | 6589 Symbols::NewFormatted(T, "<%s_sync_body>", generator_name.ToCString()); |
| 6592 body_closure_name = Symbols::New(body_closure_name); | |
| 6593 body = Function::NewClosureFunction(body_closure_name, | 6590 body = Function::NewClosureFunction(body_closure_name, |
| 6594 innermost_function(), | 6591 innermost_function(), |
| 6595 func_pos); | 6592 func_pos); |
| 6596 body.set_is_generated_body(true); | 6593 body.set_is_generated_body(true); |
| 6597 body.set_result_type(Object::dynamic_type()); | 6594 body.set_result_type(Object::dynamic_type()); |
| 6598 is_new_closure = true; | 6595 is_new_closure = true; |
| 6599 } | 6596 } |
| 6600 | 6597 |
| 6601 ParamList closure_params; | 6598 ParamList closure_params; |
| 6602 AddSyncGenClosureParameters(&closure_params); | 6599 AddSyncGenClosureParameters(&closure_params); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6713 // compilation of this function. | 6710 // compilation of this function. |
| 6714 const Function& found_func = Function::Handle( | 6711 const Function& found_func = Function::Handle( |
| 6715 Z, I->LookupClosureFunction(innermost_function(), async_func_pos)); | 6712 Z, I->LookupClosureFunction(innermost_function(), async_func_pos)); |
| 6716 if (!found_func.IsNull()) { | 6713 if (!found_func.IsNull()) { |
| 6717 ASSERT(found_func.IsAsyncClosure()); | 6714 ASSERT(found_func.IsAsyncClosure()); |
| 6718 closure = found_func.raw(); | 6715 closure = found_func.raw(); |
| 6719 } else { | 6716 } else { |
| 6720 // Create the closure containing the body of this async function. | 6717 // Create the closure containing the body of this async function. |
| 6721 const String& async_func_name = | 6718 const String& async_func_name = |
| 6722 String::Handle(Z, innermost_function().name()); | 6719 String::Handle(Z, innermost_function().name()); |
| 6723 String& closure_name = String::Handle(Z, | 6720 String& closure_name = String::Handle(Z, Symbols::NewFormatted(T, |
| 6724 Symbols::NewFormatted("<%s_async_body>", async_func_name.ToCString())); | 6721 "<%s_async_body>", async_func_name.ToCString())); |
| 6725 closure = Function::NewClosureFunction( | 6722 closure = Function::NewClosureFunction( |
| 6726 closure_name, | 6723 closure_name, |
| 6727 innermost_function(), | 6724 innermost_function(), |
| 6728 async_func_pos); | 6725 async_func_pos); |
| 6729 closure.set_is_generated_body(true); | 6726 closure.set_is_generated_body(true); |
| 6730 closure.set_result_type(Object::dynamic_type()); | 6727 closure.set_result_type(Object::dynamic_type()); |
| 6731 is_new_closure = true; | 6728 is_new_closure = true; |
| 6732 } | 6729 } |
| 6733 // Create the parameter list for the async body closure. | 6730 // Create the parameter list for the async body closure. |
| 6734 ParamList closure_params; | 6731 ParamList closure_params; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6846 // compilation of this function. | 6843 // compilation of this function. |
| 6847 const Function& found_func = Function::Handle( | 6844 const Function& found_func = Function::Handle( |
| 6848 Z, I->LookupClosureFunction(innermost_function(), async_func_pos)); | 6845 Z, I->LookupClosureFunction(innermost_function(), async_func_pos)); |
| 6849 if (!found_func.IsNull()) { | 6846 if (!found_func.IsNull()) { |
| 6850 ASSERT(found_func.IsAsyncGenClosure()); | 6847 ASSERT(found_func.IsAsyncGenClosure()); |
| 6851 closure = found_func.raw(); | 6848 closure = found_func.raw(); |
| 6852 } else { | 6849 } else { |
| 6853 // Create the closure containing the body of this async generator function. | 6850 // Create the closure containing the body of this async generator function. |
| 6854 const String& async_generator_name = | 6851 const String& async_generator_name = |
| 6855 String::Handle(Z, innermost_function().name()); | 6852 String::Handle(Z, innermost_function().name()); |
| 6856 String& closure_name = String::Handle(Z, | 6853 const String& closure_name = String::Handle(Z, Symbols::NewFormatted(T, |
| 6857 Symbols::NewFormatted("<%s_async_gen_body>", | 6854 "<%s_async_gen_body>", async_generator_name.ToCString())); |
| 6858 async_generator_name.ToCString())); | 6855 closure = Function::NewClosureFunction(closure_name, |
| 6859 closure = Function::NewClosureFunction( | 6856 innermost_function(), |
| 6860 String::Handle(Z, Symbols::New(closure_name)), | 6857 async_func_pos); |
| 6861 innermost_function(), | |
| 6862 async_func_pos); | |
| 6863 closure.set_is_generated_body(true); | 6858 closure.set_is_generated_body(true); |
| 6864 closure.set_result_type(Object::dynamic_type()); | 6859 closure.set_result_type(Object::dynamic_type()); |
| 6865 is_new_closure = true; | 6860 is_new_closure = true; |
| 6866 } | 6861 } |
| 6867 | 6862 |
| 6868 ParamList closure_params; | 6863 ParamList closure_params; |
| 6869 AddAsyncGenClosureParameters(&closure_params); | 6864 AddAsyncGenClosureParameters(&closure_params); |
| 6870 | 6865 |
| 6871 if (is_new_closure) { | 6866 if (is_new_closure) { |
| 6872 // Add the parameters to the newly created closure. | 6867 // Add the parameters to the newly created closure. |
| (...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8154 SequenceNode* sequence = CloseBlock(); | 8149 SequenceNode* sequence = CloseBlock(); |
| 8155 sequence->set_label(label); | 8150 sequence->set_label(label); |
| 8156 if_node = sequence; | 8151 if_node = sequence; |
| 8157 } | 8152 } |
| 8158 return if_node; | 8153 return if_node; |
| 8159 } | 8154 } |
| 8160 | 8155 |
| 8161 | 8156 |
| 8162 // Return true if the type class of the given value implements the | 8157 // Return true if the type class of the given value implements the |
| 8163 // == operator. | 8158 // == operator. |
| 8164 static bool ImplementsEqualOperator(const Instance& value) { | 8159 static bool ImplementsEqualOperator(Zone* zone, const Instance& value) { |
| 8165 Class& cls = Class::Handle(value.clazz()); | 8160 Class& cls = Class::Handle(value.clazz()); |
| 8166 const Function& equal_op = Function::Handle( | 8161 const Function& equal_op = Function::Handle(zone, |
| 8167 Resolver::ResolveDynamicAnyArgs(cls, Symbols::EqualOperator())); | 8162 Resolver::ResolveDynamicAnyArgs(zone, cls, Symbols::EqualOperator())); |
| 8168 ASSERT(!equal_op.IsNull()); | 8163 ASSERT(!equal_op.IsNull()); |
| 8169 cls = equal_op.Owner(); | 8164 cls = equal_op.Owner(); |
| 8170 return !cls.IsObjectClass(); | 8165 return !cls.IsObjectClass(); |
| 8171 } | 8166 } |
| 8172 | 8167 |
| 8173 | 8168 |
| 8174 // Check that all case expressions are of the same type, either int, String, | 8169 // Check that all case expressions are of the same type, either int, String, |
| 8175 // or any other class that does not override the == operator. | 8170 // or any other class that does not override the == operator. |
| 8176 // The expressions are compile-time constants and are thus in the form | 8171 // The expressions are compile-time constants and are thus in the form |
| 8177 // of a LiteralNode. | 8172 // of a LiteralNode. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 8204 ReportError(val_pos, "all case expressions must be of same type"); | 8199 ReportError(val_pos, "all case expressions must be of same type"); |
| 8205 } | 8200 } |
| 8206 if (val.clazz() == I->object_store()->symbol_class()) { | 8201 if (val.clazz() == I->object_store()->symbol_class()) { |
| 8207 continue; | 8202 continue; |
| 8208 } | 8203 } |
| 8209 if (i == 0) { | 8204 if (i == 0) { |
| 8210 // The value is of some type other than int, String or double. | 8205 // The value is of some type other than int, String or double. |
| 8211 // Check that the type class does not override the == operator. | 8206 // Check that the type class does not override the == operator. |
| 8212 // Check this only in the first loop iteration since all values | 8207 // Check this only in the first loop iteration since all values |
| 8213 // are of the same type, which we check above. | 8208 // are of the same type, which we check above. |
| 8214 if (ImplementsEqualOperator(val)) { | 8209 if (ImplementsEqualOperator(Z, val)) { |
| 8215 ReportError(val_pos, | 8210 ReportError(val_pos, |
| 8216 "type class of case expression must not " | 8211 "type class of case expression must not " |
| 8217 "implement operator =="); | 8212 "implement operator =="); |
| 8218 } | 8213 } |
| 8219 } | 8214 } |
| 8220 } | 8215 } |
| 8221 if (first_value.IsInteger()) { | 8216 if (first_value.IsInteger()) { |
| 8222 return Type::Handle(Z, Type::IntType()).type_class(); | 8217 return Type::Handle(Z, Type::IntType()).type_class(); |
| 8223 } else if (first_value.IsString()) { | 8218 } else if (first_value.IsString()) { |
| 8224 return Type::Handle(Z, Type::StringType()).type_class(); | 8219 return Type::Handle(Z, Type::StringType()).type_class(); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8456 | 8451 |
| 8457 | 8452 |
| 8458 static LocalVariable* LookupSavedTryContextVar(LocalScope* scope) { | 8453 static LocalVariable* LookupSavedTryContextVar(LocalScope* scope) { |
| 8459 LocalVariable* var = | 8454 LocalVariable* var = |
| 8460 scope->LocalLookupVariable(Symbols::SavedTryContextVar()); | 8455 scope->LocalLookupVariable(Symbols::SavedTryContextVar()); |
| 8461 ASSERT((var != NULL) && !var->is_captured()); | 8456 ASSERT((var != NULL) && !var->is_captured()); |
| 8462 return var; | 8457 return var; |
| 8463 } | 8458 } |
| 8464 | 8459 |
| 8465 | 8460 |
| 8466 static LocalVariable* LookupAsyncSavedTryContextVar(LocalScope* scope, | 8461 static LocalVariable* LookupAsyncSavedTryContextVar(Thread* thread, |
| 8462 LocalScope* scope, |
| 8467 uint16_t try_index) { | 8463 uint16_t try_index) { |
| 8468 const String& async_saved_try_ctx_name = | 8464 Zone* zone = thread->zone(); |
| 8469 String::ZoneHandle(Symbols::NewFormatted( | 8465 const String& async_saved_try_ctx_name = String::ZoneHandle(zone, |
| 8470 "%s%d", | 8466 Symbols::NewFormatted(thread, |
| 8471 Symbols::AsyncSavedTryCtxVarPrefix().ToCString(), | 8467 "%s%d", |
| 8472 try_index)); | 8468 Symbols::AsyncSavedTryCtxVarPrefix().ToCString(), |
| 8469 try_index)); |
| 8473 LocalVariable* var = scope->LocalLookupVariable(async_saved_try_ctx_name); | 8470 LocalVariable* var = scope->LocalLookupVariable(async_saved_try_ctx_name); |
| 8474 ASSERT(var != NULL); | 8471 ASSERT(var != NULL); |
| 8475 return var; | 8472 return var; |
| 8476 } | 8473 } |
| 8477 | 8474 |
| 8478 | 8475 |
| 8479 // If the await or yield being parsed is in a try block, the continuation code | 8476 // If the await or yield being parsed is in a try block, the continuation code |
| 8480 // needs to restore the corresponding stack-based variable :saved_try_ctx_var, | 8477 // needs to restore the corresponding stack-based variable :saved_try_ctx_var, |
| 8481 // and the stack-based variable :saved_try_ctx_var of the outer try block. | 8478 // and the stack-based variable :saved_try_ctx_var of the outer try block. |
| 8482 // The inner :saved_try_ctx_var is used by a finally clause handling an | 8479 // The inner :saved_try_ctx_var is used by a finally clause handling an |
| (...skipping 17 matching lines...) Expand all Loading... |
| 8500 *outer_saved_try_ctx = NULL; | 8497 *outer_saved_try_ctx = NULL; |
| 8501 *outer_async_saved_try_ctx = NULL; | 8498 *outer_async_saved_try_ctx = NULL; |
| 8502 if (try_stack_ != NULL) { | 8499 if (try_stack_ != NULL) { |
| 8503 LocalScope* scope = try_stack_->try_block()->scope; | 8500 LocalScope* scope = try_stack_->try_block()->scope; |
| 8504 uint16_t try_index = try_stack_->try_index(); | 8501 uint16_t try_index = try_stack_->try_index(); |
| 8505 const int current_function_level = current_block_->scope->function_level(); | 8502 const int current_function_level = current_block_->scope->function_level(); |
| 8506 if (scope->function_level() == current_function_level) { | 8503 if (scope->function_level() == current_function_level) { |
| 8507 // The block declaring :saved_try_ctx_var variable is the parent of the | 8504 // The block declaring :saved_try_ctx_var variable is the parent of the |
| 8508 // pushed try block. | 8505 // pushed try block. |
| 8509 *saved_try_ctx = LookupSavedTryContextVar(scope->parent()); | 8506 *saved_try_ctx = LookupSavedTryContextVar(scope->parent()); |
| 8510 *async_saved_try_ctx = LookupAsyncSavedTryContextVar(async_temp_scope_, | 8507 *async_saved_try_ctx = LookupAsyncSavedTryContextVar(T, |
| 8511 try_index); | 8508 async_temp_scope_, try_index); |
| 8512 if ((try_stack_->outer_try() != NULL) && !try_stack_->inside_finally()) { | 8509 if ((try_stack_->outer_try() != NULL) && !try_stack_->inside_finally()) { |
| 8513 // Collecting the outer try scope is not necessary if we | 8510 // Collecting the outer try scope is not necessary if we |
| 8514 // are in a finally block. | 8511 // are in a finally block. |
| 8515 scope = try_stack_->outer_try()->try_block()->scope; | 8512 scope = try_stack_->outer_try()->try_block()->scope; |
| 8516 try_index = try_stack_->outer_try()->try_index(); | 8513 try_index = try_stack_->outer_try()->try_index(); |
| 8517 if (scope->function_level() == current_function_level) { | 8514 if (scope->function_level() == current_function_level) { |
| 8518 *outer_saved_try_ctx = LookupSavedTryContextVar(scope->parent()); | 8515 *outer_saved_try_ctx = LookupSavedTryContextVar(scope->parent()); |
| 8519 *outer_async_saved_try_ctx = | 8516 *outer_async_saved_try_ctx = LookupAsyncSavedTryContextVar(T, |
| 8520 LookupAsyncSavedTryContextVar(async_temp_scope_, try_index); | 8517 async_temp_scope_, try_index); |
| 8521 } | 8518 } |
| 8522 } | 8519 } |
| 8523 } | 8520 } |
| 8524 } | 8521 } |
| 8525 // An async or async* has an implicitly created try-catch around the | 8522 // An async or async* has an implicitly created try-catch around the |
| 8526 // function body, so the await or yield inside the async closure should always | 8523 // function body, so the await or yield inside the async closure should always |
| 8527 // be created with a try scope. | 8524 // be created with a try scope. |
| 8528 ASSERT((*saved_try_ctx != NULL) || | 8525 ASSERT((*saved_try_ctx != NULL) || |
| 8529 innermost_function().IsAsyncFunction() || | 8526 innermost_function().IsAsyncFunction() || |
| 8530 innermost_function().IsAsyncGenerator() || | 8527 innermost_function().IsAsyncGenerator() || |
| 8531 innermost_function().IsSyncGenClosure() || | 8528 innermost_function().IsSyncGenClosure() || |
| 8532 innermost_function().IsSyncGenerator()); | 8529 innermost_function().IsSyncGenerator()); |
| 8533 } | 8530 } |
| 8534 | 8531 |
| 8535 | 8532 |
| 8536 // Build an AST node for static call to Dart function print(str). | 8533 // Build an AST node for static call to Dart function print(str). |
| 8537 // Used during debugging to insert print in generated dart code. | 8534 // Used during debugging to insert print in generated dart code. |
| 8538 AstNode* Parser::DartPrint(const char* str) { | 8535 AstNode* Parser::DartPrint(const char* str) { |
| 8539 const Library& lib = Library::Handle(Library::CoreLibrary()); | 8536 const Library& lib = Library::Handle(Library::CoreLibrary()); |
| 8540 const Function& print_fn = Function::ZoneHandle( | 8537 const Function& print_fn = Function::ZoneHandle( |
| 8541 Z, lib.LookupFunctionAllowPrivate(Symbols::print())); | 8538 Z, lib.LookupFunctionAllowPrivate(Symbols::print())); |
| 8542 ASSERT(!print_fn.IsNull()); | 8539 ASSERT(!print_fn.IsNull()); |
| 8543 ArgumentListNode* one_arg = | 8540 ArgumentListNode* one_arg = |
| 8544 new(Z) ArgumentListNode(TokenPosition::kNoSource); | 8541 new(Z) ArgumentListNode(TokenPosition::kNoSource); |
| 8545 String& msg = String::ZoneHandle(Symbols::NewFormatted("%s", str)); | 8542 String& msg = String::ZoneHandle(Symbols::NewFormatted(T, "%s", str)); |
| 8546 one_arg->Add(new(Z) LiteralNode(TokenPosition::kNoSource, msg)); | 8543 one_arg->Add(new(Z) LiteralNode(TokenPosition::kNoSource, msg)); |
| 8547 AstNode* print_call = | 8544 AstNode* print_call = |
| 8548 new(Z) StaticCallNode(TokenPosition::kNoSource, print_fn, one_arg); | 8545 new(Z) StaticCallNode(TokenPosition::kNoSource, print_fn, one_arg); |
| 8549 return print_call; | 8546 return print_call; |
| 8550 } | 8547 } |
| 8551 | 8548 |
| 8552 | 8549 |
| 8553 AstNode* Parser::ParseAwaitForStatement(String* label_name) { | 8550 AstNode* Parser::ParseAwaitForStatement(String* label_name) { |
| 8554 TRACE_PARSER("ParseAwaitForStatement"); | 8551 TRACE_PARSER("ParseAwaitForStatement"); |
| 8555 ASSERT(IsAwaitKeyword()); | 8552 ASSERT(IsAwaitKeyword()); |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9195 } | 9192 } |
| 9196 // In case of async closures we need to restore the saved try context of an | 9193 // In case of async closures we need to restore the saved try context of an |
| 9197 // outer try block (if it exists). The current try block has already been | 9194 // outer try block (if it exists). The current try block has already been |
| 9198 // removed from the stack of try blocks. | 9195 // removed from the stack of try blocks. |
| 9199 if (is_async) { | 9196 if (is_async) { |
| 9200 if (try_stack_ != NULL) { | 9197 if (try_stack_ != NULL) { |
| 9201 LocalScope* scope = try_stack_->try_block()->scope; | 9198 LocalScope* scope = try_stack_->try_block()->scope; |
| 9202 if (scope->function_level() == current_block_->scope->function_level()) { | 9199 if (scope->function_level() == current_block_->scope->function_level()) { |
| 9203 LocalVariable* saved_try_ctx = | 9200 LocalVariable* saved_try_ctx = |
| 9204 LookupSavedTryContextVar(scope->parent()); | 9201 LookupSavedTryContextVar(scope->parent()); |
| 9205 LocalVariable* async_saved_try_ctx = | 9202 LocalVariable* async_saved_try_ctx = LookupAsyncSavedTryContextVar(T, |
| 9206 LookupAsyncSavedTryContextVar(async_temp_scope_, | 9203 async_temp_scope_, try_stack_->try_index()); |
| 9207 try_stack_->try_index()); | |
| 9208 current_block_->statements->Add( | 9204 current_block_->statements->Add( |
| 9209 new (Z) StoreLocalNode( | 9205 new (Z) StoreLocalNode( |
| 9210 TokenPosition::kNoSource, | 9206 TokenPosition::kNoSource, |
| 9211 saved_try_ctx, | 9207 saved_try_ctx, |
| 9212 new (Z) LoadLocalNode(TokenPosition::kNoSource, | 9208 new (Z) LoadLocalNode(TokenPosition::kNoSource, |
| 9213 async_saved_try_ctx))); | 9209 async_saved_try_ctx))); |
| 9214 } | 9210 } |
| 9215 } | 9211 } |
| 9216 // We need to save the exception variables as in catch clauses, whether | 9212 // We need to save the exception variables as in catch clauses, whether |
| 9217 // there is an outer try or not. Note that this is only necessary if the | 9213 // there is an outer try or not. Note that this is only necessary if the |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9468 // the catch clauses. | 9464 // the catch clauses. |
| 9469 if (is_async && (current != NULL)) { | 9465 if (is_async && (current != NULL)) { |
| 9470 ASSERT(try_stack_ != NULL); | 9466 ASSERT(try_stack_ != NULL); |
| 9471 SequenceNode* async_code = new(Z) SequenceNode(handler_pos, NULL); | 9467 SequenceNode* async_code = new(Z) SequenceNode(handler_pos, NULL); |
| 9472 const TryStack* try_block = try_stack_->outer_try(); | 9468 const TryStack* try_block = try_stack_->outer_try(); |
| 9473 if (try_block != NULL) { | 9469 if (try_block != NULL) { |
| 9474 LocalScope* scope = try_block->try_block()->scope; | 9470 LocalScope* scope = try_block->try_block()->scope; |
| 9475 if (scope->function_level() == current_block_->scope->function_level()) { | 9471 if (scope->function_level() == current_block_->scope->function_level()) { |
| 9476 LocalVariable* saved_try_ctx = | 9472 LocalVariable* saved_try_ctx = |
| 9477 LookupSavedTryContextVar(scope->parent()); | 9473 LookupSavedTryContextVar(scope->parent()); |
| 9478 LocalVariable* async_saved_try_ctx = | 9474 LocalVariable* async_saved_try_ctx = LookupAsyncSavedTryContextVar(T, |
| 9479 LookupAsyncSavedTryContextVar(async_temp_scope_, | 9475 async_temp_scope_, try_block->try_index()); |
| 9480 try_block->try_index()); | |
| 9481 async_code->Add( | 9476 async_code->Add( |
| 9482 new (Z) StoreLocalNode( | 9477 new (Z) StoreLocalNode( |
| 9483 TokenPosition::kNoSource, | 9478 TokenPosition::kNoSource, |
| 9484 saved_try_ctx, | 9479 saved_try_ctx, |
| 9485 new (Z) LoadLocalNode(TokenPosition::kNoSource, | 9480 new (Z) LoadLocalNode(TokenPosition::kNoSource, |
| 9486 async_saved_try_ctx))); | 9481 async_saved_try_ctx))); |
| 9487 } | 9482 } |
| 9488 } | 9483 } |
| 9489 SaveExceptionAndStacktrace(async_code, | 9484 SaveExceptionAndStacktrace(async_code, |
| 9490 exception_var, | 9485 exception_var, |
| 9491 stack_trace_var, | 9486 stack_trace_var, |
| 9492 rethrow_exception_var, | 9487 rethrow_exception_var, |
| 9493 rethrow_stack_trace_var); | 9488 rethrow_stack_trace_var); |
| 9494 // The async_code node sequence contains code to restore the context (if | 9489 // The async_code node sequence contains code to restore the context (if |
| 9495 // an outer try block is present) and code to save the exception and | 9490 // an outer try block is present) and code to save the exception and |
| 9496 // stack trace variables. | 9491 // stack trace variables. |
| 9497 // This async code is inserted before the current node sequence containing | 9492 // This async code is inserted before the current node sequence containing |
| 9498 // the chain of if/then/else handling all catch clauses. | 9493 // the chain of if/then/else handling all catch clauses. |
| 9499 async_code->Add(current); | 9494 async_code->Add(current); |
| 9500 current = async_code; | 9495 current = async_code; |
| 9501 } | 9496 } |
| 9502 return current; | 9497 return current; |
| 9503 } | 9498 } |
| 9504 | 9499 |
| 9505 | 9500 |
| 9506 void Parser::SetupSavedTryContext(LocalVariable* saved_try_context) { | 9501 void Parser::SetupSavedTryContext(LocalVariable* saved_try_context) { |
| 9507 const String& async_saved_try_ctx_name = String::ZoneHandle(Z, | 9502 const String& async_saved_try_ctx_name = String::ZoneHandle(Z, |
| 9508 Symbols::NewFormatted("%s%d", | 9503 Symbols::NewFormatted(T, |
| 9509 Symbols::AsyncSavedTryCtxVarPrefix().ToCString(), | 9504 "%s%d", |
| 9510 last_used_try_index_ - 1)); | 9505 Symbols::AsyncSavedTryCtxVarPrefix().ToCString(), |
| 9506 last_used_try_index_ - 1)); |
| 9511 LocalVariable* async_saved_try_ctx = new (Z) LocalVariable( | 9507 LocalVariable* async_saved_try_ctx = new (Z) LocalVariable( |
| 9512 TokenPosition::kNoSource, | 9508 TokenPosition::kNoSource, |
| 9513 async_saved_try_ctx_name, | 9509 async_saved_try_ctx_name, |
| 9514 Object::dynamic_type()); | 9510 Object::dynamic_type()); |
| 9515 ASSERT(async_temp_scope_ != NULL); | 9511 ASSERT(async_temp_scope_ != NULL); |
| 9516 async_temp_scope_->AddVariable(async_saved_try_ctx); | 9512 async_temp_scope_->AddVariable(async_saved_try_ctx); |
| 9517 ASSERT(saved_try_context != NULL); | 9513 ASSERT(saved_try_context != NULL); |
| 9518 current_block_->statements->Add(new(Z) StoreLocalNode( | 9514 current_block_->statements->Add(new(Z) StoreLocalNode( |
| 9519 TokenPosition::kNoSource, | 9515 TokenPosition::kNoSource, |
| 9520 async_saved_try_ctx, | 9516 async_saved_try_ctx, |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10338 arguments->Add(LoadReceiver(func->token_pos())); | 10334 arguments->Add(LoadReceiver(func->token_pos())); |
| 10339 } else { | 10335 } else { |
| 10340 AbstractType& type = AbstractType::ZoneHandle(Z); | 10336 AbstractType& type = AbstractType::ZoneHandle(Z); |
| 10341 type ^= Type::New(cls, TypeArguments::Handle(Z), call_pos, Heap::kOld); | 10337 type ^= Type::New(cls, TypeArguments::Handle(Z), call_pos, Heap::kOld); |
| 10342 type ^= ClassFinalizer::FinalizeType( | 10338 type ^= ClassFinalizer::FinalizeType( |
| 10343 current_class(), type, ClassFinalizer::kCanonicalize); | 10339 current_class(), type, ClassFinalizer::kCanonicalize); |
| 10344 arguments->Add(new(Z) LiteralNode(call_pos, type)); | 10340 arguments->Add(new(Z) LiteralNode(call_pos, type)); |
| 10345 } | 10341 } |
| 10346 // String memberName. | 10342 // String memberName. |
| 10347 arguments->Add(new(Z) LiteralNode( | 10343 arguments->Add(new(Z) LiteralNode( |
| 10348 call_pos, String::ZoneHandle(Z, Symbols::New(function_name)))); | 10344 call_pos, String::ZoneHandle(Z, Symbols::New(T, function_name)))); |
| 10349 // Smi invocation_type. | 10345 // Smi invocation_type. |
| 10350 if (cls.IsTopLevel()) { | 10346 if (cls.IsTopLevel()) { |
| 10351 ASSERT(im_call == InvocationMirror::kStatic || | 10347 ASSERT(im_call == InvocationMirror::kStatic || |
| 10352 im_call == InvocationMirror::kTopLevel); | 10348 im_call == InvocationMirror::kTopLevel); |
| 10353 im_call = InvocationMirror::kTopLevel; | 10349 im_call = InvocationMirror::kTopLevel; |
| 10354 } | 10350 } |
| 10355 arguments->Add(new(Z) LiteralNode(call_pos, Smi::ZoneHandle(Z, | 10351 arguments->Add(new(Z) LiteralNode(call_pos, Smi::ZoneHandle(Z, |
| 10356 Smi::New(InvocationMirror::EncodeType(im_call, im_type))))); | 10352 Smi::New(InvocationMirror::EncodeType(im_call, im_type))))); |
| 10357 // List arguments. | 10353 // List arguments. |
| 10358 if (function_arguments == NULL) { | 10354 if (function_arguments == NULL) { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10506 parsed_function()->EnsureExpressionTemp(); | 10502 parsed_function()->EnsureExpressionTemp(); |
| 10507 } | 10503 } |
| 10508 | 10504 |
| 10509 | 10505 |
| 10510 LocalVariable* Parser::CreateTempConstVariable(TokenPosition token_pos, | 10506 LocalVariable* Parser::CreateTempConstVariable(TokenPosition token_pos, |
| 10511 const char* s) { | 10507 const char* s) { |
| 10512 char name[64]; | 10508 char name[64]; |
| 10513 OS::SNPrint(name, 64, ":%s%" Pd "", s, token_pos.value()); | 10509 OS::SNPrint(name, 64, ":%s%" Pd "", s, token_pos.value()); |
| 10514 LocalVariable* temp = new(Z) LocalVariable( | 10510 LocalVariable* temp = new(Z) LocalVariable( |
| 10515 token_pos, | 10511 token_pos, |
| 10516 String::ZoneHandle(Z, Symbols::New(name)), | 10512 String::ZoneHandle(Z, Symbols::New(T, name)), |
| 10517 Object::dynamic_type()); | 10513 Object::dynamic_type()); |
| 10518 temp->set_is_final(); | 10514 temp->set_is_final(); |
| 10519 current_block_->scope->AddVariable(temp); | 10515 current_block_->scope->AddVariable(temp); |
| 10520 return temp; | 10516 return temp; |
| 10521 } | 10517 } |
| 10522 | 10518 |
| 10523 | 10519 |
| 10524 // TODO(srdjan): Implement other optimizations. | 10520 // TODO(srdjan): Implement other optimizations. |
| 10525 AstNode* Parser::OptimizeBinaryOpNode(TokenPosition op_pos, | 10521 AstNode* Parser::OptimizeBinaryOpNode(TokenPosition op_pos, |
| 10526 Token::Kind binary_op, | 10522 Token::Kind binary_op, |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10718 AstNode* Parser::CreateAssignmentNode(AstNode* original, | 10714 AstNode* Parser::CreateAssignmentNode(AstNode* original, |
| 10719 AstNode* rhs, | 10715 AstNode* rhs, |
| 10720 const String* left_ident, | 10716 const String* left_ident, |
| 10721 TokenPosition left_pos, | 10717 TokenPosition left_pos, |
| 10722 bool is_compound /* = false */) { | 10718 bool is_compound /* = false */) { |
| 10723 AstNode* result = original->MakeAssignmentNode(rhs); | 10719 AstNode* result = original->MakeAssignmentNode(rhs); |
| 10724 if (result == NULL) { | 10720 if (result == NULL) { |
| 10725 String& name = String::ZoneHandle(Z); | 10721 String& name = String::ZoneHandle(Z); |
| 10726 const Class* target_cls = ¤t_class(); | 10722 const Class* target_cls = ¤t_class(); |
| 10727 if (original->IsTypeNode()) { | 10723 if (original->IsTypeNode()) { |
| 10728 name = Symbols::New(original->AsTypeNode()->TypeName()); | 10724 name = Symbols::New(T, original->AsTypeNode()->TypeName()); |
| 10729 } else if (original->IsLoadStaticFieldNode()) { | 10725 } else if (original->IsLoadStaticFieldNode()) { |
| 10730 name = original->AsLoadStaticFieldNode()->field().name(); | 10726 name = original->AsLoadStaticFieldNode()->field().name(); |
| 10731 target_cls = &Class::Handle(Z, | 10727 target_cls = &Class::Handle(Z, |
| 10732 original->AsLoadStaticFieldNode()->field().Owner()); | 10728 original->AsLoadStaticFieldNode()->field().Owner()); |
| 10733 } else if ((left_ident != NULL) && | 10729 } else if ((left_ident != NULL) && |
| 10734 (original->IsLiteralNode() || | 10730 (original->IsLiteralNode() || |
| 10735 original->IsLoadLocalNode())) { | 10731 original->IsLoadLocalNode())) { |
| 10736 name = left_ident->raw(); | 10732 name = left_ident->raw(); |
| 10737 } | 10733 } |
| 10738 if (name.IsNull()) { | 10734 if (name.IsNull()) { |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11619 | 11615 |
| 11620 String& extractor_name = String::ZoneHandle(Z); | 11616 String& extractor_name = String::ZoneHandle(Z); |
| 11621 if (IsIdentifier()) { | 11617 if (IsIdentifier()) { |
| 11622 extractor_name = CurrentLiteral()->raw(); | 11618 extractor_name = CurrentLiteral()->raw(); |
| 11623 ConsumeToken(); | 11619 ConsumeToken(); |
| 11624 if (CurrentToken() == Token::kASSIGN) { | 11620 if (CurrentToken() == Token::kASSIGN) { |
| 11625 ConsumeToken(); | 11621 ConsumeToken(); |
| 11626 is_setter_name = true; | 11622 is_setter_name = true; |
| 11627 } | 11623 } |
| 11628 } else if (Token::CanBeOverloaded(CurrentToken())) { | 11624 } else if (Token::CanBeOverloaded(CurrentToken())) { |
| 11629 extractor_name = Symbols::New(Token::Str(CurrentToken())); | 11625 extractor_name = Symbols::Token(CurrentToken()).raw(); |
| 11630 ConsumeToken(); | 11626 ConsumeToken(); |
| 11631 } else { | 11627 } else { |
| 11632 ReportError("identifier or operator expected"); | 11628 ReportError("identifier or operator expected"); |
| 11633 } | 11629 } |
| 11634 | 11630 |
| 11635 if (primary->IsPrimaryNode() && primary->AsPrimaryNode()->IsSuper()) { | 11631 if (primary->IsPrimaryNode() && primary->AsPrimaryNode()->IsSuper()) { |
| 11636 // TODO(hausner): implement super#m | 11632 // TODO(hausner): implement super#m |
| 11637 ReportError("closurization of super method not yet supported"); | 11633 ReportError("closurization of super method not yet supported"); |
| 11638 } | 11634 } |
| 11639 | 11635 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11746 NULL); // No existing function. | 11742 NULL); // No existing function. |
| 11747 } | 11743 } |
| 11748 | 11744 |
| 11749 // Closurization of instance getter, setter, method or operator. | 11745 // Closurization of instance getter, setter, method or operator. |
| 11750 GrowableHandlePtrArray<const String> pieces(Z, 3); | 11746 GrowableHandlePtrArray<const String> pieces(Z, 3); |
| 11751 pieces.Add(Symbols::HashMark()); | 11747 pieces.Add(Symbols::HashMark()); |
| 11752 if (is_setter_name) { | 11748 if (is_setter_name) { |
| 11753 pieces.Add(Symbols::SetterPrefix()); | 11749 pieces.Add(Symbols::SetterPrefix()); |
| 11754 } | 11750 } |
| 11755 pieces.Add(extractor_name); | 11751 pieces.Add(extractor_name); |
| 11756 extractor_name = Symbols::FromConcatAll(pieces); | 11752 extractor_name = Symbols::FromConcatAll(T, pieces); |
| 11757 return new(Z) InstanceGetterNode(property_pos, primary, extractor_name); | 11753 return new(Z) InstanceGetterNode(property_pos, primary, extractor_name); |
| 11758 } | 11754 } |
| 11759 | 11755 |
| 11760 | 11756 |
| 11761 AstNode* Parser::ParsePostfixExpr() { | 11757 AstNode* Parser::ParsePostfixExpr() { |
| 11762 TRACE_PARSER("ParsePostfixExpr"); | 11758 TRACE_PARSER("ParsePostfixExpr"); |
| 11763 String* expr_ident = | 11759 String* expr_ident = |
| 11764 Token::IsIdentifier(CurrentToken()) ? CurrentLiteral() : NULL; | 11760 Token::IsIdentifier(CurrentToken()) ? CurrentLiteral() : NULL; |
| 11765 const TokenPosition expr_pos = TokenPos(); | 11761 const TokenPosition expr_pos = TokenPos(); |
| 11766 AstNode* expr = ParsePrimary(); | 11762 AstNode* expr = ParsePrimary(); |
| (...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12936 } | 12932 } |
| 12937 if (is_const) { | 12933 if (is_const) { |
| 12938 ASSERT(key->IsLiteralNode()); | 12934 ASSERT(key->IsLiteralNode()); |
| 12939 const Instance& key_value = key->AsLiteralNode()->literal(); | 12935 const Instance& key_value = key->AsLiteralNode()->literal(); |
| 12940 if (key_value.IsDouble()) { | 12936 if (key_value.IsDouble()) { |
| 12941 ReportError(key_pos, "key value must not be of type double"); | 12937 ReportError(key_pos, "key value must not be of type double"); |
| 12942 } | 12938 } |
| 12943 if (!key_value.IsInteger() && | 12939 if (!key_value.IsInteger() && |
| 12944 !key_value.IsString() && | 12940 !key_value.IsString() && |
| 12945 (key_value.clazz() != I->object_store()->symbol_class()) && | 12941 (key_value.clazz() != I->object_store()->symbol_class()) && |
| 12946 ImplementsEqualOperator(key_value)) { | 12942 ImplementsEqualOperator(Z, key_value)) { |
| 12947 ReportError(key_pos, "key value must not implement operator =="); | 12943 ReportError(key_pos, "key value must not implement operator =="); |
| 12948 } | 12944 } |
| 12949 } | 12945 } |
| 12950 ExpectToken(Token::kCOLON); | 12946 ExpectToken(Token::kCOLON); |
| 12951 const TokenPosition value_pos = TokenPos(); | 12947 const TokenPosition value_pos = TokenPos(); |
| 12952 AstNode* value = ParseExpr(is_const, kConsumeCascades); | 12948 AstNode* value = ParseExpr(is_const, kConsumeCascades); |
| 12953 SetAllowFunctionLiterals(saved_mode); | 12949 SetAllowFunctionLiterals(saved_mode); |
| 12954 if (I->type_checks() && | 12950 if (I->type_checks() && |
| 12955 !is_const && | 12951 !is_const && |
| 12956 !value_type.IsDynamicType()) { | 12952 !value_type.IsDynamicType()) { |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13134 if (IsIdentifier()) { | 13130 if (IsIdentifier()) { |
| 13135 symbol = CurrentLiteral()->raw(); | 13131 symbol = CurrentLiteral()->raw(); |
| 13136 ConsumeToken(); | 13132 ConsumeToken(); |
| 13137 GrowableHandlePtrArray<const String> pieces(Z, 3); | 13133 GrowableHandlePtrArray<const String> pieces(Z, 3); |
| 13138 pieces.Add(symbol); | 13134 pieces.Add(symbol); |
| 13139 while (CurrentToken() == Token::kPERIOD) { | 13135 while (CurrentToken() == Token::kPERIOD) { |
| 13140 pieces.Add(Symbols::Dot()); | 13136 pieces.Add(Symbols::Dot()); |
| 13141 ConsumeToken(); | 13137 ConsumeToken(); |
| 13142 pieces.Add(*ExpectIdentifier("identifier expected")); | 13138 pieces.Add(*ExpectIdentifier("identifier expected")); |
| 13143 } | 13139 } |
| 13144 symbol = Symbols::FromConcatAll(pieces); | 13140 symbol = Symbols::FromConcatAll(T, pieces); |
| 13145 } else if (Token::CanBeOverloaded(CurrentToken())) { | 13141 } else if (Token::CanBeOverloaded(CurrentToken())) { |
| 13146 symbol = Symbols::New(Token::Str(CurrentToken())); | 13142 symbol = Symbols::Token(CurrentToken()).raw(); |
| 13147 ConsumeToken(); | 13143 ConsumeToken(); |
| 13148 } else { | 13144 } else { |
| 13149 ReportError("illegal symbol literal"); | 13145 ReportError("illegal symbol literal"); |
| 13150 } | 13146 } |
| 13151 ASSERT(symbol.IsSymbol()); | 13147 ASSERT(symbol.IsSymbol()); |
| 13152 | 13148 |
| 13153 Instance& symbol_instance = Instance::ZoneHandle(Z); | 13149 Instance& symbol_instance = Instance::ZoneHandle(Z); |
| 13154 if (GetCachedConstant(symbol_pos, &symbol_instance)) { | 13150 if (GetCachedConstant(symbol_pos, &symbol_instance)) { |
| 13155 return new(Z) LiteralNode(symbol_pos, symbol_instance); | 13151 return new(Z) LiteralNode(symbol_pos, symbol_instance); |
| 13156 } | 13152 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 13183 const Function& ctr, TokenPosition token_pos) { | 13179 const Function& ctr, TokenPosition token_pos) { |
| 13184 ASSERT(ctr.kind() == RawFunction::kConstructor); | 13180 ASSERT(ctr.kind() == RawFunction::kConstructor); |
| 13185 Function& closure = Function::Handle(Z); | 13181 Function& closure = Function::Handle(Z); |
| 13186 closure = I->LookupClosureFunction(innermost_function(), token_pos); | 13182 closure = I->LookupClosureFunction(innermost_function(), token_pos); |
| 13187 if (!closure.IsNull()) { | 13183 if (!closure.IsNull()) { |
| 13188 ASSERT(closure.IsConstructorClosureFunction()); | 13184 ASSERT(closure.IsConstructorClosureFunction()); |
| 13189 return closure.raw(); | 13185 return closure.raw(); |
| 13190 } | 13186 } |
| 13191 | 13187 |
| 13192 String& closure_name = String::Handle(Z, ctr.name()); | 13188 String& closure_name = String::Handle(Z, ctr.name()); |
| 13193 closure_name = Symbols::FromConcat(Symbols::ConstructorClosurePrefix(), | 13189 closure_name = Symbols::FromConcat(T, |
| 13194 closure_name); | 13190 Symbols::ConstructorClosurePrefix(), closure_name); |
| 13195 | 13191 |
| 13196 ParamList params; | 13192 ParamList params; |
| 13197 params.AddFinalParameter(token_pos, | 13193 params.AddFinalParameter(token_pos, |
| 13198 &Symbols::ClosureParameter(), | 13194 &Symbols::ClosureParameter(), |
| 13199 &Object::dynamic_type()); | 13195 &Object::dynamic_type()); |
| 13200 | 13196 |
| 13201 ParseFormalParameters(ctr, ¶ms); | 13197 ParseFormalParameters(ctr, ¶ms); |
| 13202 // Per language spec, the type of the closure parameters is dynamic. | 13198 // Per language spec, the type of the closure parameters is dynamic. |
| 13203 // Replace the types parsed from the constructor. | 13199 // Replace the types parsed from the constructor. |
| 13204 params.EraseParameterTypes(); | 13200 params.EraseParameterTypes(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 13216 Type& signature_type = Type::Handle(Z, closure.SignatureType()); | 13212 Type& signature_type = Type::Handle(Z, closure.SignatureType()); |
| 13217 signature_type ^= ClassFinalizer::FinalizeType( | 13213 signature_type ^= ClassFinalizer::FinalizeType( |
| 13218 current_class(), signature_type, ClassFinalizer::kCanonicalize); | 13214 current_class(), signature_type, ClassFinalizer::kCanonicalize); |
| 13219 closure.SetSignatureType(signature_type); | 13215 closure.SetSignatureType(signature_type); |
| 13220 // Finalization would be premature when top-level parsing. | 13216 // Finalization would be premature when top-level parsing. |
| 13221 ASSERT(!is_top_level_); | 13217 ASSERT(!is_top_level_); |
| 13222 return closure.raw(); | 13218 return closure.raw(); |
| 13223 } | 13219 } |
| 13224 | 13220 |
| 13225 | 13221 |
| 13226 static String& BuildConstructorName(const String& type_class_name, | 13222 static String& BuildConstructorName(Thread* thread, |
| 13223 const String& type_class_name, |
| 13227 const String* named_constructor) { | 13224 const String* named_constructor) { |
| 13228 // By convention, the static function implementing a named constructor 'C' | 13225 // By convention, the static function implementing a named constructor 'C' |
| 13229 // for class 'A' is labeled 'A.C', and the static function implementing the | 13226 // for class 'A' is labeled 'A.C', and the static function implementing the |
| 13230 // unnamed constructor for class 'A' is labeled 'A.'. | 13227 // unnamed constructor for class 'A' is labeled 'A.'. |
| 13231 // This convention prevents users from explicitly calling constructors. | 13228 // This convention prevents users from explicitly calling constructors. |
| 13232 String& constructor_name = | 13229 Zone* zone = thread->zone(); |
| 13233 String::Handle(Symbols::FromConcat(type_class_name, Symbols::Dot())); | 13230 String& constructor_name = String::Handle(zone, |
| 13231 Symbols::FromDot(thread, type_class_name)); |
| 13234 if (named_constructor != NULL) { | 13232 if (named_constructor != NULL) { |
| 13235 constructor_name = | 13233 constructor_name = |
| 13236 Symbols::FromConcat(constructor_name, *named_constructor); | 13234 Symbols::FromConcat(thread, constructor_name, *named_constructor); |
| 13237 } | 13235 } |
| 13238 return constructor_name; | 13236 return constructor_name; |
| 13239 } | 13237 } |
| 13240 | 13238 |
| 13241 | 13239 |
| 13242 // Parse a primary expression of the form new T# or new T#m. | 13240 // Parse a primary expression of the form new T# or new T#m. |
| 13243 // Current token position is after the keyword new. Extracts the | 13241 // Current token position is after the keyword new. Extracts the |
| 13244 // anonymous or named constructor and type arguments. | 13242 // anonymous or named constructor and type arguments. |
| 13245 // Note that type type T has already been parsed before | 13243 // Note that type type T has already been parsed before |
| 13246 // (by ParseNewOperator()) and is guaranteed to be well-formed, | 13244 // (by ParseNewOperator()) and is guaranteed to be well-formed, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 13265 ExpectToken(Token::kHASH); | 13263 ExpectToken(Token::kHASH); |
| 13266 String* named_constructor = NULL; | 13264 String* named_constructor = NULL; |
| 13267 if (IsIdentifier()) { | 13265 if (IsIdentifier()) { |
| 13268 named_constructor = CurrentLiteral(); | 13266 named_constructor = CurrentLiteral(); |
| 13269 ConsumeToken(); | 13267 ConsumeToken(); |
| 13270 } | 13268 } |
| 13271 // Resolve the type and optional identifier to a constructor or factory. | 13269 // Resolve the type and optional identifier to a constructor or factory. |
| 13272 Class& type_class = Class::Handle(Z, type.type_class()); | 13270 Class& type_class = Class::Handle(Z, type.type_class()); |
| 13273 String& type_class_name = String::Handle(Z, type_class.Name()); | 13271 String& type_class_name = String::Handle(Z, type_class.Name()); |
| 13274 *type_arguments = type.arguments(); | 13272 *type_arguments = type.arguments(); |
| 13275 String& constructor_name = | 13273 String& constructor_name = BuildConstructorName(T, |
| 13276 BuildConstructorName(type_class_name, named_constructor); | 13274 type_class_name, named_constructor); |
| 13277 *constructor = type_class.LookupConstructor(constructor_name); | 13275 *constructor = type_class.LookupConstructor(constructor_name); |
| 13278 if (constructor->IsNull()) { | 13276 if (constructor->IsNull()) { |
| 13279 *constructor = type_class.LookupFactory(constructor_name); | 13277 *constructor = type_class.LookupFactory(constructor_name); |
| 13280 ASSERT(!constructor->IsNull()); | 13278 ASSERT(!constructor->IsNull()); |
| 13281 if (constructor->IsRedirectingFactory()) { | 13279 if (constructor->IsRedirectingFactory()) { |
| 13282 ClassFinalizer::ResolveRedirectingFactory(type_class, *constructor); | 13280 ClassFinalizer::ResolveRedirectingFactory(type_class, *constructor); |
| 13283 type = constructor->RedirectionType(); | 13281 type = constructor->RedirectionType(); |
| 13284 ASSERT(!type.IsMalformedOrMalbounded()); | 13282 ASSERT(!type.IsMalformedOrMalbounded()); |
| 13285 if (!type.IsInstantiated()) { | 13283 if (!type.IsInstantiated()) { |
| 13286 Error& error = Error::Handle(Z); | 13284 Error& error = Error::Handle(Z); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13406 | 13404 |
| 13407 // A constructor has an implicit 'this' parameter (instance to construct) | 13405 // A constructor has an implicit 'this' parameter (instance to construct) |
| 13408 // and a factory has an implicit 'this' parameter (type_arguments). | 13406 // and a factory has an implicit 'this' parameter (type_arguments). |
| 13409 intptr_t arguments_length = arguments->length() + 1; | 13407 intptr_t arguments_length = arguments->length() + 1; |
| 13410 | 13408 |
| 13411 // An additional type check of the result of a redirecting factory may be | 13409 // An additional type check of the result of a redirecting factory may be |
| 13412 // required. | 13410 // required. |
| 13413 AbstractType& type_bound = AbstractType::ZoneHandle(Z); | 13411 AbstractType& type_bound = AbstractType::ZoneHandle(Z); |
| 13414 | 13412 |
| 13415 // Make sure that an appropriate constructor exists. | 13413 // Make sure that an appropriate constructor exists. |
| 13416 String& constructor_name = | 13414 String& constructor_name = BuildConstructorName(T, |
| 13417 BuildConstructorName(type_class_name, named_constructor); | 13415 type_class_name, named_constructor); |
| 13418 Function& constructor = Function::ZoneHandle(Z, | 13416 Function& constructor = Function::ZoneHandle(Z, |
| 13419 type_class.LookupConstructor(constructor_name)); | 13417 type_class.LookupConstructor(constructor_name)); |
| 13420 if (constructor.IsNull()) { | 13418 if (constructor.IsNull()) { |
| 13421 constructor = type_class.LookupFactory(constructor_name); | 13419 constructor = type_class.LookupFactory(constructor_name); |
| 13422 if (constructor.IsNull()) { | 13420 if (constructor.IsNull()) { |
| 13423 const String& external_constructor_name = | 13421 const String& external_constructor_name = |
| 13424 (named_constructor ? constructor_name : type_class_name); | 13422 (named_constructor ? constructor_name : type_class_name); |
| 13425 // Replace the type with a malformed type and compile a throw or report a | 13423 // Replace the type with a malformed type and compile a throw or report a |
| 13426 // compile-time error if the constructor is const. | 13424 // compile-time error if the constructor is const. |
| 13427 if (is_const) { | 13425 if (is_const) { |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13675 interpolate_arg.SetAt(0, value_arr); | 13673 interpolate_arg.SetAt(0, value_arr); |
| 13676 | 13674 |
| 13677 // Call interpolation function. | 13675 // Call interpolation function. |
| 13678 Object& result = Object::Handle(Z); | 13676 Object& result = Object::Handle(Z); |
| 13679 result = DartEntry::InvokeFunction(func, interpolate_arg); | 13677 result = DartEntry::InvokeFunction(func, interpolate_arg); |
| 13680 if (result.IsUnhandledException()) { | 13678 if (result.IsUnhandledException()) { |
| 13681 ReportError("%s", Error::Cast(result).ToErrorCString()); | 13679 ReportError("%s", Error::Cast(result).ToErrorCString()); |
| 13682 } | 13680 } |
| 13683 String& concatenated = String::ZoneHandle(Z); | 13681 String& concatenated = String::ZoneHandle(Z); |
| 13684 concatenated ^= result.raw(); | 13682 concatenated ^= result.raw(); |
| 13685 concatenated = Symbols::New(concatenated); | 13683 concatenated = Symbols::New(T, concatenated); |
| 13686 return concatenated; | 13684 return concatenated; |
| 13687 } | 13685 } |
| 13688 | 13686 |
| 13689 | 13687 |
| 13690 // A string literal consists of the concatenation of the next n tokens | 13688 // A string literal consists of the concatenation of the next n tokens |
| 13691 // that satisfy the EBNF grammar: | 13689 // that satisfy the EBNF grammar: |
| 13692 // literal = kSTRING {{ interpol } kSTRING } | 13690 // literal = kSTRING {{ interpol } kSTRING } |
| 13693 // interpol = kINTERPOL_VAR | (kINTERPOL_START expression kINTERPOL_END) | 13691 // interpol = kINTERPOL_VAR | (kINTERPOL_START expression kINTERPOL_END) |
| 13694 // In other words, the scanner breaks down interpolated strings so that | 13692 // In other words, the scanner breaks down interpolated strings so that |
| 13695 // a string literal always begins and ends with a kSTRING token. | 13693 // a string literal always begins and ends with a kSTRING token. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13773 const String& interpolated_string = Interpolate(values_list); | 13771 const String& interpolated_string = Interpolate(values_list); |
| 13774 primary = new(Z) LiteralNode(literal_start, interpolated_string); | 13772 primary = new(Z) LiteralNode(literal_start, interpolated_string); |
| 13775 CacheConstantValue(literal_start, interpolated_string); | 13773 CacheConstantValue(literal_start, interpolated_string); |
| 13776 } else { | 13774 } else { |
| 13777 GrowableHandlePtrArray<const String> pieces(Z, values_list.length()); | 13775 GrowableHandlePtrArray<const String> pieces(Z, values_list.length()); |
| 13778 for (int i = 0; i < values_list.length(); i++) { | 13776 for (int i = 0; i < values_list.length(); i++) { |
| 13779 const Instance& part = values_list[i]->AsLiteralNode()->literal(); | 13777 const Instance& part = values_list[i]->AsLiteralNode()->literal(); |
| 13780 ASSERT(part.IsString()); | 13778 ASSERT(part.IsString()); |
| 13781 pieces.Add(String::Cast(part)); | 13779 pieces.Add(String::Cast(part)); |
| 13782 } | 13780 } |
| 13783 const String& lit = String::ZoneHandle(Z, Symbols::FromConcatAll(pieces)); | 13781 const String& lit = String::ZoneHandle(Z, |
| 13782 Symbols::FromConcatAll(T, pieces)); |
| 13784 primary = new(Z) LiteralNode(literal_start, lit); | 13783 primary = new(Z) LiteralNode(literal_start, lit); |
| 13785 // Caching of constant not necessary because the symbol lookup will | 13784 // Caching of constant not necessary because the symbol lookup will |
| 13786 // find the value next time. | 13785 // find the value next time. |
| 13787 } | 13786 } |
| 13788 } else { | 13787 } else { |
| 13789 ArrayNode* values = new(Z) ArrayNode( | 13788 ArrayNode* values = new(Z) ArrayNode( |
| 13790 TokenPos(), | 13789 TokenPos(), |
| 13791 Type::ZoneHandle(Z, Type::ArrayType()), | 13790 Type::ZoneHandle(Z, Type::ArrayType()), |
| 13792 values_list); | 13791 values_list); |
| 13793 primary = new(Z) StringInterpolateNode(TokenPos(), values); | 13792 primary = new(Z) StringInterpolateNode(TokenPos(), values); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13863 // in the parser. The four cases are: prefixed vs non-prefixed | 13862 // in the parser. The four cases are: prefixed vs non-prefixed |
| 13864 // name, static vs dynamic context in which the unresolved name | 13863 // name, static vs dynamic context in which the unresolved name |
| 13865 // is used. We cheat a little here by looking at the next token | 13864 // is used. We cheat a little here by looking at the next token |
| 13866 // to determine whether we have an unresolved method call or | 13865 // to determine whether we have an unresolved method call or |
| 13867 // field access. | 13866 // field access. |
| 13868 GrowableHandlePtrArray<const String> pieces(Z, 3); | 13867 GrowableHandlePtrArray<const String> pieces(Z, 3); |
| 13869 pieces.Add(String::Handle(Z, prefix.name())); | 13868 pieces.Add(String::Handle(Z, prefix.name())); |
| 13870 pieces.Add(Symbols::Dot()); | 13869 pieces.Add(Symbols::Dot()); |
| 13871 pieces.Add(ident); | 13870 pieces.Add(ident); |
| 13872 const String& qualified_name = String::ZoneHandle(Z, | 13871 const String& qualified_name = String::ZoneHandle(Z, |
| 13873 Symbols::FromConcatAll(pieces)); | 13872 Symbols::FromConcatAll(T, pieces)); |
| 13874 InvocationMirror::Type call_type = | 13873 InvocationMirror::Type call_type = |
| 13875 CurrentToken() == Token::kLPAREN ? | 13874 CurrentToken() == Token::kLPAREN ? |
| 13876 InvocationMirror::kMethod : InvocationMirror::kGetter; | 13875 InvocationMirror::kMethod : InvocationMirror::kGetter; |
| 13877 primary = ThrowNoSuchMethodError(qual_ident_pos, | 13876 primary = ThrowNoSuchMethodError(qual_ident_pos, |
| 13878 current_class(), | 13877 current_class(), |
| 13879 qualified_name, | 13878 qualified_name, |
| 13880 NULL, // No arguments. | 13879 NULL, // No arguments. |
| 13881 InvocationMirror::kTopLevel, | 13880 InvocationMirror::kTopLevel, |
| 13882 call_type, | 13881 call_type, |
| 13883 NULL); // No existing function. | 13882 NULL); // No existing function. |
| 13884 } | 13883 } |
| 13885 } else if (FLAG_load_deferred_eagerly && prefix.is_deferred_load()) { | 13884 } else if (FLAG_load_deferred_eagerly && prefix.is_deferred_load()) { |
| 13886 // primary != NULL. | 13885 // primary != NULL. |
| 13887 String& qualified_name = String::ZoneHandle(Z, prefix.name()); | 13886 GrowableHandlePtrArray<const String> pieces(Z, 3); |
| 13888 qualified_name = String::Concat(qualified_name, Symbols::Dot()); | 13887 pieces.Add(String::Handle(Z, prefix.name())); |
| 13889 qualified_name = Symbols::FromConcat(qualified_name, ident); | 13888 pieces.Add(Symbols::Dot()); |
| 13889 pieces.Add(ident); |
| 13890 const String& qualified_name = String::ZoneHandle(Z, |
| 13891 Symbols::FromConcatAll(T, pieces)); |
| 13890 InvocationMirror::Type call_type = | 13892 InvocationMirror::Type call_type = |
| 13891 CurrentToken() == Token::kLPAREN ? | 13893 CurrentToken() == Token::kLPAREN ? |
| 13892 InvocationMirror::kMethod : InvocationMirror::kGetter; | 13894 InvocationMirror::kMethod : InvocationMirror::kGetter; |
| 13893 // Note: Adding a statement to current block is a hack, parsing an | 13895 // Note: Adding a statement to current block is a hack, parsing an |
| 13894 // espression should have no side-effect. | 13896 // espression should have no side-effect. |
| 13895 current_block_->statements->Add(ThrowNoSuchMethodError( | 13897 current_block_->statements->Add(ThrowNoSuchMethodError( |
| 13896 qual_ident_pos, | 13898 qual_ident_pos, |
| 13897 current_class(), | 13899 current_class(), |
| 13898 qualified_name, | 13900 qualified_name, |
| 13899 NULL, // No arguments. | 13901 NULL, // No arguments. |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14473 const ArgumentListNode& function_args, | 14475 const ArgumentListNode& function_args, |
| 14474 const LocalVariable* temp_for_last_arg, | 14476 const LocalVariable* temp_for_last_arg, |
| 14475 bool is_super_invocation) { | 14477 bool is_super_invocation) { |
| 14476 UNREACHABLE(); | 14478 UNREACHABLE(); |
| 14477 return NULL; | 14479 return NULL; |
| 14478 } | 14480 } |
| 14479 | 14481 |
| 14480 } // namespace dart | 14482 } // namespace dart |
| 14481 | 14483 |
| 14482 #endif // DART_PRECOMPILED_RUNTIME | 14484 #endif // DART_PRECOMPILED_RUNTIME |
| OLD | NEW |