Skip to content

Commit

Permalink
rename ddc -> dev_compiler, fixes #84
Browse files Browse the repository at this point in the history
R=sigmund@google.com

Review URL: https://codereview.chromium.org/967933005
  • Loading branch information
John Messerly committed Mar 4, 2015
1 parent 579a098 commit 6e82406
Show file tree
Hide file tree
Showing 91 changed files with 672 additions and 667 deletions.
2 changes: 1 addition & 1 deletion pkg/dev_compiler/bin/devc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// BSD-style license that can be found in the LICENSE file.

/// Command line tool to run the checker on a Dart program.
library ddc.bin.checker;
library dev_compiler.bin.checker;

import 'dart:io';

Expand Down
2 changes: 1 addition & 1 deletion pkg/dev_compiler/bin/edit_files.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/// running devc.dart passing the arguments
/// --dump-info --dump-info-file info.json
library ddc.bin.edit_files;
library dev_compiler.bin.edit_files;

import 'dart:io';
import 'dart:convert';
Expand Down
2 changes: 1 addition & 1 deletion pkg/dev_compiler/lib/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

/// Configuration of DDC rule set.
library ddc.config;
library dev_compiler.config;

// Options shared by the compiler and runtime.
class TypeOptions {
Expand Down
4 changes: 2 additions & 2 deletions pkg/dev_compiler/lib/devc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

/// Command line tool to run the checker on a Dart program.
library ddc.devc;
library dev_compiler.devc;

import 'dart:async';
import 'dart:convert';
Expand Down Expand Up @@ -268,5 +268,5 @@ class CompilerServer {
}
}

final _log = new Logger('ddc');
final _log = new Logger('dev_compiler');
final _earlyErrorResult = new CheckerResults(const [], null, true);
33 changes: 18 additions & 15 deletions pkg/dev_compiler/lib/runtime/dart_logging_runtime.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library ddc.runtime.dart_logging_runtime;
library dev_compiler.runtime.dart_logging_runtime;

import 'dart:mirrors' as mirrors;

Expand All @@ -18,11 +18,14 @@ const bool _skipSuccess = true;
class CastRecord {
final Type runtimeType;
final Type staticType;
final bool ddcSuccess;
final bool dartSuccess;

CastRecord(
this.runtimeType, this.staticType, this.ddcSuccess, this.dartSuccess);
/// True if the dev_compiler would allow this cast. Otherwise false.
final bool soundCast;

/// True if Dart checked mode would allow this cast. Otherwise false.
final bool dartCast;

CastRecord(this.runtimeType, this.staticType, this.soundCast, this.dartCast);
}

