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

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

Issue 10854176: - Merge function lists when patching classes (no more duplicates). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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.cc ('k') | no next file » | 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 "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/compiler_stats.h" 10 #include "vm/compiler_stats.h"
(...skipping 2927 matching lines...) Expand 10 before | Expand all | Expand 10 after
2938 } else { 2938 } else {
2939 if (!obj.IsClass()) { 2939 if (!obj.IsClass()) {
2940 ErrorMsg(classname_pos, "'%s' is already defined", 2940 ErrorMsg(classname_pos, "'%s' is already defined",
2941 class_name.ToCString()); 2941 class_name.ToCString());
2942 } 2942 }
2943 cls ^= obj.raw(); 2943 cls ^= obj.raw();
2944 if (cls.is_interface()) { 2944 if (cls.is_interface()) {
2945 ErrorMsg(classname_pos, "'%s' %s", 2945 ErrorMsg(classname_pos, "'%s' %s",
2946 class_name.ToCString(), 2946 class_name.ToCString(),
2947 is_patch ? 2947 is_patch ?
2948 "is already defined as interface" : 2948 "interface cannot be patched" :
2949 "interface cannot be patched"); 2949 "is already defined as interface");
2950 } else if (is_patch) { 2950 } else if (is_patch) {
2951 String& patch = String::Handle(Symbols::New("patch ")); 2951 String& patch = String::Handle(Symbols::New("patch "));
2952 patch = String::Concat(patch, class_name); 2952 patch = String::Concat(patch, class_name);
2953 patch = Symbols::New(patch); 2953 patch = Symbols::New(patch);
2954 cls = Class::New(patch, script_, classname_pos); 2954 cls = Class::New(patch, script_, classname_pos);
2955 } else { 2955 } else {
2956 // Not patching a class, but it has been found. This must be one of the 2956 // Not patching a class, but it has been found. This must be one of the
2957 // pre-registered classes from object.cc or a duplicate definition. 2957 // pre-registered classes from object.cc or a duplicate definition.
2958 if (cls.functions() != Object::empty_array()) { 2958 if (cls.functions() != Object::empty_array()) {
2959 ErrorMsg(classname_pos, "class '%s' is already defined", 2959 ErrorMsg(classname_pos, "class '%s' is already defined",
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
3020 3020
3021 // Creating a new array for functions marks the class as parsed. 3021 // Creating a new array for functions marks the class as parsed.
3022 array = Array::MakeArray(members.functions()); 3022 array = Array::MakeArray(members.functions());
3023 cls.SetFunctions(array); 3023 cls.SetFunctions(array);
3024 3024
3025 if (!is_patch) { 3025 if (!is_patch) {
3026 pending_classes.Add(cls, Heap::kOld); 3026 pending_classes.Add(cls, Heap::kOld);
3027 } else { 3027 } else {
3028 // Lookup the patched class and apply the changes. 3028 // Lookup the patched class and apply the changes.
3029 obj = library_.LookupObject(class_name); 3029 obj = library_.LookupObject(class_name);
3030 Class::Cast(obj).ApplyPatch(cls); 3030 const char* err_msg = Class::Cast(obj).ApplyPatch(cls);
3031 if (err_msg != NULL) {
3032 ErrorMsg(classname_pos, "applying patch failed with '%s'", err_msg);
3033 }
3031 } 3034 }
3032 } 3035 }
3033 3036
3034 3037
3035 // Add an implicit constructor if no explicit constructor is present. 3038 // Add an implicit constructor if no explicit constructor is present.
3036 void Parser::AddImplicitConstructor(ClassDesc* class_desc) { 3039 void Parser::AddImplicitConstructor(ClassDesc* class_desc) {
3037 // The implicit constructor is unnamed, has no explicit parameter, 3040 // The implicit constructor is unnamed, has no explicit parameter,
3038 // and contains a supercall in the initializer list. 3041 // and contains a supercall in the initializer list.
3039 String& ctor_name = String::ZoneHandle( 3042 String& ctor_name = String::ZoneHandle(
3040 String::Concat(class_desc->class_name(), String::Handle(Symbols::Dot()))); 3043 String::Concat(class_desc->class_name(), String::Handle(Symbols::Dot())));
(...skipping 6038 matching lines...) Expand 10 before | Expand all | Expand 10 after
9079 void Parser::SkipQualIdent() { 9082 void Parser::SkipQualIdent() {
9080 ASSERT(IsIdentifier()); 9083 ASSERT(IsIdentifier());
9081 ConsumeToken(); 9084 ConsumeToken();
9082 if (CurrentToken() == Token::kPERIOD) { 9085 if (CurrentToken() == Token::kPERIOD) {
9083 ConsumeToken(); // Consume the kPERIOD token. 9086 ConsumeToken(); // Consume the kPERIOD token.
9084 ExpectIdentifier("identifier expected after '.'"); 9087 ExpectIdentifier("identifier expected after '.'");
9085 } 9088 }
9086 } 9089 }
9087 9090
9088 } // namespace dart 9091 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698