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 12212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12223 } else { | 12223 } else { |
12224 // The implicit static getter will throw the exception if necessary. | 12224 // The implicit static getter will throw the exception if necessary. |
12225 return new(Z) StaticGetterNode( | 12225 return new(Z) StaticGetterNode( |
12226 field_ref_pos, NULL, field_owner, field_name); | 12226 field_ref_pos, NULL, field_owner, field_name); |
12227 } | 12227 } |
12228 } else if (value.raw() == Object::sentinel().raw()) { | 12228 } else if (value.raw() == Object::sentinel().raw()) { |
12229 // This field has not been referenced yet and thus the value has | 12229 // This field has not been referenced yet and thus the value has |
12230 // not been evaluated. If the field is const, call the static getter method | 12230 // not been evaluated. If the field is const, call the static getter method |
12231 // to evaluate the expression and canonicalize the value. | 12231 // to evaluate the expression and canonicalize the value. |
12232 if (field.is_const()) { | 12232 if (field.is_const()) { |
| 12233 NoReloadScope no_reload_scope(isolate(), thread()); |
12233 field.SetStaticValue(Object::transition_sentinel()); | 12234 field.SetStaticValue(Object::transition_sentinel()); |
12234 const int kNumArguments = 0; // no arguments. | 12235 const int kNumArguments = 0; // no arguments. |
12235 const Function& func = Function::Handle(Z, | 12236 const Function& func = Function::Handle(Z, |
12236 Resolver::ResolveStatic(field_owner, | 12237 Resolver::ResolveStatic(field_owner, |
12237 getter_name, | 12238 getter_name, |
12238 kNumArguments, | 12239 kNumArguments, |
12239 Object::empty_array())); | 12240 Object::empty_array())); |
12240 ASSERT(!func.IsNull()); | 12241 ASSERT(!func.IsNull()); |
12241 ASSERT(func.kind() == RawFunction::kImplicitStaticFinalGetter); | 12242 ASSERT(func.kind() == RawFunction::kImplicitStaticFinalGetter); |
12242 Object& const_value = Object::Handle(Z); | 12243 Object& const_value = Object::Handle(Z); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12280 return new(Z) StaticGetterNode( | 12281 return new(Z) StaticGetterNode( |
12281 field_ref_pos, NULL, field_owner, field_name); | 12282 field_ref_pos, NULL, field_owner, field_name); |
12282 } | 12283 } |
12283 | 12284 |
12284 | 12285 |
12285 RawObject* Parser::EvaluateConstConstructorCall( | 12286 RawObject* Parser::EvaluateConstConstructorCall( |
12286 const Class& type_class, | 12287 const Class& type_class, |
12287 const TypeArguments& type_arguments, | 12288 const TypeArguments& type_arguments, |
12288 const Function& constructor, | 12289 const Function& constructor, |
12289 ArgumentListNode* arguments) { | 12290 ArgumentListNode* arguments) { |
| 12291 NoReloadScope no_reload_scope(isolate(), thread()); |
12290 // Factories have one extra argument: the type arguments. | 12292 // Factories have one extra argument: the type arguments. |
12291 // Constructors have 1 extra arguments: receiver. | 12293 // Constructors have 1 extra arguments: receiver. |
12292 const int kNumExtraArgs = 1; | 12294 const int kNumExtraArgs = 1; |
12293 const int num_arguments = arguments->length() + kNumExtraArgs; | 12295 const int num_arguments = arguments->length() + kNumExtraArgs; |
12294 const Array& arg_values = | 12296 const Array& arg_values = |
12295 Array::Handle(Z, Array::New(num_arguments, Heap::kOld)); | 12297 Array::Handle(Z, Array::New(num_arguments, Heap::kOld)); |
12296 Instance& instance = Instance::Handle(Z); | 12298 Instance& instance = Instance::Handle(Z); |
12297 if (!constructor.IsFactory()) { | 12299 if (!constructor.IsFactory()) { |
12298 instance = Instance::New(type_class, Heap::kOld); | 12300 instance = Instance::New(type_class, Heap::kOld); |
12299 if (!type_arguments.IsNull()) { | 12301 if (!type_arguments.IsNull()) { |
(...skipping 1494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13794 } | 13796 } |
13795 if (!type_bound.IsNull()) { | 13797 if (!type_bound.IsNull()) { |
13796 new_object = new(Z) AssignableNode( | 13798 new_object = new(Z) AssignableNode( |
13797 new_pos, new_object, type_bound, Symbols::FactoryResult()); | 13799 new_pos, new_object, type_bound, Symbols::FactoryResult()); |
13798 } | 13800 } |
13799 return new_object; | 13801 return new_object; |
13800 } | 13802 } |
13801 | 13803 |
13802 | 13804 |
13803 String& Parser::Interpolate(const GrowableArray<AstNode*>& values) { | 13805 String& Parser::Interpolate(const GrowableArray<AstNode*>& values) { |
| 13806 NoReloadScope no_reload_scope(isolate(), thread()); |
13804 const Class& cls = Class::Handle( | 13807 const Class& cls = Class::Handle( |
13805 Z, Library::LookupCoreClass(Symbols::StringBase())); | 13808 Z, Library::LookupCoreClass(Symbols::StringBase())); |
13806 ASSERT(!cls.IsNull()); | 13809 ASSERT(!cls.IsNull()); |
13807 const Function& func = Function::Handle(Z, cls.LookupStaticFunction( | 13810 const Function& func = Function::Handle(Z, cls.LookupStaticFunction( |
13808 Library::PrivateCoreLibName(Symbols::Interpolate()))); | 13811 Library::PrivateCoreLibName(Symbols::Interpolate()))); |
13809 ASSERT(!func.IsNull()); | 13812 ASSERT(!func.IsNull()); |
13810 | 13813 |
13811 // Build the array of literal values to interpolate. | 13814 // Build the array of literal values to interpolate. |
13812 const Array& value_arr = Array::Handle(Z, | 13815 const Array& value_arr = Array::Handle(Z, |
13813 Array::New(values.length(), Heap::kOld)); | 13816 Array::New(values.length(), Heap::kOld)); |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14141 UnexpectedToken(); | 14144 UnexpectedToken(); |
14142 } | 14145 } |
14143 return primary; | 14146 return primary; |
14144 } | 14147 } |
14145 | 14148 |
14146 | 14149 |
14147 // Evaluate expression in expr and return the value. The expression must | 14150 // Evaluate expression in expr and return the value. The expression must |
14148 // be a compile time constant. | 14151 // be a compile time constant. |
14149 const Instance& Parser::EvaluateConstExpr(TokenPosition expr_pos, | 14152 const Instance& Parser::EvaluateConstExpr(TokenPosition expr_pos, |
14150 AstNode* expr) { | 14153 AstNode* expr) { |
| 14154 NoReloadScope no_reload_scope(isolate(), thread()); |
14151 if (expr->IsLiteralNode()) { | 14155 if (expr->IsLiteralNode()) { |
14152 return expr->AsLiteralNode()->literal(); | 14156 return expr->AsLiteralNode()->literal(); |
14153 } else if (expr->IsLoadLocalNode() && | 14157 } else if (expr->IsLoadLocalNode() && |
14154 expr->AsLoadLocalNode()->local().IsConst()) { | 14158 expr->AsLoadLocalNode()->local().IsConst()) { |
14155 return *expr->AsLoadLocalNode()->local().ConstValue(); | 14159 return *expr->AsLoadLocalNode()->local().ConstValue(); |
14156 } else if (expr->IsLoadStaticFieldNode()) { | 14160 } else if (expr->IsLoadStaticFieldNode()) { |
14157 const Field& field = expr->AsLoadStaticFieldNode()->field(); | 14161 const Field& field = expr->AsLoadStaticFieldNode()->field(); |
14158 // We already checked that this field is const and has been | 14162 // We already checked that this field is const and has been |
14159 // initialized. | 14163 // initialized. |
14160 ASSERT(field.is_const()); | 14164 ASSERT(field.is_const()); |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14636 const ArgumentListNode& function_args, | 14640 const ArgumentListNode& function_args, |
14637 const LocalVariable* temp_for_last_arg, | 14641 const LocalVariable* temp_for_last_arg, |
14638 bool is_super_invocation) { | 14642 bool is_super_invocation) { |
14639 UNREACHABLE(); | 14643 UNREACHABLE(); |
14640 return NULL; | 14644 return NULL; |
14641 } | 14645 } |
14642 | 14646 |
14643 } // namespace dart | 14647 } // namespace dart |
14644 | 14648 |
14645 #endif // DART_PRECOMPILED_RUNTIME | 14649 #endif // DART_PRECOMPILED_RUNTIME |
OLD | NEW |