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

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

Issue 12473002: Complete implementation of bounds checking in the vm, by introducing a vm object (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object_store.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/parser.h" 5 #include "vm/parser.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 3444 matching lines...) Expand 10 before | Expand all | Expand 10 after
3455 3455
3456 // The result of ParseMixins() is a chain of super types that is the 3456 // The result of ParseMixins() is a chain of super types that is the
3457 // result of the mixin composition 'S with M1, M2, ...'. The mixin 3457 // result of the mixin composition 'S with M1, M2, ...'. The mixin
3458 // application classes are anonymous (i.e. not registered in the current 3458 // application classes are anonymous (i.e. not registered in the current
3459 // library). We steal the super type and mixin type from the bottom of 3459 // library). We steal the super type and mixin type from the bottom of
3460 // the chain and add it to the named mixin application class. The bottom 3460 // the chain and add it to the named mixin application class. The bottom
3461 // anonymous class in the chain is thrown away. 3461 // anonymous class in the chain is thrown away.
3462 const Class& anon_mixin_app_class = 3462 const Class& anon_mixin_app_class =
3463 Class::Handle(mixin_application_type.type_class()); 3463 Class::Handle(mixin_application_type.type_class());
3464 mixin_application.set_super_type( 3464 mixin_application.set_super_type(
3465 Type::Handle(anon_mixin_app_class.super_type())); 3465 AbstractType::Handle(anon_mixin_app_class.super_type()));
3466 mixin_application.set_mixin(Type::Handle(anon_mixin_app_class.mixin())); 3466 mixin_application.set_mixin(Type::Handle(anon_mixin_app_class.mixin()));
3467 const Array& interfaces = Array::Handle(anon_mixin_app_class.interfaces()); 3467 const Array& interfaces = Array::Handle(anon_mixin_app_class.interfaces());
3468 mixin_application.set_interfaces(interfaces); 3468 mixin_application.set_interfaces(interfaces);
3469 AddImplicitConstructor(mixin_application); 3469 AddImplicitConstructor(mixin_application);
3470 3470
3471 if (CurrentToken() == Token::kIMPLEMENTS) { 3471 if (CurrentToken() == Token::kIMPLEMENTS) {
3472 Array& interfaces = Array::Handle(); 3472 Array& interfaces = Array::Handle();
3473 const intptr_t interfaces_pos = TokenPos(); 3473 const intptr_t interfaces_pos = TokenPos();
3474 const Type& super_type = Type::Handle(mixin_application.super_type()); 3474 Type& super_type = Type::Handle();
3475 super_type ^= mixin_application.super_type();
3475 interfaces = ParseInterfaceList(super_type); 3476 interfaces = ParseInterfaceList(super_type);
3476 AddInterfaces(interfaces_pos, mixin_application, interfaces); 3477 AddInterfaces(interfaces_pos, mixin_application, interfaces);
3477 } 3478 }
3478 3479
3479 pending_classes.Add(mixin_application, Heap::kOld); 3480 pending_classes.Add(mixin_application, Heap::kOld);
3480 ExpectSemicolon(); 3481 ExpectSemicolon();
3481 } 3482 }
3482 3483
3483 3484
3484 // Look ahead to detect if we are seeing ident [ TypeParameters ] "(". 3485 // Look ahead to detect if we are seeing ident [ TypeParameters ] "(".
(...skipping 5840 matching lines...) Expand 10 before | Expand all | Expand 10 after
9325 return ThrowNoSuchMethodError(call_pos, 9326 return ThrowNoSuchMethodError(call_pos,
9326 type_class, 9327 type_class,
9327 external_constructor_name, 9328 external_constructor_name,
9328 InvocationMirror::kConstructor, 9329 InvocationMirror::kConstructor,
9329 InvocationMirror::kMethod); 9330 InvocationMirror::kMethod);
9330 } else if (constructor.IsRedirectingFactory()) { 9331 } else if (constructor.IsRedirectingFactory()) {
9331 Type& redirect_type = Type::Handle(constructor.RedirectionType()); 9332 Type& redirect_type = Type::Handle(constructor.RedirectionType());
9332 if (!redirect_type.IsMalformed() && !redirect_type.IsInstantiated()) { 9333 if (!redirect_type.IsMalformed() && !redirect_type.IsInstantiated()) {
9333 // The type arguments of the redirection type are instantiated from the 9334 // The type arguments of the redirection type are instantiated from the
9334 // type arguments of the parsed type of the 'new' or 'const' expression. 9335 // type arguments of the parsed type of the 'new' or 'const' expression.
9335 redirect_type ^= redirect_type.InstantiateFrom(type_arguments); 9336 Error& malformed_error = Error::Handle();
9337 redirect_type ^= redirect_type.InstantiateFrom(type_arguments,
9338 &malformed_error);
9339 if (!malformed_error.IsNull()) {
9340 redirect_type.set_malformed_error(malformed_error);
9341 }
9336 } 9342 }
9337 if (redirect_type.IsMalformed()) { 9343 if (redirect_type.IsMalformed()) {
9338 if (is_const) { 9344 if (is_const) {
9339 const Error& error = Error::Handle(redirect_type.malformed_error()); 9345 ErrorMsg(Error::Handle(redirect_type.malformed_error()));
9340 ErrorMsg(error);
9341 } 9346 }
9342 return ThrowTypeError(redirect_type.token_pos(), redirect_type); 9347 return ThrowTypeError(redirect_type.token_pos(), redirect_type);
9343 } 9348 }
9344 if (FLAG_enable_type_checks && !redirect_type.IsSubtypeOf(type, NULL)) { 9349 if (FLAG_enable_type_checks && !redirect_type.IsSubtypeOf(type, NULL)) {
9345 // Additional type checking of the result is necessary. 9350 // Additional type checking of the result is necessary.
9346 type_bound = type.raw(); 9351 type_bound = type.raw();
9347 } 9352 }
9348 type = redirect_type.raw(); 9353 type = redirect_type.raw();
9349 type_class = type.type_class(); 9354 type_class = type.type_class();
9350 type_arguments = type.arguments(); 9355 type_arguments = type.arguments();
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
10064 void Parser::SkipQualIdent() { 10069 void Parser::SkipQualIdent() {
10065 ASSERT(IsIdentifier()); 10070 ASSERT(IsIdentifier());
10066 ConsumeToken(); 10071 ConsumeToken();
10067 if (CurrentToken() == Token::kPERIOD) { 10072 if (CurrentToken() == Token::kPERIOD) {
10068 ConsumeToken(); // Consume the kPERIOD token. 10073 ConsumeToken(); // Consume the kPERIOD token.
10069 ExpectIdentifier("identifier expected after '.'"); 10074 ExpectIdentifier("identifier expected after '.'");
10070 } 10075 }
10071 } 10076 }
10072 10077
10073 } // namespace dart 10078 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object_store.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698