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

Side by Side Diff: pkg/servicec/lib/compiler.dart

Issue 2035023003: Remove service-compiler related code. (Closed) Base URL: git@github.com:dartino/sdk.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « pkg/immi_samples/lib/sliding_window.immi ('k') | pkg/servicec/lib/converter.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file
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.
4
5 library servicec.compiler;
6
7 import 'dart:async' show
8 Future;
9
10 import 'dart:io';
11
12 import 'package:compiler/src/tokens/token.dart' show
13 Token;
14
15 import 'error_handling_listener.dart' show
16 ErrorHandlingListener;
17
18 import 'errors.dart' show
19 CompilationError,
20 ErrorReporter,
21 UndefinedServiceError,
22 InternalCompilerError;
23
24 import 'listener.dart' show
25 DebugListener,
26 Listener;
27
28 import 'parser.dart' show
29 Parser;
30
31 import 'scanner.dart' show
32 Scanner;
33
34 import 'targets.dart' show
35 Target;
36
37 import 'validator.dart' show
38 validate;
39
40 import 'converter.dart' show
41 convert;
42
43 import 'package:old_servicec/compiler.dart' as old_servicec;
44 import 'package:old_servicec/src/parser.dart' show
45 Unit;
46
47 // Temporary output type
48 Future<Iterable<CompilationError>> compile(
49 String path,
50 String resourcesDirectory,
51 String outputDirectory,
52 {Target target: Target.ALL}) async {
53 String input = new File(path).readAsStringSync();
54 return compileInput(input,
55 path,
56 resourcesDirectory,
57 outputDirectory,
58 target: target);
59 }
60
61 // Temporary output type
62 Future<Iterable<CompilationError>> compileInput(
63 String input,
64 String path,
65 String resourcesDirectory,
66 String outputDirectory,
67 {Target target: Target.ALL}) async {
68 if (input.isEmpty) {
69 return [new UndefinedServiceError()];
70 }
71
72 Scanner scanner = new Scanner(input);
73 Token tokens = scanner.tokenize();
74
75 ErrorHandlingListener listener = new ErrorHandlingListener();
76 Parser parser = new Parser(listener);
77 parser.parseUnit(tokens);
78
79 Iterable<CompilationError> errors = validate(listener.parsedUnitNode);
80
81 if (errors.isEmpty) {
82 Unit unit = convert(listener.parsedUnitNode);
83 try {
84 old_servicec.compile(path, unit, resourcesDirectory, outputDirectory);
85 } catch (e, stackTrace) {
86 String message = "Original error:\n$e\n$stackTrace";
87 throw new InternalCompilerError(message);
88 }
89 }
90
91 return errors;
92 }
93
94 Future<bool> compileAndReportErrors(
95 String path,
96 String relativePath,
97 String resourcesDirectory,
98 String outputDirectory,
99 {Target target: Target.ALL}) async {
100 String input = new File(path).readAsStringSync();
101 Iterable<CompilationError> errors = await compileInput(
102 input, path, resourcesDirectory, outputDirectory, target: target);
103 if (errors.isNotEmpty) {
104 new ErrorReporter(path, relativePath).report(errors);
105 return false;
106 }
107 return true;
108 }
OLDNEW
« no previous file with comments | « pkg/immi_samples/lib/sliding_window.immi ('k') | pkg/servicec/lib/converter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698