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

Side by Side Diff: lib/compiler/implementation/compiler.dart

Issue 10080003: Revert "Implement interface types." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 | « frog/tests/leg/src/ResolverTest.dart ('k') | lib/compiler/implementation/resolver.dart » ('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 class WorkItem { 5 class WorkItem {
6 final Element element; 6 final Element element;
7 TreeElements resolutionTree; 7 TreeElements resolutionTree;
8 Function run; 8 Function run;
9 bool allowSpeculativeOptimization = true; 9 bool allowSpeculativeOptimization = true;
10 List<HTypeGuard> guards = const <HTypeGuard>[]; 10 List<HTypeGuard> guards = const <HTypeGuard>[];
(...skipping 17 matching lines...) Expand all
28 String codegen(Compiler compiler) { 28 String codegen(Compiler compiler) {
29 return compiler.codegen(this); 29 return compiler.codegen(this);
30 } 30 }
31 } 31 }
32 32
33 class Compiler implements DiagnosticListener { 33 class Compiler implements DiagnosticListener {
34 Queue<WorkItem> worklist; 34 Queue<WorkItem> worklist;
35 Universe universe; 35 Universe universe;
36 String assembledCode; 36 String assembledCode;
37 Namer namer; 37 Namer namer;
38 final Types types; 38 Types types;
39 39
40 final Tracer tracer; 40 final Tracer tracer;
41 41
42 CompilerTask measuredTask; 42 CompilerTask measuredTask;
43 Element _currentElement; 43 Element _currentElement;
44 LibraryElement coreLibrary; 44 LibraryElement coreLibrary;
45 LibraryElement coreImplLibrary; 45 LibraryElement coreImplLibrary;
46 LibraryElement isolateLibrary; 46 LibraryElement isolateLibrary;
47 LibraryElement jsHelperLibrary; 47 LibraryElement jsHelperLibrary;
48 LibraryElement mainApp; 48 LibraryElement mainApp;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 void initializeSpecialClasses() { 215 void initializeSpecialClasses() {
216 objectClass = coreLibrary.find(const SourceString('Object')); 216 objectClass = coreLibrary.find(const SourceString('Object'));
217 boolClass = coreLibrary.find(const SourceString('bool')); 217 boolClass = coreLibrary.find(const SourceString('bool'));
218 numClass = coreLibrary.find(const SourceString('num')); 218 numClass = coreLibrary.find(const SourceString('num'));
219 intClass = coreLibrary.find(const SourceString('int')); 219 intClass = coreLibrary.find(const SourceString('int'));
220 doubleClass = coreLibrary.find(const SourceString('double')); 220 doubleClass = coreLibrary.find(const SourceString('double'));
221 stringClass = coreLibrary.find(const SourceString('String')); 221 stringClass = coreLibrary.find(const SourceString('String'));
222 functionClass = coreLibrary.find(const SourceString('Function')); 222 functionClass = coreLibrary.find(const SourceString('Function'));
223 listClass = coreLibrary.find(const SourceString('List')); 223 listClass = coreLibrary.find(const SourceString('List'));
224 closureClass = jsHelperLibrary.find(const SourceString('Closure')); 224 closureClass = jsHelperLibrary.find(const SourceString('Closure'));
225 dynamicClass = types.dynamicType.element; 225 dynamicClass = jsHelperLibrary.find(const SourceString('Dynamic'));
226 nullClass = jsHelperLibrary.find(const SourceString('Null')); 226 nullClass = jsHelperLibrary.find(const SourceString('Null'));
227 } 227 }
228 228
229 void scanBuiltinLibraries() { 229 void scanBuiltinLibraries() {
230 coreImplLibrary = scanBuiltinLibrary('coreimpl'); 230 coreImplLibrary = scanBuiltinLibrary('coreimpl');
231 jsHelperLibrary = scanBuiltinLibrary('_js_helper'); 231 jsHelperLibrary = scanBuiltinLibrary('_js_helper');
232 coreLibrary = scanBuiltinLibrary('core'); 232 coreLibrary = scanBuiltinLibrary('core');
233 233
234 // Since coreLibrary import the libraries "coreimpl", and 234 // Since coreLibrary import the libraries "coreimpl", and
235 // "js_helper", coreLibrary is null when they are being built. So 235 // "js_helper", coreLibrary is null when they are being built. So
(...skipping 23 matching lines...) Expand all
259 const SourceString('JS_CURRENT_ISOLATE'), library), this); 259 const SourceString('JS_CURRENT_ISOLATE'), library), this);
260 library.define(new ForeignElement( 260 library.define(new ForeignElement(
261 const SourceString('JS_CALL_IN_ISOLATE'), library), this); 261 const SourceString('JS_CALL_IN_ISOLATE'), library), this);
262 library.define(new ForeignElement( 262 library.define(new ForeignElement(
263 const SourceString('DART_CLOSURE_TO_JS'), library), this); 263 const SourceString('DART_CLOSURE_TO_JS'), library), this);
264 } 264 }
265 265
266 void runCompiler(Uri uri) { 266 void runCompiler(Uri uri) {
267 scanBuiltinLibraries(); 267 scanBuiltinLibraries();
268 mainApp = scanner.loadLibrary(uri, null); 268 mainApp = scanner.loadLibrary(uri, null);
269 final Element mainElement = mainApp.find(MAIN); 269 final Element mainMethod = mainApp.find(MAIN);
270 if (mainElement === null) { 270 if (mainMethod === null) {
271 withCurrentElement(mainApp, () => cancel('Could not find $MAIN')); 271 withCurrentElement(mainApp, () => cancel('Could not find $MAIN'));
272 } else { 272 } else {
273 withCurrentElement(mainElement, () { 273 withCurrentElement(mainMethod, () {
274 if (!mainElement.isFunction()) { 274 if (!mainMethod.isFunction()) {
275 cancel('main is not a function', element: mainElement); 275 cancel('main is not a function', element: mainMethod);
276 } 276 }
277 FunctionElement mainMethod = mainElement;
278 FunctionParameters parameters = mainMethod.computeParameters(this); 277 FunctionParameters parameters = mainMethod.computeParameters(this);
279 if (parameters.parameterCount > 0) { 278 if (parameters.parameterCount > 0) {
280 cancel('main cannot have parameters', element: mainMethod); 279 cancel('main cannot have parameters', element: mainMethod);
281 } 280 }
282 }); 281 });
283 } 282 }
284 native.processNativeClasses(this, universe.libraries.getValues()); 283 native.processNativeClasses(this, universe.libraries.getValues());
285 enqueue(new WorkItem.toCompile(mainElement)); 284 enqueue(new WorkItem.toCompile(mainMethod));
286 codegenProgress.reset(); 285 codegenProgress.reset();
287 while (!worklist.isEmpty()) { 286 while (!worklist.isEmpty()) {
288 WorkItem work = worklist.removeLast(); 287 WorkItem work = worklist.removeLast();
289 withCurrentElement(work.element, () => (work.run)(this)); 288 withCurrentElement(work.element, () => (work.run)(this));
290 } 289 }
291 workListIsClosed = true; 290 workListIsClosed = true;
292 assert(enqueuer.checkNoEnqueuedInvokedInstanceMethods()); 291 assert(enqueuer.checkNoEnqueuedInvokedInstanceMethods());
293 enqueuer.registerFieldClosureInvocations(); 292 enqueuer.registerFieldClosureInvocations();
294 emitter.assembleProgram(); 293 emitter.assembleProgram();
295 if (!worklist.isEmpty()) { 294 if (!worklist.isEmpty()) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 () => resolver.resolveSignature(element)); 399 () => resolver.resolveSignature(element));
401 } 400 }
402 401
403 Constant compileVariable(VariableElement element) { 402 Constant compileVariable(VariableElement element) {
404 return withCurrentElement(element, () { 403 return withCurrentElement(element, () {
405 return constantHandler.compileVariable(element); 404 return constantHandler.compileVariable(element);
406 }); 405 });
407 } 406 }
408 407
409 reportWarning(Node node, var message) { 408 reportWarning(Node node, var message) {
410 if (message is TypeWarning) { 409 if (message is ResolutionWarning) {
410 // TODO(ahe): Don't supress this warning when we support type variables.
411 if (message.message.kind === MessageKind.CANNOT_RESOLVE_TYPE) return;
412 } else if (message is TypeWarning) {
411 // TODO(ahe): Don't supress these warning when the type checker 413 // TODO(ahe): Don't supress these warning when the type checker
412 // is more complete. 414 // is more complete.
413 if (message.message.kind === MessageKind.NOT_ASSIGNABLE) return; 415 if (message.message.kind === MessageKind.NOT_ASSIGNABLE) return;
414 if (message.message.kind === MessageKind.MISSING_RETURN) return; 416 if (message.message.kind === MessageKind.MISSING_RETURN) return;
415 if (message.message.kind === MessageKind.ADDITIONAL_ARGUMENT) return; 417 if (message.message.kind === MessageKind.ADDITIONAL_ARGUMENT) return;
416 if (message.message.kind === MessageKind.METHOD_NOT_FOUND) return; 418 if (message.message.kind === MessageKind.METHOD_NOT_FOUND) return;
417 } 419 }
418 SourceSpan span = spanFromNode(node); 420 SourceSpan span = spanFromNode(node);
419 reportDiagnostic(span, "${magenta('warning:')} $message", false); 421 reportDiagnostic(span, "${magenta('warning:')} $message", false);
420 } 422 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 } 541 }
540 } 542 }
541 543
542 class SourceSpan { 544 class SourceSpan {
543 final Uri uri; 545 final Uri uri;
544 final int begin; 546 final int begin;
545 final int end; 547 final int end;
546 548
547 const SourceSpan(this.uri, this.begin, this.end); 549 const SourceSpan(this.uri, this.begin, this.end);
548 } 550 }
OLDNEW
« no previous file with comments | « frog/tests/leg/src/ResolverTest.dart ('k') | lib/compiler/implementation/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698