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

Unified Diff: lib/runtime/dart_runtime.js

Issue 1133593004: fixes #131, use before define from variables to classes (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 7 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/runtime/dart/core.js ('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/runtime/dart_runtime.js
diff --git a/lib/runtime/dart_runtime.js b/lib/runtime/dart_runtime.js
index 7cdacd33726347793c24e5b364d385d1b57942f4..34ec47aa50709b87b4646810b8dbcff32cbaa8ff 100644
--- a/lib/runtime/dart_runtime.js
+++ b/lib/runtime/dart_runtime.js
@@ -210,7 +210,7 @@ var dart, _js_helper, _js_primitives;
if (t2 == core.Type) {
// Special case Types.
result = t1.prototype instanceof core.Type ||
- t1 instanceof AbstractFunctionType ||
+ t1 instanceof FunctionType ||
isSubtype_(t1, t2);
} else {
result = isSubtype_(t1, t2)
@@ -339,7 +339,7 @@ var dart, _js_helper, _js_primitives;
function isGroundType(type) {
// TODO(vsm): Cache this if we start using it at runtime.
- if (type instanceof AbstractFunctionType) {
+ if (type instanceof FunctionType) {
if (!_isTop(type.returnType, false)) return false;
for (let i = 0; i < type.args.length; ++i) {
if (!_isBottom(type.args[i], true)) return false;
@@ -390,9 +390,14 @@ var dart, _js_helper, _js_primitives;
return name;
}
- class AbstractFunctionType {
- constructor() {
- this._stringValue = null;
+ // TODO(jmesserly): extends Type?
+ class FunctionType {
+ constructor(returnType, args, optionals, named, opt_typedefName) {
+ this.returnType = returnType;
+ this.args = args;
+ this.optionals = optionals;
+ this.named = named;
+ this._stringValue = opt_typedefName;
}
get name() {
@@ -434,16 +439,6 @@ var dart, _js_helper, _js_primitives;
}
}
- class FunctionType extends AbstractFunctionType {
- constructor(returnType, args, optionals, named) {
- super();
- this.returnType = returnType;
- this.args = args;
- this.optionals = optionals;
- this.named = named;
- }
- }
-
function functionType(returnType, args, extra) {
// TODO(vsm): Cache / memomize?
var optionals;
@@ -462,49 +457,14 @@ var dart, _js_helper, _js_primitives;
}
dart.functionType = functionType;
- class Typedef extends AbstractFunctionType {
- constructor(name, closure) {
- super();
- this._name = name;
- this._closure = closure;
- this._functionType = null;
- }
-
- get name() {
- return this._name;
- }
-
- get functionType() {
- if (!this._functionType) {
- this._functionType = this._closure();
- }
- return this._functionType;
- }
-
- get returnType() {
- return this.functionType.returnType;
- }
-
- get args() {
- return this.functionType.args;
- }
-
- get optionals() {
- return this.functionType.optionals;
- }
-
- get named() {
- return this.functionType.named;
- }
- }
-
- function typedef(name, closure) {
- return new Typedef(name, closure);
+ function typedef(name, functionType) {
+ let f = functionType;
+ return new FunctionType(f.returnType, f.args, f.optionals, f.named, name);
}
dart.typedef = typedef;
function isFunctionType(type) {
- return isClassSubType(type, core.Function) || type instanceof AbstractFunctionType;
+ return isClassSubType(type, core.Function) || type instanceof FunctionType;
}
function getFunctionType(obj) {
« no previous file with comments | « lib/runtime/dart/core.js ('k') | lib/src/codegen/js_codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698