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

Unified Diff: pkg/fletchc/lib/src/fletch_compiler_implementation.dart

Issue 1659163007: Rename fletch -> dartino (Closed) Base URL: https://github.com/dartino/sdk.git@master
Patch Set: address comments Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/fletchc/lib/src/fletch_class_builder.dart ('k') | pkg/fletchc/lib/src/fletch_constants.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/fletchc/lib/src/fletch_compiler_implementation.dart
diff --git a/pkg/fletchc/lib/src/fletch_compiler_implementation.dart b/pkg/fletchc/lib/src/fletch_compiler_implementation.dart
deleted file mode 100644
index 625f10164195ef0ed8f491df51de66d89274a08d..0000000000000000000000000000000000000000
--- a/pkg/fletchc/lib/src/fletch_compiler_implementation.dart
+++ /dev/null
@@ -1,286 +0,0 @@
-// Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE.md file.
-
-library fletchc.fletch_compiler_implementation;
-
-import 'dart:async' show
- EventSink;
-
-import 'package:compiler/compiler_new.dart' as api;
-
-import 'package:compiler/src/apiimpl.dart' show
- CompilerImpl,
- makeDiagnosticOptions;
-
-import 'package:compiler/src/io/source_file.dart';
-
-import 'package:compiler/src/source_file_provider.dart' show
- SourceFileProvider;
-
-import 'package:compiler/src/elements/modelx.dart' show
- CompilationUnitElementX,
- LibraryElementX;
-
-import 'package:compiler/compiler_new.dart' show
- CompilerOutput;
-
-import 'package:compiler/src/diagnostics/messages.dart' show
- Message,
- MessageKind,
- MessageTemplate;
-
-import 'package:compiler/src/diagnostics/source_span.dart' show
- SourceSpan;
-
-import 'package:compiler/src/diagnostics/diagnostic_listener.dart' show
- DiagnosticMessage,
- DiagnosticReporter;
-
-import 'package:compiler/src/diagnostics/spannable.dart' show
- Spannable;
-
-import 'fletch_function_builder.dart';
-import 'debug_info.dart';
-import 'find_position_visitor.dart';
-import 'fletch_context.dart';
-
-import 'fletch_enqueuer.dart' show
- FletchEnqueueTask;
-
-import '../fletch_system.dart';
-import 'package:compiler/src/diagnostics/diagnostic_listener.dart';
-import 'package:compiler/src/elements/elements.dart';
-
-import '../incremental/fletchc_incremental.dart' show
- IncrementalCompiler;
-
-import 'fletch_diagnostic_reporter.dart' show
- FletchDiagnosticReporter;
-
-const EXTRA_DART2JS_OPTIONS = const <String>[
- // TODO(ahe): This doesn't completely disable type inference. Investigate.
- '--disable-type-inference',
- '--output-type=dart',
- // We want to continue generating code in the case of errors, to support
- // incremental fixes of erroneous code.
- '--generate-code-with-compile-time-errors',
-];
-
-const FLETCH_PATCHES = const <String, String>{
- "_internal": "internal/internal_patch.dart",
- "collection": "collection/collection_patch.dart",
- "convert": "convert/convert_patch.dart",
- "math": "math/math_patch.dart",
- "async": "async/async_patch.dart",
- "typed_data": "typed_data/typed_data_patch.dart",
-};
-
-const FLETCH_PLATFORM = 3;
-
-DiagnosticOptions makeFletchDiagnosticOptions(
- {bool suppressWarnings: false,
- bool fatalWarnings: false,
- bool suppressHints: false,
- bool terseDiagnostics: false,
- bool showPackageWarnings: true}) {
- return makeDiagnosticOptions(
- suppressWarnings: suppressWarnings,
- fatalWarnings: fatalWarnings,
- suppressHints: suppressHints,
- terseDiagnostics: terseDiagnostics,
- showPackageWarnings: true);
-}
-
-class FletchCompilerImplementation extends CompilerImpl {
- final Uri fletchVm;
-
- final Uri nativesJson;
-
- final IncrementalCompiler incrementalCompiler;
-
- Map<Uri, CompilationUnitElementX> compilationUnits;
- FletchContext internalContext;
-
- /// A reference to [../compiler.dart:FletchCompiler] used for testing.
- // TODO(ahe): Clean this up and remove this.
- var helper;
-
- @override
- FletchEnqueueTask get enqueuer => super.enqueuer;
-
- FletchCompilerImplementation(
- api.CompilerInput provider,
- api.CompilerOutput outputProvider,
- api.CompilerDiagnostics handler,
- Uri libraryRoot,
- Uri packageConfig,
- this.nativesJson,
- List<String> options,
- Map<String, dynamic> environment,
- this.fletchVm,
- this.incrementalCompiler)
- : super(
- provider, outputProvider, handler, libraryRoot, null,
- EXTRA_DART2JS_OPTIONS.toList()..addAll(options), environment,
- packageConfig, null, FletchBackend.createInstance,
- FletchDiagnosticReporter.createInstance,
- makeFletchDiagnosticOptions);
-
- FletchContext get context {
- if (internalContext == null) {
- internalContext = new FletchContext(this);
- }
- return internalContext;
- }
-
- String fletchPatchLibraryFor(String name) {
- // TODO(sigurdm): Try to remove this special casing.
- if (name == "core") {
- return platformConfigUri.path.endsWith("fletch_embedded.platform")
- ? "core/embedded_core_patch.dart"
- : "core/core_patch.dart";
- }
- return FLETCH_PATCHES[name];
- }
-
- @override
- Uri resolvePatchUri(String dartLibraryPath) {
- String path = fletchPatchLibraryFor(dartLibraryPath);
- if (path == null) return null;
- // Fletch patches are located relative to [libraryRoot].
- return libraryRoot.resolve(path);
- }
-
- CompilationUnitElementX compilationUnitForUri(Uri uri) {
- if (compilationUnits == null) {
- compilationUnits = <Uri, CompilationUnitElementX>{};
- libraryLoader.libraries.forEach((LibraryElementX library) {
- for (CompilationUnitElementX unit in library.compilationUnits) {
- compilationUnits[unit.script.resourceUri] = unit;
- }
- });
- }
- return compilationUnits[uri];
- }
-
- DebugInfo debugInfoForPosition(
- Uri file,
- int position,
- FletchSystem currentSystem) {
- Uri uri = Uri.base.resolveUri(file);
- CompilationUnitElementX unit = compilationUnitForUri(uri);
- if (unit == null) return null;
- FindPositionVisitor visitor = new FindPositionVisitor(position, unit);
- unit.accept(visitor, null);
- FletchFunctionBuilder builder =
- context.backend.systemBuilder.lookupFunctionBuilderByElement(
- visitor.element);
- if (builder == null) return null;
- // TODO(ajohnsen): We need a mapping from element to functionId, that can
- // be looked up in the current fletch system.
- FletchFunction function = builder.finalizeFunction(context, []);
- return context.backend.createDebugInfo(function, currentSystem);
- }
-
- int positionInFileFromPattern(Uri file, int line, String pattern) {
- Uri uri = Uri.base.resolveUri(file);
- SourceFile sourceFile = getSourceFile(provider, uri);
- if (sourceFile == null) return null;
- List<int> lineStarts = sourceFile.lineStarts;
- if (line >= lineStarts.length) return null;
- int begin = lineStarts[line];
- int end = line + 2 < lineStarts.length
- ? lineStarts[line + 1]
- : sourceFile.length;
- String lineText = sourceFile.slowSubstring(begin, end);
- int column = lineText.indexOf(pattern);
- if (column == -1) return null;
- return begin + column;
- }
-
- int positionInFile(Uri file, int line, int column) {
- Uri uri = Uri.base.resolveUri(file);
- SourceFile sourceFile = getSourceFile(provider, uri);
- if (sourceFile == null) return null;
- if (line >= sourceFile.lineStarts.length) return null;
- return sourceFile.lineStarts[line] + column;
- }
-
- Iterable<Uri> findSourceFiles(Pattern pattern) {
- SourceFileProvider provider = this.provider;
- return provider.sourceFiles.keys.where((Uri uri) {
- return pattern.matchAsPrefix(uri.pathSegments.last) != null;
- });
- }
-
- void reportVerboseInfo(
- Spannable node,
- String messageText,
- {bool forceVerbose: false}) {
- // TODO(johnniwinther): Use super.reportVerboseInfo once added.
- if (forceVerbose || verbose) {
- MessageTemplate template = MessageTemplate.TEMPLATES[MessageKind.GENERIC];
- SourceSpan span = reporter.spanFromSpannable(node);
- Message message = template.message({'text': messageText});
- reportDiagnostic(new DiagnosticMessage(span, node, message),
- [], api.Diagnostic.HINT);
- }
- }
-
- @override
- void compileLoadedLibraries() {
- // TODO(ahe): Ensure fletchSystemLibrary is not null
- // (also when mainApp is null).
- if (mainApp == null) {
- return;
- }
- super.compileLoadedLibraries();
- }
-}
-
-/// Output provider which collects output in [output].
-class OutputProvider implements CompilerOutput {
- final Map<String, String> output = new Map<String, String>();
-
- EventSink<String> createEventSink(String name, String extension) {
- return new StringEventSink((String data) {
- output['$name.$extension'] = data;
- });
- }
-
- String operator[](String key) => output[key];
-}
-
-/// Helper class to collect sources.
-class StringEventSink implements EventSink<String> {
- List<String> data = <String>[];
-
- final Function onClose;
-
- StringEventSink(this.onClose);
-
- void add(String event) {
- if (data == null) throw 'StringEventSink is closed.';
- data.add(event);
- }
-
- void addError(errorEvent, [StackTrace stackTrace]) {
- throw 'addError($errorEvent, $stackTrace)';
- }
-
- void close() {
- if (data != null) {
- onClose(data.join());
- data = null;
- }
- }
-}
-
-SourceFile getSourceFile(api.CompilerInput provider, Uri uri) {
- if (provider is SourceFileProvider) {
- return provider.getSourceFile(uri);
- } else {
- return null;
- }
-}
« no previous file with comments | « pkg/fletchc/lib/src/fletch_class_builder.dart ('k') | pkg/fletchc/lib/src/fletch_constants.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698