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

Unified Diff: frog/leg/elements/elements.dart

Issue 9618053: Introduce the TYPEDEF element, and use it in order to catch passing closures to the DOM. I make the… (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | frog/leg/lib/js_helper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/elements/elements.dart
===================================================================
--- frog/leg/elements/elements.dart (revision 5070)
+++ frog/leg/elements/elements.dart (working copy)
@@ -33,6 +33,7 @@
static final ElementKind ABSTRACT_FIELD = const ElementKind('abstract_field');
static final ElementKind LIBRARY = const ElementKind('library');
static final ElementKind PREFIX = const ElementKind('prefix');
+ static final ElementKind TYPEDEF = const ElementKind('typedef');
static final ElementKind STATEMENT = const ElementKind('statement');
static final ElementKind LABEL = const ElementKind('label');
@@ -64,9 +65,13 @@
return kind === ElementKind.COMPILATION_UNIT ||
kind === ElementKind.LIBRARY;
}
+ bool isClass() => kind == ElementKind.CLASS;
bool isVariable() => kind === ElementKind.VARIABLE;
bool isParameter() => kind === ElementKind.PARAMETER;
bool isStatement() => kind === ElementKind.STATEMENT;
+ bool isClassOrInterfaceOrAlias() {
kasperl 2012/03/07 10:25:59 isClassOrInterfaceOrTypedef? Maybe we should have
ngeoffray 2012/03/07 10:43:48 Peter prefered Alias, that was fine by me, but now
+ return kind == ElementKind.CLASS || kind == ElementKind.TYPEDEF;
+ }
bool isAssignable() {
if (modifiers != null && modifiers.isFinal()) return false;
@@ -198,6 +203,11 @@
}
}
+class TypedefElement extends Element {
+ TypedefElement(SourceString name, Element enclosing)
+ : super(name, ElementKind.TYPEDEF, enclosing);
+}
+
class VariableElement extends Element {
final VariableListElement variables;
Expression cachedNode; // The send or the identifier in the variables list.
@@ -324,11 +334,20 @@
compiler.cancel('library prefixes not handled',
node: typeAnnotation.typeName);
}
- final SourceString name = identifier.source;
+ SourceString name = identifier.source;
Element element = library.find(name);
- if (element !== null && element.kind === ElementKind.CLASS) {
- // TODO(karlklose): substitute type parameters.
- return element.computeType(compiler);
+ if (element !== null) {
+ if (element.kind === ElementKind.TYPEDEF) {
kasperl 2012/03/07 10:25:59 isTypedef()
ngeoffray 2012/03/07 10:43:48 Done.
+ // TODO(ngeoffray): This is a hack to help us get support for the
+ // DOM library.
+ return new FunctionType(compiler.types.dynamicType,
+ const EmptyLink<Type>(),
+ element);
+ }
+ if (element.kind === ElementKind.CLASS) {
kasperl 2012/03/07 10:25:59 isClass()
ngeoffray 2012/03/07 10:43:48 Done.
+ // TODO(karlklose): substitute type parameters.
+ return element.computeType(compiler);
+ }
}
Type type = compiler.types.lookup(name);
if (type === null) {
« no previous file with comments | « no previous file | frog/leg/lib/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698