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

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

Issue 10832136: Skeleton typedef type implementation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Backend updated Created 8 years, 4 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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 Type computeType(Compiler compiler) => compiler.types.dynamicType; 468 Type computeType(Compiler compiler) => compiler.types.dynamicType;
469 469
470 Token position() => firstPosition; 470 Token position() => firstPosition;
471 471
472 PrefixElement cloneTo(Element enclosing, DiagnosticListener listener) { 472 PrefixElement cloneTo(Element enclosing, DiagnosticListener listener) {
473 return new PrefixElement(name, enclosing, firstPosition); 473 return new PrefixElement(name, enclosing, firstPosition);
474 } 474 }
475 } 475 }
476 476
477 class TypedefElement extends Element implements TypeDeclarationElement { 477 class TypedefElement extends Element implements TypeDeclarationElement {
478 Type cachedType;
479 Typedef cachedNode; 478 Typedef cachedNode;
479 TypedefType cachedType;
480 Type alias;
481
482 bool isResolved = false;
ahe 2012/08/16 13:22:58 Can you use states instead as I do in ClassElement
Johnni Winther 2012/08/17 11:15:19 I will do that in a later CL.
483 bool isBeingResolved = false;
480 484
481 TypedefElement(SourceString name, Element enclosing) 485 TypedefElement(SourceString name, Element enclosing)
482 : super(name, ElementKind.TYPEDEF, enclosing); 486 : super(name, ElementKind.TYPEDEF, enclosing);
483 487
484 Type computeType(Compiler compiler) { 488 /**
489 * Function signature for a typedef of a function type. The signature is
490 * kept to provide full information about parameter names through the mirror
491 * system.
492 *
493 * The [functionSignature] is not available until the typedef element has been
494 * resolved.
ahe 2012/08/16 13:22:58 How do you resolve a typedef element?
Johnni Winther 2012/08/17 11:15:19 Currently `compiler.resolveTypedef(this)`. I will
ahe 2012/08/21 14:27:24 I hoped you would include this explanation in the
495 */
496 FunctionSignature functionSignature;
497
498 TypedefType computeType(Compiler compiler) {
485 if (cachedType !== null) return cachedType; 499 if (cachedType !== null) return cachedType;
486 cachedType = new FunctionType(null, null, this); 500 Typedef node = parseNode(compiler);
487 cachedType.initializeFrom( 501 Link<Type> parameters =
488 compiler.computeFunctionType(this, compiler.resolveTypedef(this))); 502 TypeDeclarationElement.createTypeVariables(this, node.typeParameters);
503 cachedType = new TypedefType(this, parameters);
504 compiler.resolveTypedef(this);
489 return cachedType; 505 return cachedType;
490 } 506 }
491 507
492 Link<Type> get typeVariables() => const EmptyLink<Type>(); 508 Link<Type> get typeVariables() => cachedType.typeArguments;
493 509
494 Scope buildScope() => 510 Scope buildScope() =>
495 new TypeDeclarationScope(enclosingElement.buildScope(), this); 511 new TypeDeclarationScope(enclosingElement.buildScope(), this);
496 512
497 TypedefElement cloneTo(Element enclosing, DiagnosticListener listener) { 513 TypedefElement cloneTo(Element enclosing, DiagnosticListener listener) {
498 TypedefElement result = new TypedefElement(name, enclosing); 514 TypedefElement result = new TypedefElement(name, enclosing);
499 return result; 515 return result;
500 } 516 }
501 } 517 }
502 518
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 } 651 }
636 assert(type != null); 652 assert(type != null);
637 return type; 653 return type;
638 } 654 }
639 655
640 Token position() => cachedNode.getBeginToken(); 656 Token position() => cachedNode.getBeginToken();
641 657
642 VariableListElement cloneTo(Element enclosing, DiagnosticListener listener) { 658 VariableListElement cloneTo(Element enclosing, DiagnosticListener listener) {
643 VariableListElement result; 659 VariableListElement result;
644 if (cachedNode !== null) { 660 if (cachedNode !== null) {
645 result = new VariableListElement(cachedNode, kind, enclosing); 661 result = new VariableListElement.node(cachedNode, kind, enclosing);
646 } else { 662 } else {
647 result = new VariableListElement(kind, modifiers, enclosing); 663 result = new VariableListElement(kind, modifiers, enclosing);
648 } 664 }
649 return result; 665 return result;
650 } 666 }
651 } 667 }
652 668
653 class ForeignElement extends Element { 669 class ForeignElement extends Element {
654 ForeignElement(SourceString name, ContainerElement enclosingElement) 670 ForeignElement(SourceString name, ContainerElement enclosingElement)
655 : super(name, ElementKind.FOREIGN, enclosingElement); 671 : super(name, ElementKind.FOREIGN, enclosingElement);
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 : super(name, ElementKind.TYPE_VARIABLE, enclosing); 1424 : super(name, ElementKind.TYPE_VARIABLE, enclosing);
1409 1425
1410 TypeVariableType computeType(compiler) => type; 1426 TypeVariableType computeType(compiler) => type;
1411 1427
1412 Node parseNode(compiler) => cachedNode; 1428 Node parseNode(compiler) => cachedNode;
1413 1429
1414 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; 1430 String toString() => "${enclosingElement.toString()}.${name.slowToString()}";
1415 1431
1416 TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) { 1432 TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) {
1417 TypeVariableElement result = 1433 TypeVariableElement result =
1418 new TypeVariableElement(name, enclosing, node, type, bound); 1434 new TypeVariableElement(name, enclosing, cachedNode, type, bound);
1419 return result; 1435 return result;
1420 } 1436 }
1421 } 1437 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698