| OLD | NEW |
| 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 Map<int, BailoutInfo> bailouts = null; | 9 Map<int, BailoutInfo> bailouts = null; |
| 10 bool allowSpeculativeOptimization = true; | 10 bool allowSpeculativeOptimization = true; |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 const SourceString('JS_HAS_EQUALS'), library), this); | 263 const SourceString('JS_HAS_EQUALS'), library), this); |
| 264 library.define(new ForeignElement( | 264 library.define(new ForeignElement( |
| 265 const SourceString('JS_CURRENT_ISOLATE'), library), this); | 265 const SourceString('JS_CURRENT_ISOLATE'), library), this); |
| 266 library.define(new ForeignElement( | 266 library.define(new ForeignElement( |
| 267 const SourceString('JS_CALL_IN_ISOLATE'), library), this); | 267 const SourceString('JS_CALL_IN_ISOLATE'), library), this); |
| 268 } | 268 } |
| 269 | 269 |
| 270 void runCompiler(Uri uri) { | 270 void runCompiler(Uri uri) { |
| 271 scanBuiltinLibraries(); | 271 scanBuiltinLibraries(); |
| 272 mainApp = scanner.loadLibrary(uri, null); | 272 mainApp = scanner.loadLibrary(uri, null); |
| 273 Element element; | 273 final Element mainMethod = mainApp.find(MAIN); |
| 274 withCurrentElement(mainApp, () { | 274 if (mainMethod === null) { |
| 275 element = mainApp.find(MAIN); | 275 withCurrentElement(mainApp, () => cancel('Could not find $MAIN')); |
| 276 if (element === null) cancel('Could not find $MAIN'); | 276 } else { |
| 277 }); | 277 withCurrentElement(mainMethod, () { |
| 278 if (!mainMethod.isFunction()) { |
| 279 cancel('main is not a function', element: mainMethod); |
| 280 } |
| 281 FunctionParameters parameters = mainMethod.computeParameters(this); |
| 282 if (parameters.parameterCount > 0) { |
| 283 cancel('main cannot have parameters', element: mainMethod); |
| 284 } |
| 285 }); |
| 286 } |
| 278 native.processNativeClasses(this, universe.libraries.getValues()); | 287 native.processNativeClasses(this, universe.libraries.getValues()); |
| 279 enqueue(new WorkItem.toCompile(element)); | 288 enqueue(new WorkItem.toCompile(mainMethod)); |
| 280 codegenProgress.reset(); | 289 codegenProgress.reset(); |
| 281 while (!worklist.isEmpty()) { | 290 while (!worklist.isEmpty()) { |
| 282 WorkItem work = worklist.removeLast(); | 291 WorkItem work = worklist.removeLast(); |
| 283 withCurrentElement(work.element, () => (work.run)(this)); | 292 withCurrentElement(work.element, () => (work.run)(this)); |
| 284 } | 293 } |
| 285 workListIsClosed = true; | 294 workListIsClosed = true; |
| 286 assert(enqueuer.checkNoEnqueuedInvokedInstanceMethods()); | 295 assert(enqueuer.checkNoEnqueuedInvokedInstanceMethods()); |
| 287 enqueuer.registerFieldClosureInvocations(); | 296 enqueuer.registerFieldClosureInvocations(); |
| 288 emitter.assembleProgram(); | 297 emitter.assembleProgram(); |
| 289 if (!worklist.isEmpty()) { | 298 if (!worklist.isEmpty()) { |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 } | 536 } |
| 528 } | 537 } |
| 529 | 538 |
| 530 class SourceSpan { | 539 class SourceSpan { |
| 531 final Uri uri; | 540 final Uri uri; |
| 532 final int begin; | 541 final int begin; |
| 533 final int end; | 542 final int end; |
| 534 | 543 |
| 535 const SourceSpan(this.uri, this.begin, this.end); | 544 const SourceSpan(this.uri, this.begin, this.end); |
| 536 } | 545 } |
| OLD | NEW |