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

Side by Side Diff: frog/gen.dart

Issue 8334035: Reduces code generated by dynamic calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 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 | Annotate | Revision Log
« frog/frogsh ('K') | « frog/frogsh ('k') | frog/member.dart » ('j') | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 /** 5 /**
6 * Top level generator object for writing code and keeping track of 6 * Top level generator object for writing code and keeping track of
7 * dependencies. 7 * dependencies.
8 * 8 *
9 * Should have two compilation models, but only one implemented so far. 9 * Should have two compilation models, but only one implemented so far.
10 * 10 *
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 if (type.isGeneric) { 104 if (type.isGeneric) {
105 for (var ct in _orderValues(type._concreteTypes)) { 105 for (var ct in _orderValues(type._concreteTypes)) {
106 writeType(ct); 106 writeType(ct);
107 } 107 }
108 } 108 }
109 } 109 }
110 } 110 }
111 } 111 }
112 112
113 genMethod(Member meth, [MethodGenerator enclosingMethod = null]) { 113 genMethod(Member meth, [MethodGenerator enclosingMethod=null]) {
jimhug 2011/11/07 21:14:21 Nit: I like the spaces int the original enclosingM
114 if (!meth.isGenerated && meth.declaringType.isClass && 114 if (!meth.isGenerated && meth.declaringType.isClass
115 meth.definition != null && !meth.isAbstract) { 115 && meth.definition != null && !meth.isAbstract) {
116 new MethodGenerator(meth, enclosingMethod).run(); 116 new MethodGenerator(meth, enclosingMethod).run();
117 } 117 }
118 } 118 }
119 119
120 _maybeIsTest(Type onType, Type checkType) { 120 _maybeIsTest(Type onType, Type checkType) {
121 if (!checkType.isTested) return; 121 if (!checkType.isTested) return;
122 122
123 writer.writeln('${onType.jsname}.prototype.is\$${checkType.jsname} =' 123 writer.writeln('${onType.jsname}.prototype.is\$${checkType.jsname} ='
124 + ' function(){return this;};'); 124 + ' function(){return this;};');
125 } 125 }
(...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 world.error('const list can only contain const values', item.span); 1841 world.error('const list can only contain const values', item.span);
1842 argsCode.add(arg.code); 1842 argsCode.add(arg.code);
1843 } else { 1843 } else {
1844 argsCode.add(arg.canonicalCode); 1844 argsCode.add(arg.canonicalCode);
1845 } 1845 }
1846 } else { 1846 } else {
1847 argsCode.add(arg.code); 1847 argsCode.add(arg.code);
1848 } 1848 }
1849 } 1849 }
1850 1850
1851 world.coreimpl.types['ListFactory'].markUsed();
jimhug 2011/11/07 21:14:21 This is getting annoying - I'm a little afraid of
1852
1851 final code = '[${Strings.join(argsCode, ", ")}]'; 1853 final code = '[${Strings.join(argsCode, ", ")}]';
1852 var value = new Value(world.listType, code); 1854 var value = new Value(world.listType, code);
1853 if (node.isConst) { 1855 if (node.isConst) {
1854 final immutableList = world.coreimpl.types['ImmutableList']; 1856 final immutableList = world.coreimpl.types['ImmutableList'];
1855 final immutableListCtor = immutableList.getConstructor('from'); 1857 final immutableListCtor = immutableList.getConstructor('from');
1856 final result = immutableListCtor.invoke( 1858 final result = immutableListCtor.invoke(
1857 this, node, null, new Arguments(null, [value])); 1859 this, node, null, new Arguments(null, [value]));
1858 value = world.gen.globalForConst( 1860 value = world.gen.globalForConst(
1859 new ConstListValue(immutableList, argValues, 'const $code', 1861 new ConstListValue(immutableList, argValues, 'const $code',
1860 result.code, node.span), 1862 result.code, node.span),
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
2150 result.add(new Value(world.varType, '\$$i', false, /*needsTemp:*/false)); 2152 result.add(new Value(world.varType, '\$$i', false, /*needsTemp:*/false));
2151 } 2153 }
2152 for (int i = bareCount; i < length; i++) { 2154 for (int i = bareCount; i < length; i++) {
2153 var name = getName(i); 2155 var name = getName(i);
2154 if (name == null) name = '\$$i'; 2156 if (name == null) name = '\$$i';
2155 result.add(new Value(world.varType, name, false, /*needsTemp:*/false)); 2157 result.add(new Value(world.varType, name, false, /*needsTemp:*/false));
2156 } 2158 }
2157 return new Arguments(nodes, result); 2159 return new Arguments(nodes, result);
2158 } 2160 }
2159 } 2161 }
OLDNEW
« frog/frogsh ('K') | « frog/frogsh ('k') | frog/member.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698