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

Side by Side Diff: frog/leg/universe.dart

Issue 9701072: Revert r5529. Breaks frog and web bots. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « frog/leg/resolver.dart ('k') | frog/leg/warnings.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 class Universe { 5 class Universe {
6 Map<Element, String> generatedCode; 6 Map<Element, String> generatedCode;
7 Map<Element, String> generatedBailoutCode; 7 Map<Element, String> generatedBailoutCode;
8 final Set<ClassElement> instantiatedClasses; 8 final Set<ClassElement> instantiatedClasses;
9 final Set<SourceString> instantiatedClassInstanceFields; 9 final Set<SourceString> instantiatedClassInstanceFields;
10 final Set<FunctionElement> staticFunctionsNeedingGetter; 10 final Set<FunctionElement> staticFunctionsNeedingGetter;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 } 114 }
115 115
116 /** 116 /**
117 * Returns [:true:] if the selector and the [element] match; [:false:] 117 * Returns [:true:] if the selector and the [element] match; [:false:]
118 * otherwise. 118 * otherwise.
119 */ 119 */
120 bool addSendArgumentsToList(Send send, 120 bool addSendArgumentsToList(Send send,
121 List list, 121 List list,
122 FunctionParameters parameters, 122 FunctionParameters parameters,
123 compileArgument(Node argument), 123 visitArgument(Node argument),
124 compileConstant(Element element)) { 124 visitConstant(Element element)) {
125 void addMatchingSendArgumentsToList(Link<Node> link) { 125 void addMatchingSendArgumentsToList(Link<Node> link) {
126 for (; !link.isEmpty(); link = link.tail) { 126 for (; !link.isEmpty(); link = link.tail) {
127 list.add(compileArgument(link.head)); 127 list.add(visitArgument(link.head));
128 } 128 }
129 } 129 }
130 130
131 if (!this.applies(parameters)) return false; 131 if (!this.applies(parameters)) return false;
132 if (this.positionalArgumentCount == parameters.parameterCount) { 132 if (this.positionalArgumentCount == parameters.parameterCount) {
133 addMatchingSendArgumentsToList(send.arguments); 133 addMatchingSendArgumentsToList(send.arguments);
134 return true; 134 return true;
135 } 135 }
136 136
137 // If there are named arguments, provide them in the order 137 // If there are named arguments, provide them in the order
138 // expected by the called function, which is the source order. 138 // expected by the called function, which is the source order.
139 139
140 // Visit positional arguments and add them to the list. 140 // Visit positional arguments and add them to the list.
141 Link<Node> arguments = send.arguments; 141 Link<Node> arguments = send.arguments;
142 int positionalArgumentCount = this.positionalArgumentCount; 142 int positionalArgumentCount = this.positionalArgumentCount;
143 for (int i = 0; 143 for (int i = 0;
144 i < positionalArgumentCount; 144 i < positionalArgumentCount;
145 arguments = arguments.tail, i++) { 145 arguments = arguments.tail, i++) {
146 list.add(compileArgument(arguments.head)); 146 list.add(visitArgument(arguments.head));
147 } 147 }
148 148
149 // Visit named arguments and add them into a temporary list. 149 // Visit named arguments and add them into a temporary list.
150 List namedArguments = []; 150 List namedArguments = [];
151 for (; !arguments.isEmpty(); arguments = arguments.tail) { 151 for (; !arguments.isEmpty(); arguments = arguments.tail) {
152 NamedArgument namedArgument = arguments.head; 152 namedArguments.add(visitArgument(arguments.head));
153 namedArguments.add(compileArgument(namedArgument.expression));
154 } 153 }
155 154
156 Link<Element> remainingNamedParameters = parameters.optionalParameters; 155 Link<Element> remainingNamedParameters = parameters.optionalParameters;
157 // Skip the optional parameters that have been given in the 156 // Skip the optional parameters that have been given in the
158 // positional arguments. 157 // positional arguments.
159 for (int i = parameters.requiredParameterCount; 158 for (int i = parameters.requiredParameterCount;
160 i < positionalArgumentCount; 159 i < positionalArgumentCount;
161 i++) { 160 i++) {
162 remainingNamedParameters = remainingNamedParameters.tail; 161 remainingNamedParameters = remainingNamedParameters.tail;
163 } 162 }
164 163
165 // Loop over the remaining named parameters, and try to find 164 // Loop over the remaining named parameters, and try to find
166 // their values: either in the temporary list or using the 165 // their values: either in the temporary list or using the
167 // default value. 166 // default value.
168 for (; 167 for (;
169 !remainingNamedParameters.isEmpty(); 168 !remainingNamedParameters.isEmpty();
170 remainingNamedParameters = remainingNamedParameters.tail) { 169 remainingNamedParameters = remainingNamedParameters.tail) {
171 Element parameter = remainingNamedParameters.head; 170 Element parameter = remainingNamedParameters.head;
172 int foundIndex = -1; 171 int foundIndex = -1;
173 for (int i = 0; i < this.namedArguments.length; i++) { 172 for (int i = 0; i < this.namedArguments.length; i++) {
174 SourceString name = this.namedArguments[i]; 173 SourceString name = this.namedArguments[i];
175 if (name == parameter.name) { 174 if (name == parameter.name) {
176 foundIndex = i; 175 foundIndex = i;
177 break; 176 break;
178 } 177 }
179 } 178 }
180 if (foundIndex != -1) { 179 if (foundIndex != -1) {
181 list.add(namedArguments[foundIndex]); 180 list.add(namedArguments[foundIndex]);
182 } else { 181 } else {
183 list.add(compileConstant(parameter)); 182 list.add(visitConstant(parameter));
184 } 183 }
185 } 184 }
186 return true; 185 return true;
187 } 186 }
188 187
189 static bool sameNames(List<SourceString> first, List<SourceString> second) { 188 static bool sameNames(List<SourceString> first, List<SourceString> second) {
190 for (int i = 0; i < first.length; i++) { 189 for (int i = 0; i < first.length; i++) {
191 if (first[i] != second[i]) return false; 190 if (first[i] != second[i]) return false;
192 } 191 }
193 return true; 192 return true;
(...skipping 29 matching lines...) Expand all
223 if (!orderedNamedArguments.isEmpty()) return orderedNamedArguments; 222 if (!orderedNamedArguments.isEmpty()) return orderedNamedArguments;
224 223
225 List<SourceString> list = new List<SourceString>.from(namedArguments); 224 List<SourceString> list = new List<SourceString>.from(namedArguments);
226 list.sort((SourceString first, SourceString second) { 225 list.sort((SourceString first, SourceString second) {
227 return first.slowToString().compareTo(second.slowToString()); 226 return first.slowToString().compareTo(second.slowToString());
228 }); 227 });
229 orderedNamedArguments = list; 228 orderedNamedArguments = list;
230 return orderedNamedArguments; 229 return orderedNamedArguments;
231 } 230 }
232 } 231 }
OLDNEW
« no previous file with comments | « frog/leg/resolver.dart ('k') | frog/leg/warnings.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698