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

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

Issue 9699033: Introduce FieldParameterElement. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments and create a separate map for the fields. 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
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 28 matching lines...) Expand all
39 class ElementKind { 39 class ElementKind {
40 final String id; 40 final String id;
41 final int category; 41 final int category;
42 42
43 const ElementKind(String this.id, this.category); 43 const ElementKind(String this.id, this.category);
44 44
45 static final ElementKind VARIABLE = 45 static final ElementKind VARIABLE =
46 const ElementKind('variable', ElementCategory.VARIABLE); 46 const ElementKind('variable', ElementCategory.VARIABLE);
47 static final ElementKind PARAMETER = 47 static final ElementKind PARAMETER =
48 const ElementKind('parameter', ElementCategory.VARIABLE); 48 const ElementKind('parameter', ElementCategory.VARIABLE);
49 // Parameters in constructors that directly initialize fields. For example:
50 // [:A(this.field):].
51 static final ElementKind FIELD_PARAMETER =
52 const ElementKind('field_parameter', ElementCategory.VARIABLE);
49 static final ElementKind FUNCTION = 53 static final ElementKind FUNCTION =
50 const ElementKind('function', ElementCategory.FUNCTION); 54 const ElementKind('function', ElementCategory.FUNCTION);
51 static final ElementKind CLASS = 55 static final ElementKind CLASS =
52 const ElementKind('class', ElementCategory.CLASS); 56 const ElementKind('class', ElementCategory.CLASS);
53 static final ElementKind FOREIGN = 57 static final ElementKind FOREIGN =
54 const ElementKind('foreign', ElementCategory.FUNCTION); 58 const ElementKind('foreign', ElementCategory.FUNCTION);
55 static final ElementKind GENERATIVE_CONSTRUCTOR = 59 static final ElementKind GENERATIVE_CONSTRUCTOR =
56 const ElementKind('generative_constructor', ElementCategory.FACTORY); 60 const ElementKind('generative_constructor', ElementCategory.FACTORY);
57 static final ElementKind FIELD = 61 static final ElementKind FIELD =
58 const ElementKind('field', ElementCategory.VARIABLE); 62 const ElementKind('field', ElementCategory.VARIABLE);
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 348
345 bool isInstanceMember() { 349 bool isInstanceMember() {
346 return isMember() && !modifiers.isStatic(); 350 return isMember() && !modifiers.isStatic();
347 } 351 }
348 352
349 // Note: cachedNode.getBeginToken() will not be correct in all 353 // Note: cachedNode.getBeginToken() will not be correct in all
350 // cases, for example, for function typed parameters. 354 // cases, for example, for function typed parameters.
351 Token position() => findMyName(variables.position()); 355 Token position() => findMyName(variables.position());
352 } 356 }
353 357
358 /**
359 * Parameters in constructors that directly initialize fields. For example:
360 * [:A(this.field):].
361 */
362 class FieldParameterElement extends VariableElement {
363 VariableElement fieldElement;
364
365 FieldParameterElement(SourceString name,
366 this.fieldElement,
367 VariableListElement variables,
368 Element enclosing,
369 Node node)
370 : super(name, variables, ElementKind.FIELD_PARAMETER, enclosing, node);
371 }
372
354 // This element represents a list of variable or field declaration. 373 // This element represents a list of variable or field declaration.
355 // It contains the node, and the type. A [VariableElement] always 374 // It contains the node, and the type. A [VariableElement] always
356 // references its [VariableListElement]. It forwards its 375 // references its [VariableListElement]. It forwards its
357 // [computeType] and [parseNode] methods to this element. 376 // [computeType] and [parseNode] methods to this element.
358 class VariableListElement extends Element { 377 class VariableListElement extends Element {
359 VariableDefinitions cachedNode; 378 VariableDefinitions cachedNode;
360 Type type; 379 Type type;
361 final Modifiers modifiers; 380 final Modifiers modifiers;
362 381
363 VariableListElement(ElementKind kind, 382 VariableListElement(ElementKind kind,
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 return result; 893 return result;
875 } 894 }
876 895
877 Node parseNode(DiagnosticListener l) => statement; 896 Node parseNode(DiagnosticListener l) => statement;
878 897
879 bool get isSwitch() => statement is SwitchStatement; 898 bool get isSwitch() => statement is SwitchStatement;
880 899
881 Token position() => statement.getBeginToken(); 900 Token position() => statement.getBeginToken();
882 String toString() => statement.toString(); 901 String toString() => statement.toString();
883 } 902 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698