| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 import 'memory_compiler.dart'; | 7 import 'memory_compiler.dart'; |
| 8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
| 9 import 'package:compiler/src/commandline_options.dart'; | 9 import 'package:compiler/src/commandline_options.dart'; |
| 10 import 'package:compiler/src/common_elements.dart'; | 10 import 'package:compiler/src/common_elements.dart'; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 String buildDir = Platform.isMacOS ? 'xcodebuild' : 'out'; | 45 String buildDir = Platform.isMacOS ? 'xcodebuild' : 'out'; |
| 46 String configuration = | 46 String configuration = |
| 47 Platform.environment['DART_CONFIGURATION'] ?? 'ReleaseX64'; | 47 Platform.environment['DART_CONFIGURATION'] ?? 'ReleaseX64'; |
| 48 var platform = Platform.script.resolve( | 48 var platform = Platform.script.resolve( |
| 49 '../../../$buildDir/$configuration/patched_dart2js_sdk/platform.dill'); | 49 '../../../$buildDir/$configuration/patched_dart2js_sdk/platform.dill'); |
| 50 var options = new CompilerOptions() | 50 var options = new CompilerOptions() |
| 51 ..target = new Dart2jsTarget(new TargetFlags()) | 51 ..target = new Dart2jsTarget(new TargetFlags()) |
| 52 ..packagesFileUri = Platform.script.resolve('../../../.packages') | 52 ..packagesFileUri = Platform.script.resolve('../../../.packages') |
| 53 ..compileSdk = true | 53 ..compileSdk = true |
| 54 ..linkedDependencies = [platform] | 54 ..linkedDependencies = [platform] |
| 55 ..verify = true | 55 ..setExitCodeOnProblem = true |
| 56 ..onError = errorHandler; | 56 ..verify = true; |
| 57 | 57 |
| 58 List<int> kernelBinary = | 58 List<int> kernelBinary = |
| 59 serializeProgram(await kernelForProgram(uri, options)); | 59 serializeProgram(await kernelForProgram(uri, options)); |
| 60 CompilerImpl compiler = compilerFor( | 60 CompilerImpl compiler = compilerFor( |
| 61 entryPoint: entryPoint, | 61 entryPoint: entryPoint, |
| 62 memorySourceFiles: {'main.dill': kernelBinary}, | 62 memorySourceFiles: {'main.dill': kernelBinary}, |
| 63 diagnosticHandler: diagnostics, | 63 diagnosticHandler: diagnostics, |
| 64 outputProvider: output, | 64 outputProvider: output, |
| 65 options: [Flags.loadFromDill]); | 65 options: [Flags.loadFromDill]); |
| 66 await compiler.setupSdk(); | 66 await compiler.setupSdk(); |
| 67 await compiler.libraryLoader.loadLibrary(entryPoint); | 67 await compiler.libraryLoader.loadLibrary(entryPoint); |
| 68 | 68 |
| 69 Expect.equals(0, diagnostics.errors.length); | 69 Expect.equals(0, diagnostics.errors.length); |
| 70 Expect.equals(0, diagnostics.warnings.length); | 70 Expect.equals(0, diagnostics.warnings.length); |
| 71 | 71 |
| 72 ElementEnvironment environment = | 72 ElementEnvironment environment = |
| 73 compiler.frontendStrategy.elementEnvironment; | 73 compiler.frontendStrategy.elementEnvironment; |
| 74 LibraryEntity library = environment.lookupLibrary(uri); | 74 LibraryEntity library = environment.lookupLibrary(uri); |
| 75 Expect.isNotNull(library); | 75 Expect.isNotNull(library); |
| 76 ClassEntity clss = environment.lookupClass(library, 'ListLiteralTest'); | 76 ClassEntity clss = environment.lookupClass(library, 'ListLiteralTest'); |
| 77 Expect.isNotNull(clss); | 77 Expect.isNotNull(clss); |
| 78 var member = environment.lookupClassMember(clss, 'testMain'); | 78 var member = environment.lookupClassMember(clss, 'testMain'); |
| 79 Expect.isNotNull(member); | 79 Expect.isNotNull(member); |
| 80 }); | 80 }); |
| 81 } | 81 } |
| 82 | |
| 83 void errorHandler(CompilationError e) { | |
| 84 exitCode = 1; | |
| 85 print(e.message); | |
| 86 } | |
| OLD | NEW |