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

Side by Side Diff: lib/runtime/dart_runtime.js

Issue 1099703003: Treat our type objects as core.Type (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Updated CL 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 var dart, _js_helper, _js_primitives; 5 var dart, _js_helper, _js_primitives;
6 (function (dart) { 6 (function (dart) {
7 'use strict'; 7 'use strict';
8 8
9 let defineProperty = Object.defineProperty; 9 let defineProperty = Object.defineProperty;
10 let getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; 10 let getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 function throwNoSuchMethod(obj, name, args, opt_func) { 54 function throwNoSuchMethod(obj, name, args, opt_func) {
55 if (obj === void 0) obj = opt_func; 55 if (obj === void 0) obj = opt_func;
56 throw new core.NoSuchMethodError(obj, name, args); 56 throw new core.NoSuchMethodError(obj, name, args);
57 } 57 }
58 58
59 function checkAndCall(f, obj, args, name) { 59 function checkAndCall(f, obj, args, name) {
60 if (!(f instanceof Function)) { 60 if (!(f instanceof Function)) {
61 // Grab the `call` method if it's not a function. 61 // Grab the `call` method if it's not a function.
62 if (f !== null) f = f.call; 62 if (f !== null) f = f.call;
63 if (!(f instanceof Function)) { 63 if (!(f instanceof Function)) {
64 throwNoSuchMethod(obj, method, args); 64 throwNoSuchMethod(obj, name, args);
65 } 65 }
66 } 66 }
67 // TODO(jmesserly): enable this when we can fix => and methods. 67 // TODO(jmesserly): enable this when we can fix => and methods.
68 /* 68 /*
69 let formals = formalParameterList(f); 69 let formals = formalParameterList(f);
70 // TODO(vsm): Type check args! We need to encode sufficient type info on f. 70 // TODO(vsm): Type check args! We need to encode sufficient type info on f.
71 if (formals.length < args.length) { 71 if (formals.length < args.length) {
72 throwNoSuchMethod(obj, name, args, f); 72 throwNoSuchMethod(obj, name, args, f);
73 } else if (formals.length > args.length) { 73 } else if (formals.length > args.length) {
74 for (let i = args.length; i < formals.length; ++i) { 74 for (let i = args.length; i < formals.length; ++i) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // See if we already know the answer 200 // See if we already know the answer
201 // TODO(jmesserly): general purpose memoize function? 201 // TODO(jmesserly): general purpose memoize function?
202 let map = subtypeMap.get(t1); 202 let map = subtypeMap.get(t1);
203 let result; 203 let result;
204 if (map) { 204 if (map) {
205 result = map.get(t2); 205 result = map.get(t2);
206 if (result !== void 0) return result; 206 if (result !== void 0) return result;
207 } else { 207 } else {
208 subtypeMap.set(t1, map = new Map()); 208 subtypeMap.set(t1, map = new Map());
209 } 209 }
210 map.set(t2, result = isSubtype_(t1, t2)); 210 if (t2 == core.Type) {
211 // Special case Types.
212 result = t1.prototype instanceof core.Type ||
213 t1 instanceof AbstractFunctionType ||
214 isSubtype_(t1, t2);
215 } else {
216 result = isSubtype_(t1, t2)
217 }
218 map.set(t2, result);
211 return result; 219 return result;
212 } 220 }
213 dart.isSubtype = isSubtype; 221 dart.isSubtype = isSubtype;
214 222
215 function _isBottom(type, dynamicIsBottom) { 223 function _isBottom(type, dynamicIsBottom) {
216 return (type == dart.dynamic && dynamicIsBottom) || type == dart.bottom; 224 return (type == dart.dynamic && dynamicIsBottom) || type == dart.bottom;
217 } 225 }
218 226
219 function _isTop(type, dynamicIsBottom) { 227 function _isTop(type, dynamicIsBottom) {
220 return type == core.Object || (type == dart.dynamic && !dynamicIsBottom); 228 return type == core.Object || (type == dart.dynamic && !dynamicIsBottom);
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 dart.JsSymbol = Symbol; 944 dart.JsSymbol = Symbol;
937 945
938 // TODO(jmesserly): hack to bootstrap the SDK 946 // TODO(jmesserly): hack to bootstrap the SDK
939 _js_helper = _js_helper || {}; 947 _js_helper = _js_helper || {};
940 _js_helper.checkNum = notNull; 948 _js_helper.checkNum = notNull;
941 949
942 _js_primitives = _js_primitives || {}; 950 _js_primitives = _js_primitives || {};
943 _js_primitives.printString = (s) => console.log(s); 951 _js_primitives.printString = (s) => console.log(s);
944 952
945 })(dart || (dart = {})); 953 })(dart || (dart = {}));
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698