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

Side by Side Diff: frog/world.dart

Issue 8681027: Fix bug 578 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: prereviewed Created 9 years, 1 month 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 | « frog/type.dart ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 /** The one true [World]. */ 5 /** The one true [World]. */
6 World world; 6 World world;
7 7
8 /** 8 /**
9 * Should be called exactly once to setup singleton world. 9 * Should be called exactly once to setup singleton world.
10 * Can use world.reset() to reinitialize. 10 * Can use world.reset() to reinitialize.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 Map<String, Library> libraries; 69 Map<String, Library> libraries;
70 Library corelib; 70 Library corelib;
71 71
72 Library get coreimpl() => libraries['dart:coreimpl']; 72 Library get coreimpl() => libraries['dart:coreimpl'];
73 Library get dom() => libraries['dart:dom']; 73 Library get dom() => libraries['dart:dom'];
74 74
75 List<Library> _todo; 75 List<Library> _todo;
76 76
77 /** Internal map to track name conflicts in the generated javascript. */ 77 /** Internal map to track name conflicts in the generated javascript. */
78 Map<String, Named> _topNames; 78 Map<String, Element> _topNames;
79 79
80 Map<String, MemberSet> _members; 80 Map<String, MemberSet> _members;
81 81
82 int errors = 0, warnings = 0; 82 int errors = 0, warnings = 0;
83 int dartBytesRead = 0, jsBytesWritten = 0; 83 int dartBytesRead = 0, jsBytesWritten = 0;
84 bool seenFatal = false; 84 bool seenFatal = false;
85 85
86 // Special types to Dart. 86 // Special types to Dart.
87 DefinedType varType; 87 DefinedType varType;
88 // TODO(jimhug): Is this ever not === varType? 88 // TODO(jimhug): Is this ever not === varType?
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 var mset = _members[member.name]; 153 var mset = _members[member.name];
154 if (mset == null) { 154 if (mset == null) {
155 mset = new MemberSet(member, isVar:true); 155 mset = new MemberSet(member, isVar:true);
156 _members[mset.name] = mset; 156 _members[mset.name] = mset;
157 } else { 157 } else {
158 mset.members.add(member); 158 mset.members.add(member);
159 } 159 }
160 } 160 }
161 161
162 _addTopName(Named named) { 162 _addTopName(Element named) {
163 var existing = _topNames[named.name]; 163 var existing = _topNames[named.jsname];
164 if (existing != null) { 164 if (existing != null) {
165 info('mangling matching top level name "${named.name}" in ' 165 info('mangling matching top level name "${named.jsname}" in '
166 + 'both "${named.library.name}" and "${existing.library.name}"'); 166 + 'both "${named.library.jsname}" and "${existing.library.jsname}"');
167 167
168 if (named.isNative) { 168 if (named.isNative) {
169 // resolve conflicts in favor first of natives 169 // resolve conflicts in favor first of natives
170 if (existing.isNative) { 170 if (existing.isNative) {
171 world.internalError('conflicting native names "${named.name}" ' 171 world.internalError('conflicting native names "${named.jsname}" '
172 + '(already defined in ${existing.span.locationText})', 172 + '(already defined in ${existing.span.locationText})',
173 named.span); 173 named.span);
174 } else { 174 } else {
175 _topNames[named.name] = named; 175 _topNames[named.jsname] = named;
176 _addJavascriptTopName(existing); 176 _addJavascriptTopName(existing);
177 } 177 }
178 } else if (named.library.isCore) { 178 } else if (named.library.isCore) {
179 // then in favor of corelib 179 // then in favor of corelib
180 if (existing.library.isCore) { 180 if (existing.library.isCore) {
181 world.internalError( 181 world.internalError(
182 'conflicting top-level names in core "${named.name}" ' 182 'conflicting top-level names in core "${named.jsname}" '
183 + '(previously defined in ${existing.span.locationText})', 183 + '(previously defined in ${existing.span.locationText})',
184 named.span); 184 named.span);
185 } else { 185 } else {
186 _topNames[named.name] = named; 186 _topNames[named.jsname] = named;
187 _addJavascriptTopName(existing); 187 _addJavascriptTopName(existing);
188 } 188 }
189 } else { 189 } else {
190 // then just first in wins 190 // then just first in wins
191 _addJavascriptTopName(named); 191 _addJavascriptTopName(named);
192 } 192 }
193 } else { 193 } else {
194 _topNames[named.name] = named; 194 _topNames[named.jsname] = named;
195 } 195 }
196 } 196 }
197 197
198 _addJavascriptTopName(Named named) { 198 _addJavascriptTopName(Element named) {
199 named.jsname = '${named.library.jsname}_${named.name}'; 199 named._jsname = '${named.library.jsname}_${named.jsname}';
200 final existing = _topNames[named.jsname]; 200 final existing = _topNames[named.jsname];
201 if (existing != null && existing != named) { 201 if (existing != null && existing != named) {
202 world.internalError('name mangling failed for "${named.jsname}" ' 202 world.internalError('name mangling failed for "${named.jsname}" '
203 + '("${named.jsname}" defined also in ${existing.span.locationText})', 203 + '("${named.jsname}" defined also in ${existing.span.locationText})',
204 named.span); 204 named.span);
205 } 205 }
206 _topNames[named.jsname] = named; 206 _topNames[named.jsname] = named;
207 } 207 }
208 208
209 _addType(Type type) { 209 _addType(Type type) {
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 442
443 withTiming(String name, f()) { 443 withTiming(String name, f()) {
444 final sw = new Stopwatch(); 444 final sw = new Stopwatch();
445 sw.start(); 445 sw.start();
446 var result = f(); 446 var result = f();
447 sw.stop(); 447 sw.stop();
448 info('$name in ${sw.elapsedInMs()}msec'); 448 info('$name in ${sw.elapsedInMs()}msec');
449 return result; 449 return result;
450 } 450 }
451 } 451 }
OLDNEW
« no previous file with comments | « frog/type.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698