// Register a handler to process CastRecords. The default (see below) just
Expand Down Expand Up @@ -65,32 +68,32 @@ dynamic cast(dynamic obj, Type fromType, Type staticType, String kind,

CastRecord record = _lookupInCache(runtimeType, staticType);
if (record == null) {
bool ddcSuccess = true;
bool dartSuccess = true;
bool soundCast = true;
bool dartCast = true;
// TODO(vsm): Use instanceOf once we settle on nullability.
try {
rt.cast(obj, staticType);
} catch (e) {
ddcSuccess = false;
soundCast = false;
}
if (obj == null) {
dartSuccess = true;
dartCast = true;
} else {
// TODO(vsm): We could avoid mirror code by requiring the caller to pass
// in obj is TypeLiteral as a parameter. We can't do that once we have a
// Type object instead.
final staticMirror = mirrors.reflectType(staticType);
final instanceMirror = mirrors.reflect(obj);
final classMirror = instanceMirror.type;
dartSuccess = classMirror.isSubtypeOf(staticMirror);
dartCast = classMirror.isSubtypeOf(staticMirror);
}
if (_skipSuccess && dartSuccess && ddcSuccess) {
if (_skipSuccess && dartCast && soundCast) {
_successCache
.putIfAbsent(staticType, () => new Set<Type>())
.add(runtimeType);
return obj;
}
record = new CastRecord(runtimeType, staticType, ddcSuccess, dartSuccess);
record = new CastRecord(runtimeType, staticType, soundCast, dartCast);
_addToCache(runtimeType, staticType, record);
}
castRecordHandler(key, record);
Expand Down Expand Up @@ -127,14 +130,14 @@ String summary({bool clear: true}) {
// assert(staticType == record.staticType);
}
runtimeTypes.add(record.runtimeType);
if (record.ddcSuccess) {
if (record.dartSuccess) {
if (record.soundCast) {
if (record.dartCast) {
success++;
} else {
error++;
}
} else {
if (record.dartSuccess) {
if (record.dartCast) {
mismatch++;
} else {
failure++;
Expand Down
2 changes: 1 addition & 1 deletion pkg/dev_compiler/lib/runtime/dart_runtime.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library ddc.runtime.dart_runtime;
library dev_compiler.runtime.dart_runtime;

import 'dart:mirrors';

Expand Down
2 changes: 1 addition & 1 deletion pkg/dev_compiler/lib/src/checker/checker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library ddc.src.checker.checker;
library dev_compiler.src.checker.checker;

import 'package:analyzer/analyzer.dart';
import 'package:analyzer/src/generated/ast.dart';
Expand Down
2 changes: 1 addition & 1 deletion pkg/dev_compiler/lib/src/checker/dart_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// Common logic needed to provide a Dart SDK to the analyzer's resolver. This
/// includes logic to determine where the sdk is located in the filesystem, and
/// definitions to provide mock sdks.
library ddc.src.checker.dart_sdk;
library dev_compiler.src.checker.dart_sdk;

import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/sdk.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library ddc.src.checker.multi_package_resolver;
library dev_compiler.src.checker.multi_package_resolver;

import 'dart:io';

Expand Down
4 changes: 2 additions & 2 deletions pkg/dev_compiler/lib/src/checker/resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/// Encapsulates how to invoke the analyzer resolver and overrides how it
/// computes types on expressions to use our restricted set of types.
library ddc.src.checker.resolver;
library dev_compiler.src.checker.resolver;

import 'package:analyzer/analyzer.dart';
import 'package:analyzer/src/generated/ast.dart';
Expand All @@ -26,7 +26,7 @@ import 'package:dev_compiler/src/utils.dart';
import 'dart_sdk.dart';
import 'multi_package_resolver.dart';

final _log = new logger.Logger('ddc.src.resolver');
final _log = new logger.Logger('dev_compiler.src.resolver');

/// Encapsulates a resolver from the analyzer package.
class TypeResolver {
Expand Down
2 changes: 1 addition & 1 deletion pkg/dev_compiler/lib/src/checker/rules.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library ddc.src.checker.rules;
library dev_compiler.src.checker.rules;

import 'package:analyzer/src/generated/ast.dart';
import 'package:analyzer/src/generated/element.dart';
Expand Down
4 changes: 2 additions & 2 deletions pkg/dev_compiler/lib/src/codegen/ast_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library ddc.src.codegen.ast_builder;
library dev_compiler.src.codegen.ast_builder;

import 'package:analyzer/src/generated/ast.dart';
import 'package:analyzer/src/generated/scanner.dart';
import 'package:analyzer/src/generated/utilities_dart.dart';
import 'package:logging/logging.dart' as logger;

final _log = new logger.Logger('ddc.ast_builder');
final _log = new logger.Logger('dev_compiler.ast_builder');

// Wrappers around constructors for the dart ast. The AstBuilder class
// provides a higher-level interface, abstracting both from the lexical
Expand Down
2 changes: 1 addition & 1 deletion pkg/dev_compiler/lib/src/codegen/code_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library ddc.src.codegen.code_generator;
library dev_compiler.src.codegen.code_generator;

import 'dart:io';

Expand Down
20 changes: 10 additions & 10 deletions pkg/dev_compiler/lib/src/codegen/dart_codegen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library ddc.src.codegen.dart_codegen;
library dev_compiler.src.codegen.dart_codegen;

import 'dart:io' show File;

Expand All @@ -24,29 +24,29 @@ import 'ast_builder.dart';
import 'code_generator.dart' as codegenerator;
import 'reify_coercions.dart' as reifier;

final _log = new logger.Logger('ddc.dartgenerator');
final _log = new logger.Logger('dev_compiler.dart_codegen');

class DdcRuntime {
Identifier _ddcRuntimeId = AstBuilder.identifierFromString("DDC\$RT");
class DevCompilerRuntime {
Identifier _runtimeId = AstBuilder.identifierFromString("DEVC\$RT");

Identifier _castId;
Identifier _typeToTypeId;
Identifier _wrapId;

DdcRuntime() {
DevCompilerRuntime() {
_castId = _prefixId(AstBuilder.identifierFromString("cast"));
_typeToTypeId = _prefixId(AstBuilder.identifierFromString("type"));
_wrapId = _prefixId(AstBuilder.identifierFromString("wrap"));
}

String get importString {
var name = _ddcRuntimeId;
var name = _runtimeId;
var uri = "package:dev_compiler/runtime/dart_logging_runtime.dart";
return "import '$uri' as $name;";
}

Identifier _prefixId(Identifier id) =>
AstBuilder.prefixedIdentifier(_ddcRuntimeId, id);
AstBuilder.prefixedIdentifier(_runtimeId, id);

Identifier runtimeId(RuntimeOperation oper) {
if (oper.operation == "cast") return _castId;
Expand Down Expand Up @@ -276,7 +276,7 @@ class UnitGenerator extends UnitGeneratorCommon with ConversionVisitor<Object> {
final java_core.PrintWriter _out;
final String outDir;
Set<LibraryElement> _extraImports;
final ddc = new DdcRuntime();
final _runtime = new DevCompilerRuntime();
LibraryElement _currentLibrary;
bool _qualifyNames = true;
Set<Identifier> _newIdentifiers;
Expand Down Expand Up @@ -337,7 +337,7 @@ class UnitGenerator extends UnitGeneratorCommon with ConversionVisitor<Object> {
if (ds['library'].length != 0) {
assert(ds['partof'].length == 0);
var es = buildExtraImportDirectives();
es.add(ddc.importString);
es.add(_runtime.importString);
es.forEach(outputln);
}
visitListWithSeparatorAndPrefix(prefix, ds['partof'], " ");
Expand All @@ -357,7 +357,7 @@ class UnitGenerator extends UnitGeneratorCommon with ConversionVisitor<Object> {

@override
Object visitRuntimeOperation(RuntimeOperation oper) {
var e = ddc.runtimeOperation(oper);
var e = _runtime.runtimeOperation(oper);
e.accept(this);
return null;
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/dev_compiler/lib/src/codegen/html_codegen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library ddc.src.codegen.html_codegen;
library dev_compiler.src.codegen.html_codegen;

import 'package:html5lib/dom.dart';
import 'package:html5lib/parser.dart' show parseFragment;
Expand All @@ -15,11 +15,11 @@ import 'package:dev_compiler/src/utils.dart' show colorOf;
import 'js_codegen.dart' show jsLibraryName, jsOutputPath;

/// Emits an entry point HTML file corresponding to [inputFile] that can load
/// the code generated by the ddc compiler.
/// the code generated by the dev compiler.
///
/// This internally transforms the given HTML [document]. When compiling to
/// JavaScript, we remove any Dart script tags, add new script tags to load the
/// ddc runtime and the compiled code, and to execute the main method of the
/// JavaScript, we remove any Dart script tags, add new script tags to load our
/// runtime and the compiled code, and to execute the main method of the
/// application. When compiling to Dart, we ensure that the document contains a
/// single Dart script tag, but otherwise emit the original document
/// unmodified.
Expand Down Expand Up @@ -85,4 +85,4 @@ Node get _miniMockSdk => parseFragment('''
var core = { int: { parse: Number }, print: e => console.log(e) };
var dom = { document: document };
</script>''');
final _log = new Logger('ddc.src.codegen.html_codegen');
final _log = new Logger('dev_compiler.src.codegen.html_codegen');
2 changes: 1 addition & 1 deletion pkg/dev_compiler/lib/src/codegen/js_codegen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library ddc.src.codegen.js_codegen;
library dev_compiler.src.codegen.js_codegen;

import 'dart:collection' show HashSet;
import 'dart:io' show Directory, File;
Expand Down
4 changes: 2 additions & 2 deletions pkg/dev_compiler/lib/src/codegen/reify_coercions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library ddc.src.codegen.reify_coercions;
library dev_compiler.src.codegen.reify_coercions;

import 'package:analyzer/analyzer.dart' as analyzer;
import 'package:analyzer/src/generated/ast.dart';
Expand All @@ -16,7 +16,7 @@ import 'package:dev_compiler/src/utils.dart' as utils;

import 'ast_builder.dart';

final _log = new logger.Logger('ddc.reify_coercions');
final _log = new logger.Logger('dev_compiler.reify_coercions');

// TODO(leafp) Factor this out or use an existing library
class Tuple2<T0, T1> {
Expand Down
4 changes: 2 additions & 2 deletions pkg/dev_compiler/lib/src/dependency_graph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

/// Tracks the shape of the import/export graph and dependencies between files.
library ddc.src.dependency_graph;
library dev_compiler.src.dependency_graph;

import 'dart:collection' show HashSet;

Expand Down Expand Up @@ -330,4 +330,4 @@ visitInPostOrder(SourceNode node, void action(SourceNode node),
}

bool _same(Set a, Set b) => a.length == b.length && a.containsAll(b);
final _log = new Logger('ddc.graph');
final _log = new Logger('dev_compiler.graph');
6 changes: 3 additions & 3 deletions pkg/dev_compiler/lib/src/info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/// Defines static information collected by the type checker and used later by
/// emitters to generate code.
library ddc.src.info;
library dev_compiler.src.info;

import 'dart:mirrors';

Expand Down Expand Up @@ -574,9 +574,9 @@ abstract class ConversionVisitor<R> implements AstVisitor<R> {
final List<Type> infoTypes = () {
var allTypes = new Set();
var baseTypes = new Set();
var lib = currentMirrorSystem().findLibrary(#ddc.src.info);
var infoMirror = reflectClass(StaticInfo);
for (var cls in lib.declarations.values.where((d) => d is ClassMirror)) {
var declarations = infoMirror.owner.declarations.values;
for (var cls in declarations.where((d) => d is ClassMirror)) {
if (cls.isSubtypeOf(infoMirror)) {
allTypes.add(cls);
baseTypes.add(cls.superclass);
Expand Down
Loading

0 comments on commit 6e82406

Please sign in to comment.