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

Unified Diff: lib/src/closure/closure_type.dart

Issue 1322673004: Reformat (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 3 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 | « lib/src/closure/closure_annotator.dart ('k') | lib/src/codegen/js_codegen.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/closure/closure_type.dart
diff --git a/lib/src/closure/closure_type.dart b/lib/src/closure/closure_type.dart
index 357c016b016ec40e5d6291f5fe395e2a3f77d27e..19109a0ce9e84815844ee59ecea6f1e522231a09 100644
--- a/lib/src/closure/closure_type.dart
+++ b/lib/src/closure/closure_type.dart
@@ -6,24 +6,24 @@ library dev_compiler.src.closure.closure_type;
/// Poor-man's representation of a Closure type.
/// See https://developers.google.com/closure/compiler/docs/js-for-compiler
-///
+///
/// The goal here is not to completely support Closure's type system, but to
-/// be able to generate just the types needed for DDC's JS output.
-///
+/// be able to generate just the types needed for DDC's JS output.
+///
/// TODO(ochafik): Consider convergence with TypeScript, which has no nullability-awareness
/// (see http://www.typescriptlang.org/Handbook).
class ClosureType {
static const ClosureType _ALL = const ClosureType._("*");
static const ClosureType _UNKNOWN = const ClosureType._("?");
-
+
final String _representation;
final bool isNullable;
-
+
const ClosureType._(this._representation, {this.isNullable: true});
bool get isAll => _representation == "*";
bool get isUnknown => _representation == "?";
-
+
@override toString() => _representation;
factory ClosureType.all() => _ALL;
@@ -34,7 +34,8 @@ class ClosureType {
fieldTypes.forEach((n, t) => entries.add('$n: $t'));
return new ClosureType._('{${entries.join(', ')}}');
}
- factory ClosureType.function([List<ClosureType> paramTypes, ClosureType returnType]) {
+ factory ClosureType.function(
+ [List<ClosureType> paramTypes, ClosureType returnType]) {
if (paramTypes == null && returnType == null) {
return new ClosureType.type("Function");
}
@@ -52,29 +53,36 @@ class ClosureType {
factory ClosureType.array([ClosureType componentType]) =>
new ClosureType._("Array<${componentType ?? _ALL}>");
- factory ClosureType.undefined() => new ClosureType._("undefined", isNullable: false);
- factory ClosureType.number() => new ClosureType._("number", isNullable: false);
- factory ClosureType.boolean() => new ClosureType._("boolean", isNullable: false);
+ factory ClosureType.undefined() =>
+ new ClosureType._("undefined", isNullable: false);
+ factory ClosureType.number() =>
+ new ClosureType._("number", isNullable: false);
+ factory ClosureType.boolean() =>
+ new ClosureType._("boolean", isNullable: false);
factory ClosureType.string() => new ClosureType._("string");
-
- ClosureType toOptional() =>
- new ClosureType._("$this=");
-
- ClosureType toNullable() =>
- isNullable ? this : new ClosureType._(
- _representation.startsWith('!') ? _representation.substring(1) : "?$this",
+
+ ClosureType toOptional() => new ClosureType._("$this=");
+
+ ClosureType toNullable() => isNullable
+ ? this
+ : new ClosureType._(
+ _representation.startsWith('!')
+ ? _representation.substring(1)
+ : "?$this",
isNullable: true);
-
- ClosureType toNonNullable() =>
- !isNullable ? this : new ClosureType._(
- _representation.startsWith('?') ? _representation.substring(1) : "!$this",
+
+ ClosureType toNonNullable() => !isNullable
+ ? this
+ : new ClosureType._(
+ _representation.startsWith('?')
+ ? _representation.substring(1)
+ : "!$this",
isNullable: false);
/// TODO(ochafik): See which optimizations make sense here (it could be that `(*|undefined)`
/// cannot be optimized to `*` when used to model optional record fields).
- ClosureType or(ClosureType other) =>
- new ClosureType._("($this|$other)", isNullable: isNullable || other.isNullable);
-
- ClosureType orUndefined() =>
- or(new ClosureType.undefined());
+ ClosureType or(ClosureType other) => new ClosureType._("($this|$other)",
+ isNullable: isNullable || other.isNullable);
+
+ ClosureType orUndefined() => or(new ClosureType.undefined());
}
« no previous file with comments | « lib/src/closure/closure_annotator.dart ('k') | lib/src/codegen/js_codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698