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

Side by Side Diff: dart/lib/compiler/implementation/elements/elements.dart

Issue 10441071: Use the typedef arity to know how to invoke a closure given by the dom. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 6 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
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 #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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 super(prefix, ElementKind.PREFIX, enclosing); 347 super(prefix, ElementKind.PREFIX, enclosing);
348 348
349 lookupLocalMember(SourceString memberName) => imported[memberName]; 349 lookupLocalMember(SourceString memberName) => imported[memberName];
350 350
351 Type computeType(Compiler compiler) => compiler.types.dynamicType; 351 Type computeType(Compiler compiler) => compiler.types.dynamicType;
352 352
353 Token position() => firstPosition; 353 Token position() => firstPosition;
354 } 354 }
355 355
356 class TypedefElement extends Element { 356 class TypedefElement extends Element {
357 final Token token;
358 Type cachedType; 357 Type cachedType;
358 Typedef cachedNode;
359 359
360 TypedefElement(SourceString name, Element enclosing, this.token) 360 TypedefElement(SourceString name, Element enclosing)
361 : super(name, ElementKind.TYPEDEF, enclosing) { 361 : super(name, ElementKind.TYPEDEF, enclosing);
362 cachedType = new InterfaceType(this); 362
363 Type computeType(Compiler compiler) {
364 if (cachedType !== null) return cachedType;
365 cachedType = compiler.computeFunctionType(
366 this, compiler.resolveTypedef(this));
367 return cachedType;
363 } 368 }
364
365 position() => findMyName(token);
ahe 2012/05/29 15:43:49 Did you mean to delete this?
ngeoffray 2012/05/29 15:51:42 Yes, it is now in PartialTypedefElement.
366
367 Type computeType(Compiler compiler) => cachedType;
368 } 369 }
369 370
370 class VariableElement extends Element { 371 class VariableElement extends Element {
371 final VariableListElement variables; 372 final VariableListElement variables;
372 Expression cachedNode; // The send or the identifier in the variables list. 373 Expression cachedNode; // The send or the identifier in the variables list.
373 374
374 Modifiers get modifiers() => variables.modifiers; 375 Modifiers get modifiers() => variables.modifiers;
375 376
376 VariableElement(SourceString name, 377 VariableElement(SourceString name,
377 VariableListElement this.variables, 378 VariableListElement this.variables,
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 int optionalParameterCount(Compiler compiler) { 605 int optionalParameterCount(Compiler compiler) {
605 return computeSignature(compiler).optionalParameterCount; 606 return computeSignature(compiler).optionalParameterCount;
606 } 607 }
607 608
608 int parameterCount(Compiler compiler) { 609 int parameterCount(Compiler compiler) {
609 return computeSignature(compiler).parameterCount; 610 return computeSignature(compiler).parameterCount;
610 } 611 }
611 612
612 FunctionType computeType(Compiler compiler) { 613 FunctionType computeType(Compiler compiler) {
613 if (type != null) return type; 614 if (type != null) return type;
614 compiler.withCurrentElement(this, () { 615 type = compiler.computeFunctionType(this, computeSignature(compiler));
615 FunctionSignature signature = computeSignature(compiler);
616 LinkBuilder<Type> parameterTypes = new LinkBuilder<Type>();
617 for (Link<Element> link = signature.requiredParameters;
618 !link.isEmpty();
619 link = link.tail) {
620 parameterTypes.addLast(link.head.computeType(compiler));
621 // TODO(karlklose): optional parameters.
622 }
623 type = new FunctionType(signature.returnType,
624 parameterTypes.toLink(),
625 this);
626 });
627 return type; 616 return type;
628 } 617 }
629 618
630 Node parseNode(DiagnosticListener listener) => cachedNode; 619 Node parseNode(DiagnosticListener listener) => cachedNode;
631 620
632 Token position() => cachedNode.getBeginToken(); 621 Token position() => cachedNode.getBeginToken();
633 } 622 }
634 623
635 class ConstructorBodyElement extends FunctionElement { 624 class ConstructorBodyElement extends FunctionElement {
636 FunctionElement constructor; 625 FunctionElement constructor;
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 final Node node; 1035 final Node node;
1047 Type bound; 1036 Type bound;
1048 Type type; 1037 Type type;
1049 TypeVariableElement(name, Element enclosing, this.node, this.type, 1038 TypeVariableElement(name, Element enclosing, this.node, this.type,
1050 [this.bound]) 1039 [this.bound])
1051 : super(name, ElementKind.TYPE_VARIABLE, enclosing); 1040 : super(name, ElementKind.TYPE_VARIABLE, enclosing);
1052 Type computeType(compiler) => type; 1041 Type computeType(compiler) => type;
1053 Node parseNode(compiler) => node; 1042 Node parseNode(compiler) => node;
1054 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; 1043 toString() => "${enclosingElement.toString()}.${name.slowToString()}";
1055 } 1044 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698