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

Side by Side Diff: pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart

Issue 2516483002: fix #27336, ddc with recursive generic class type args (Closed)
Patch Set: Created 4 years, 1 month 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 | « pkg/dev_compiler/test/codegen/language/recursive_generic_test.dart ('k') | 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 /// 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 ///
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 if ($getGenericClass(T) == futureClass) { 90 if ($getGenericClass(T) == futureClass) {
91 let args = $getGenericArgs(T); 91 let args = $getGenericArgs(T);
92 if (args) return $builder(args[0]); 92 if (args) return $builder(args[0]);
93 } 93 }
94 return $builder(T); 94 return $builder(T);
95 } 95 }
96 return flatten; 96 return flatten;
97 })()'''); 97 })()''');
98 98
99 /// Memoize a generic type constructor function. 99 /// Memoize a generic type constructor function.
100 generic(typeConstructor) => JS( 100 generic(typeConstructor, [setBaseClass]) => JS(
101 '', 101 '',
102 '''(() => { 102 '''(() => {
103 let length = $typeConstructor.length; 103 let length = $typeConstructor.length;
104 if (length < 1) { 104 if (length < 1) {
105 $throwInternalError('must have at least one generic type argument'); 105 $throwInternalError('must have at least one generic type argument');
106 } 106 }
107 let resultMap = new Map(); 107 let resultMap = new Map();
108 function makeGenericType(...args) { 108 function makeGenericType(...args) {
109 if (args.length != length && args.length != 0) { 109 if (args.length != length && args.length != 0) {
110 $throwInternalError('requires ' + length + ' or 0 type arguments'); 110 $throwInternalError('requires ' + length + ' or 0 type arguments');
(...skipping 10 matching lines...) Expand all
121 let map = value; 121 let map = value;
122 value = map.get(arg); 122 value = map.get(arg);
123 if (value === void 0) { 123 if (value === void 0) {
124 if (i + 1 == length) { 124 if (i + 1 == length) {
125 value = $typeConstructor.apply(null, args); 125 value = $typeConstructor.apply(null, args);
126 // Save the type constructor and arguments for reflection. 126 // Save the type constructor and arguments for reflection.
127 if (value) { 127 if (value) {
128 value[$_typeArguments] = args; 128 value[$_typeArguments] = args;
129 value[$_originalDeclaration] = makeGenericType; 129 value[$_originalDeclaration] = makeGenericType;
130 } 130 }
131 map.set(arg, value);
132 if ($setBaseClass) $setBaseClass(value);
131 } else { 133 } else {
132 value = new Map(); 134 value = new Map();
135 map.set(arg, value);
133 } 136 }
134 map.set(arg, value);
135 } 137 }
136 } 138 }
137 return value; 139 return value;
138 } 140 }
139 makeGenericType[$_genericTypeCtor] = $typeConstructor; 141 makeGenericType[$_genericTypeCtor] = $typeConstructor;
140 return makeGenericType; 142 return makeGenericType;
141 })()'''); 143 })()''');
142 144
143 getGenericClass(type) => 145 getGenericClass(type) =>
144 JS('', '$safeGetOwnProperty($type, $_originalDeclaration)'); 146 JS('', '$safeGetOwnProperty($type, $_originalDeclaration)');
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 '''(() => { 548 '''(() => {
547 let values = []; 549 let values = [];
548 for (var i = 0; i < $names.length; i++) { 550 for (var i = 0; i < $names.length; i++) {
549 let value = $const_(new $enumClass(i)); 551 let value = $const_(new $enumClass(i));
550 values.push(value); 552 values.push(value);
551 Object.defineProperty($enumClass, $names[i], 553 Object.defineProperty($enumClass, $names[i],
552 { value: value, configurable: true }); 554 { value: value, configurable: true });
553 } 555 }
554 $enumClass.values = $constList(values, $enumClass); 556 $enumClass.values = $constList(values, $enumClass);
555 })()'''); 557 })()''');
OLDNEW
« no previous file with comments | « pkg/dev_compiler/test/codegen/language/recursive_generic_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698