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

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

Issue 10441111: - Rename class index to class id. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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/assembler_macros_x64.cc ('k') | runtime/vm/class_table.cc » ('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/class_finalizer.h" 5 #include "vm/class_finalizer.h"
6 6
7 #include "vm/flags.h" 7 #include "vm/flags.h"
8 #include "vm/heap.h" 8 #include "vm/heap.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/longjump.h" 10 #include "vm/longjump.h"
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 } 1194 }
1195 1195
1196 1196
1197 // Returns false if the function type alias illegally refers to itself. 1197 // Returns false if the function type alias illegally refers to itself.
1198 bool ClassFinalizer::IsAliasCycleFree(const Class& cls, 1198 bool ClassFinalizer::IsAliasCycleFree(const Class& cls,
1199 GrowableArray<intptr_t>* visited) { 1199 GrowableArray<intptr_t>* visited) {
1200 ASSERT(cls.IsSignatureClass()); 1200 ASSERT(cls.IsSignatureClass());
1201 ASSERT(!cls.IsCanonicalSignatureClass()); 1201 ASSERT(!cls.IsCanonicalSignatureClass());
1202 ASSERT(!cls.is_finalized()); 1202 ASSERT(!cls.is_finalized());
1203 ASSERT(visited != NULL); 1203 ASSERT(visited != NULL);
1204 const intptr_t cls_index = cls.index(); 1204 const intptr_t cls_index = cls.id();
1205 for (int i = 0; i < visited->length(); i++) { 1205 for (int i = 0; i < visited->length(); i++) {
1206 if ((*visited)[i] == cls_index) { 1206 if ((*visited)[i] == cls_index) {
1207 // We have already visited alias 'cls'. We found a cycle. 1207 // We have already visited alias 'cls'. We found a cycle.
1208 return false; 1208 return false;
1209 } 1209 }
1210 } 1210 }
1211 1211
1212 // Visit the result type and parameter types of this signature type. 1212 // Visit the result type and parameter types of this signature type.
1213 visited->Add(cls.index()); 1213 visited->Add(cls.id());
1214 const Function& function = Function::Handle(cls.signature_function()); 1214 const Function& function = Function::Handle(cls.signature_function());
1215 // Check class of result type. 1215 // Check class of result type.
1216 AbstractType& type = AbstractType::Handle(function.result_type()); 1216 AbstractType& type = AbstractType::Handle(function.result_type());
1217 ResolveType(cls, type, kFinalize); 1217 ResolveType(cls, type, kFinalize);
1218 if (type.IsType() && !type.IsMalformed()) { 1218 if (type.IsType() && !type.IsMalformed()) {
1219 const Class& type_class = Class::Handle(type.type_class()); 1219 const Class& type_class = Class::Handle(type.type_class());
1220 if (!type_class.is_finalized() && 1220 if (!type_class.is_finalized() &&
1221 type_class.IsSignatureClass() && 1221 type_class.IsSignatureClass() &&
1222 !type_class.IsCanonicalSignatureClass()) { 1222 !type_class.IsCanonicalSignatureClass()) {
1223 if (!IsAliasCycleFree(type_class, visited)) { 1223 if (!IsAliasCycleFree(type_class, visited)) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 // Walks the graph of explicitly declared interfaces of classes and 1279 // Walks the graph of explicitly declared interfaces of classes and
1280 // interfaces recursively. Resolves unresolved interfaces. 1280 // interfaces recursively. Resolves unresolved interfaces.
1281 // Returns false if there is an interface reference that cannot be 1281 // Returns false if there is an interface reference that cannot be
1282 // resolved, or if there is a cycle in the graph. We detect cycles by 1282 // resolved, or if there is a cycle in the graph. We detect cycles by
1283 // remembering interfaces we've visited in each path through the 1283 // remembering interfaces we've visited in each path through the
1284 // graph. If we visit an interface a second time on a given path, 1284 // graph. If we visit an interface a second time on a given path,
1285 // we found a loop. 1285 // we found a loop.
1286 void ClassFinalizer::ResolveInterfaces(const Class& cls, 1286 void ClassFinalizer::ResolveInterfaces(const Class& cls,
1287 GrowableArray<intptr_t>* visited) { 1287 GrowableArray<intptr_t>* visited) {
1288 ASSERT(visited != NULL); 1288 ASSERT(visited != NULL);
1289 const intptr_t cls_index = cls.index(); 1289 const intptr_t cls_index = cls.id();
1290 for (int i = 0; i < visited->length(); i++) { 1290 for (int i = 0; i < visited->length(); i++) {
1291 if ((*visited)[i] == cls_index) { 1291 if ((*visited)[i] == cls_index) {
1292 // We have already visited interface class 'cls'. We found a cycle. 1292 // We have already visited interface class 'cls'. We found a cycle.
1293 const String& interface_name = String::Handle(cls.Name()); 1293 const String& interface_name = String::Handle(cls.Name());
1294 const Script& script = Script::Handle(cls.script()); 1294 const Script& script = Script::Handle(cls.script());
1295 ReportError(script, cls.token_index(), 1295 ReportError(script, cls.token_index(),
1296 "cyclic reference found for interface '%s'", 1296 "cyclic reference found for interface '%s'",
1297 interface_name.ToCString()); 1297 interface_name.ToCString());
1298 } 1298 }
1299 } 1299 }
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 void ClassFinalizer::ReportError(const char* format, ...) { 1501 void ClassFinalizer::ReportError(const char* format, ...) {
1502 va_list args; 1502 va_list args;
1503 va_start(args, format); 1503 va_start(args, format);
1504 const Error& error = Error::Handle( 1504 const Error& error = Error::Handle(
1505 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); 1505 Parser::FormatError(Script::Handle(), -1, "Error", format, args));
1506 va_end(args); 1506 va_end(args);
1507 ReportError(error); 1507 ReportError(error);
1508 } 1508 }
1509 1509
1510 } // namespace dart 1510 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/assembler_macros_x64.cc ('k') | runtime/vm/class_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698