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 #library('frog_leg'); | 5 #library('frog_leg'); |
6 | 6 |
7 #import('../../lib/uri/uri.dart'); | 7 #import('../../lib/uri/uri.dart'); |
8 #import('../lang.dart', prefix: 'frog'); | 8 #import('../lang.dart', prefix: 'frog'); |
9 #import('api.dart', prefix: 'api'); | 9 #import('api.dart', prefix: 'api'); |
10 #import('io/io.dart', prefix: 'io'); | 10 #import('io/io.dart', prefix: 'io'); |
(...skipping 24 matching lines...) Expand all Loading... |
35 } | 35 } |
36 sb.add('${uriParts.last()}'); | 36 sb.add('${uriParts.last()}'); |
37 return sb.toString(); | 37 return sb.toString(); |
38 } | 38 } |
39 return uri.toString(); | 39 return uri.toString(); |
40 } | 40 } |
41 | 41 |
42 bool compile(frog.World world) { | 42 bool compile(frog.World world) { |
43 final throwOnError = frog.options.throwOnErrors; | 43 final throwOnError = frog.options.throwOnErrors; |
44 final showWarnings = frog.options.showWarnings; | 44 final showWarnings = frog.options.showWarnings; |
| 45 final allowMockCompilation = frog.options.allowMockCompilation; |
45 // final compiler = new WorldCompiler(world, throwOnError); | 46 // final compiler = new WorldCompiler(world, throwOnError); |
46 Uri cwd = new Uri(scheme: 'file', path: io.getCurrentDirectory()); | 47 Uri cwd = new Uri(scheme: 'file', path: io.getCurrentDirectory()); |
47 Uri uri = cwd.resolve(frog.options.dartScript); | 48 Uri uri = cwd.resolve(frog.options.dartScript); |
48 String frogLibDir = frog.options.libDir; | 49 String frogLibDir = frog.options.libDir; |
49 if (!frogLibDir.endsWith("/")) frogLibDir = "$frogLibDir/"; | 50 if (!frogLibDir.endsWith("/")) frogLibDir = "$frogLibDir/"; |
50 Uri frogLib = new Uri(scheme: 'file', path: frogLibDir); | 51 Uri frogLib = new Uri(scheme: 'file', path: frogLibDir); |
51 Uri libraryRoot = frogLib.resolve('../leg/lib/'); | 52 Uri libraryRoot = frogLib.resolve('../leg/lib/'); |
52 Map<String, frog.SourceFile> sourceFiles = <frog.SourceFile>{}; | 53 Map<String, frog.SourceFile> sourceFiles = <frog.SourceFile>{}; |
53 | 54 |
54 Future<String> provider(Uri uri) { | 55 Future<String> provider(Uri uri) { |
(...skipping 17 matching lines...) Expand all Loading... |
72 if (uri === null) { | 73 if (uri === null) { |
73 assert(fatal); | 74 assert(fatal); |
74 print(message); | 75 print(message); |
75 } else if (fatal || showWarnings) { | 76 } else if (fatal || showWarnings) { |
76 frog.SourceFile file = sourceFiles[uri.toString()]; | 77 frog.SourceFile file = sourceFiles[uri.toString()]; |
77 print(file.getLocationMessage(message, begin, end, true)); | 78 print(file.getLocationMessage(message, begin, end, true)); |
78 } | 79 } |
79 if (fatal && throwOnError) throw new AbortLeg(message); | 80 if (fatal && throwOnError) throw new AbortLeg(message); |
80 } | 81 } |
81 | 82 |
| 83 List<String> options = new List<String>(); |
| 84 if (allowMockCompilation) options.add('--allow-mock-compilation'); |
| 85 |
82 // TODO(ahe): We expect the future to be complete and call value | 86 // TODO(ahe): We expect the future to be complete and call value |
83 // directly. In effect, we don't support truly asynchronous API. | 87 // directly. In effect, we don't support truly asynchronous API. |
84 String code = api.compile(uri, libraryRoot, provider, handler).value; | 88 String code = api.compile(uri, libraryRoot, provider, handler, options).value; |
85 if (code === null) return false; | 89 if (code === null) return false; |
86 world.legCode = code; | 90 world.legCode = code; |
87 world.jsBytesWritten = code.length; | 91 world.jsBytesWritten = code.length; |
88 return true; | 92 return true; |
89 } | 93 } |
90 | 94 |
91 class AbortLeg { | 95 class AbortLeg { |
92 final message; | 96 final message; |
93 AbortLeg(this.message); | 97 AbortLeg(this.message); |
94 toString() => 'Aborted due to --throw-on-error: $message'; | 98 toString() => 'Aborted due to --throw-on-error: $message'; |
95 } | 99 } |
OLD | NEW |