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

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

Issue 9301038: Support named arguments for statically resolved calls. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 10 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 | « no previous file | frog/leg/emitter.dart » ('j') | frog/leg/ssa/builder.dart » ('J')
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 #library('elements'); 5 #library('elements');
6 6
7 #import('../tree/tree.dart'); 7 #import('../tree/tree.dart');
8 #import('../scanner/scannerlib.dart'); 8 #import('../scanner/scannerlib.dart');
9 #import('../leg.dart'); // TODO(karlklose): we only need type. 9 #import('../leg.dart'); // TODO(karlklose): we only need type.
10 #import('../util/util.dart'); 10 #import('../util/util.dart');
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 final SourceString name = identifier.source; 226 final SourceString name = identifier.source;
227 Element element = compiler.universe.find(name); 227 Element element = compiler.universe.find(name);
228 if (element !== null && element.kind === ElementKind.CLASS) { 228 if (element !== null && element.kind === ElementKind.CLASS) {
229 // TODO(karlklose): substitute type parameters. 229 // TODO(karlklose): substitute type parameters.
230 return element.computeType(compiler); 230 return element.computeType(compiler);
231 } 231 }
232 return types.lookup(name); 232 return types.lookup(name);
233 } 233 }
234 234
235 class FunctionParameters { 235 class FunctionParameters {
236 Link<Element> parameters; 236 Link<Element> requiredParameters;
237 Link<Element> optionalParameters; 237 Link<Element> optionalParameters;
238 int parameterCount; 238 int requiredParameterCount;
239 int optionalParameterCount; 239 int optionalParameterCount;
240 FunctionParameters(this.parameters, 240 FunctionParameters(this.requiredParameters,
241 this.optionalParameters, 241 this.optionalParameters,
242 this.parameterCount, 242 this.requiredParameterCount,
243 this.optionalParameterCount); 243 this.optionalParameterCount);
244 244
245 void forEachParameter(void function(Element parameter)) { 245 void forEachParameter(void function(Element parameter)) {
246 for (Link<Element> link = parameters; 246 for (Link<Element> link = requiredParameters;
247 !link.isEmpty(); 247 !link.isEmpty();
248 link = link.tail) { 248 link = link.tail) {
249 function(link.head); 249 function(link.head);
250 } 250 }
251 for (Link<Element> link = optionalParameters; 251 for (Link<Element> link = optionalParameters;
252 !link.isEmpty(); 252 !link.isEmpty();
253 link = link.tail) { 253 link = link.tail) {
254 function(link.head); 254 function(link.head);
255 } 255 }
256 } 256 }
257
258 int get parameterCount() => requiredParameterCount + optionalParameterCount;
257 } 259 }
258 260
259 class FunctionElement extends Element { 261 class FunctionElement extends Element {
260 FunctionExpression cachedNode; 262 FunctionExpression cachedNode;
261 Type type; 263 Type type;
262 final Modifiers modifiers; 264 final Modifiers modifiers;
263 FunctionParameters functionParameters; 265 FunctionParameters functionParameters;
264 266
265 FunctionElement(SourceString name, 267 FunctionElement(SourceString name,
266 ElementKind kind, 268 ElementKind kind,
(...skipping 23 matching lines...) Expand all
290 && !modifiers.isFactory() 292 && !modifiers.isFactory()
291 && !modifiers.isStatic(); 293 && !modifiers.isStatic();
292 } 294 }
293 295
294 FunctionParameters computeParameters(Compiler compiler) { 296 FunctionParameters computeParameters(Compiler compiler) {
295 if (functionParameters !== null) return functionParameters; 297 if (functionParameters !== null) return functionParameters;
296 functionParameters = compiler.resolveSignature(this); 298 functionParameters = compiler.resolveSignature(this);
297 return functionParameters; 299 return functionParameters;
298 } 300 }
299 301
302 int requiredParameterCount(Compiler compiler) {
303 return computeParameters(compiler).requiredParameterCount;
304 }
305
306 int optionalParameterCount(Compiler compiler) {
307 return computeParameters(compiler).optionalParameterCount;
308 }
309
300 int parameterCount(Compiler compiler) { 310 int parameterCount(Compiler compiler) {
301 return computeParameters(compiler).parameterCount; 311 return computeParameters(compiler).parameterCount;
302 } 312 }
303 313
304 int optionalParameterCount(Compiler compiler) {
305 return computeParameters(compiler).optionalParameterCount;
306 }
307
308 FunctionType computeType(Compiler compiler) { 314 FunctionType computeType(Compiler compiler) {
309 if (type != null) return type; 315 if (type != null) return type;
310 FunctionParameters parameters = computeParameters(compiler); 316 FunctionParameters parameters = computeParameters(compiler);
311 Types types = compiler.types; 317 Types types = compiler.types;
312 FunctionExpression node = 318 FunctionExpression node =
313 compiler.parser.measure(() => parseNode(compiler)); 319 compiler.parser.measure(() => parseNode(compiler));
314 Type returnType = getType(node.returnType, compiler, types); 320 Type returnType = getType(node.returnType, compiler, types);
315 if (returnType === null) returnType = types.dynamicType; 321 if (returnType === null) returnType = types.dynamicType;
316 322
317 LinkBuilder<Type> parameterTypes = new LinkBuilder<Type>(); 323 LinkBuilder<Type> parameterTypes = new LinkBuilder<Type>();
318 for (Link<Element> link = parameters.parameters; 324 for (Link<Element> link = parameters.requiredParameters;
319 !link.isEmpty(); 325 !link.isEmpty();
320 link = link.tail) { 326 link = link.tail) {
321 parameterTypes.addLast(link.head.computeType(compiler)); 327 parameterTypes.addLast(link.head.computeType(compiler));
322 } 328 }
323 type = new FunctionType(returnType, parameterTypes.toLink(), this); 329 type = new FunctionType(returnType, parameterTypes.toLink(), this);
324 return type; 330 return type;
325 } 331 }
326 332
327 Node parseNode(DiagnosticListener listener) => cachedNode; 333 Node parseNode(DiagnosticListener listener) => cachedNode;
328 334
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 else if (str === '>=') str = 'ge'; 530 else if (str === '>=') str = 'ge';
525 else if (str === '>') str = 'gt'; 531 else if (str === '>') str = 'gt';
526 else if (str === '<=') str = 'le'; 532 else if (str === '<=') str = 'le';
527 else if (str === '<') str = 'lt'; 533 else if (str === '<') str = 'lt';
528 else if (str === '&' || str === '&=') str = 'and'; 534 else if (str === '&' || str === '&=') str = 'and';
529 else if (str === '^' || str === '^=') str = 'xor'; 535 else if (str === '^' || str === '^=') str = 'xor';
530 else if (str === '|' || str === '|=') str = 'or'; 536 else if (str === '|' || str === '|=') str = 'or';
531 return new SourceString('$receiver\$$str'); 537 return new SourceString('$receiver\$$str');
532 } 538 }
533 } 539 }
OLDNEW
« no previous file with comments | « no previous file | frog/leg/emitter.dart » ('j') | frog/leg/ssa/builder.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698