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

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

Issue 1298893003: Enable is and as checks on non-ground types (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Minor fixes Created 5 years, 4 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 | lib/runtime/_errors.js » ('j') | lib/runtime/_operations.js » ('J')
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 /* This library defines the operations that define and manipulate Dart 5 /* This library defines the operations that define and manipulate Dart
6 * classes. Included in this are: 6 * classes. Included in this are:
7 * - Generics 7 * - Generics
8 * - Class metadata 8 * - Class metadata
9 * - Extension methods 9 * - Extension methods
10 */ 10 */
11 11
12 // TODO(leafp): Consider splitting some of this out. 12 // TODO(leafp): Consider splitting some of this out.
13 dart_library.library('dart_runtime/_classes', null, /* Imports */[ 13 dart_library.library('dart_runtime/_classes', null, /* Imports */[
14 ], /* Lazy Imports */[ 14 ], /* Lazy Imports */[
15 'dart/core', 15 'dart/core',
16 'dart/_interceptors', 16 'dart/_interceptors',
17 'dart_runtime/_types', 17 'dart_runtime/_types',
18 'dart_runtime/_rtti', 18 'dart_runtime/_rtti',
19 ], function(exports, core, _interceptors, types, rtti) { 19 ], function(exports, core, _interceptors, types, rtti) {
20 'use strict'; 20 'use strict';
21 21
22 const assert = dart_utils.assert; 22 const assert = dart_utils.assert;
23 const copyProperties = dart_utils.copyProperties; 23 const copyProperties = dart_utils.copyProperties;
24 const copyTheseProperties = dart_utils.copyTheseProperties; 24 const copyTheseProperties = dart_utils.copyTheseProperties;
25 const defineMemoizedGetter = dart_utils.defineMemoizedGetter; 25 const defineMemoizedGetter = dart_utils.defineMemoizedGetter;
26 const safeGetOwnProperty = dart_utils.safeGetOwnProperty; 26 const safeGetOwnProperty = dart_utils.safeGetOwnProperty;
27 const throwError = dart_utils.throwError; 27 const throwInternalError = dart_utils.throwInternalError;
28 28
29 const defineProperty = Object.defineProperty; 29 const defineProperty = Object.defineProperty;
30 const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; 30 const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
31 const getOwnPropertySymbols = Object.getOwnPropertySymbols; 31 const getOwnPropertySymbols = Object.getOwnPropertySymbols;
32 32
33 const slice = [].slice; 33 const slice = [].slice;
34 34
35 /** The Symbol for storing type arguments on a specialized generic type. */ 35 /** The Symbol for storing type arguments on a specialized generic type. */
36 const _mixins = Symbol('mixins'); 36 const _mixins = Symbol('mixins');
37 const _implements = Symbol('implements'); 37 const _implements = Symbol('implements');
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 exports.getImplements = getImplements; 103 exports.getImplements = getImplements;
104 104
105 /** The Symbol for storing type arguments on a specialized generic type. */ 105 /** The Symbol for storing type arguments on a specialized generic type. */
106 let _typeArguments = Symbol('typeArguments'); 106 let _typeArguments = Symbol('typeArguments');
107 let _originalDeclaration = Symbol('originalDeclaration'); 107 let _originalDeclaration = Symbol('originalDeclaration');
108 108
109 /** Memoize a generic type constructor function. */ 109 /** Memoize a generic type constructor function. */
110 function generic(typeConstructor) { 110 function generic(typeConstructor) {
111 let length = typeConstructor.length; 111 let length = typeConstructor.length;
112 if (length < 1) { 112 if (length < 1) {
113 throwError('must have at least one generic type argument'); 113 throwInternalError('must have at least one generic type argument');
114 } 114 }
115 let resultMap = new Map(); 115 let resultMap = new Map();
116 function makeGenericType(/*...arguments*/) { 116 function makeGenericType(/*...arguments*/) {
117 if (arguments.length != length && arguments.length != 0) { 117 if (arguments.length != length && arguments.length != 0) {
118 throwError('requires ' + length + ' or 0 type arguments'); 118 throwInternalError('requires ' + length + ' or 0 type arguments');
119 } 119 }
120 let args = slice.call(arguments); 120 let args = slice.call(arguments);
121 while (args.length < length) args.push(types.dynamic); 121 while (args.length < length) args.push(types.dynamic);
122 122
123 let value = resultMap; 123 let value = resultMap;
124 for (let i = 0; i < length; i++) { 124 for (let i = 0; i < length; i++) {
125 let arg = args[i]; 125 let arg = args[i];
126 if (arg == null) { 126 if (arg == null) {
127 throwError('type arguments should not be null: ' 127 throwInternalError('type arguments should not be null: '
128 + typeConstructor); 128 + typeConstructor);
129 } 129 }
130 let map = value; 130 let map = value;
131 value = map.get(arg); 131 value = map.get(arg);
132 if (value === void 0) { 132 if (value === void 0) {
133 if (i + 1 == length) { 133 if (i + 1 == length) {
134 value = typeConstructor.apply(null, args); 134 value = typeConstructor.apply(null, args);
135 // Save the type constructor and arguments for reflection. 135 // Save the type constructor and arguments for reflection.
136 if (value) { 136 if (value) {
137 value[_typeArguments] = args; 137 value[_typeArguments] = args;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 } 399 }
400 exports.list = list; 400 exports.list = list;
401 401
402 function setBaseClass(derived, base) { 402 function setBaseClass(derived, base) {
403 // Link the extension to the type it's extending as a base class. 403 // Link the extension to the type it's extending as a base class.
404 derived.prototype.__proto__ = base.prototype; 404 derived.prototype.__proto__ = base.prototype;
405 } 405 }
406 exports.setBaseClass = setBaseClass; 406 exports.setBaseClass = setBaseClass;
407 407
408 }); 408 });
OLDNEW
« no previous file with comments | « no previous file | lib/runtime/_errors.js » ('j') | lib/runtime/_operations.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698