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

Side by Side Diff: lib/compiler/implementation/scanner/listener.dart

Issue 10703188: Allow patch files to add top-level declarations to the patched library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix errors caught by editor. Created 8 years, 5 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 final bool VERBOSE = false; 5 final bool VERBOSE = false;
6 6
7 /** 7 /**
8 * A parser event listener that does nothing except throw exceptions 8 * A parser event listener that does nothing except throw exceptions
9 * on parser errors. 9 * on parser errors.
10 */ 10 */
(...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 } 1507 }
1508 } 1508 }
1509 cachedNode = parse(listener, getCompilationUnit(), parseFunction); 1509 cachedNode = parse(listener, getCompilationUnit(), parseFunction);
1510 return cachedNode; 1510 return cachedNode;
1511 } 1511 }
1512 1512
1513 Token position() { 1513 Token position() {
1514 if (patch !== null) return patch.position(); 1514 if (patch !== null) return patch.position();
1515 return findMyName(beginToken); 1515 return findMyName(beginToken);
1516 } 1516 }
1517
1518 PartialFunctionElement cloneTo(Element enclosing,
1519 DiagnosticListener listener) {
1520 if (patch !== null) {
1521 listener.cancel("Cloning a patched function.", element: this);
1522 }
1523 PartialFunctionElement result = new PartialFunctionElement(
1524 name, beginToken, getOrSet, endToken, kind, modifiers, enclosing);
1525 result.scriptOverride = getScript();
1526 return result;
1527 }
1517 } 1528 }
1518 1529
1519 class PartialFieldListElement extends VariableListElement { 1530 class PartialFieldListElement extends VariableListElement {
1520 final Token beginToken; 1531 final Token beginToken;
1521 final Token endToken; 1532 final Token endToken;
1522 1533
1523 PartialFieldListElement(Token this.beginToken, 1534 PartialFieldListElement(Token this.beginToken,
1524 Token this.endToken, 1535 Token this.endToken,
1525 Modifiers modifiers, 1536 Modifiers modifiers,
1526 Element enclosing) 1537 Element enclosing)
1527 : super(ElementKind.VARIABLE_LIST, modifiers, enclosing); 1538 : super(ElementKind.VARIABLE_LIST, modifiers, enclosing);
1528 1539
1529 VariableDefinitions parseNode(DiagnosticListener listener) { 1540 VariableDefinitions parseNode(DiagnosticListener listener) {
1530 if (cachedNode != null) return cachedNode; 1541 if (cachedNode != null) return cachedNode;
1531 cachedNode = parse(listener, 1542 cachedNode = parse(listener,
1532 getCompilationUnit(), 1543 getCompilationUnit(),
1533 (p) => p.parseVariablesDeclaration(beginToken)); 1544 (p) => p.parseVariablesDeclaration(beginToken));
1534 if (!cachedNode.modifiers.isVar() && 1545 if (!cachedNode.modifiers.isVar() &&
1535 !cachedNode.modifiers.isFinal() && 1546 !cachedNode.modifiers.isFinal() &&
1536 !cachedNode.modifiers.isConst() && 1547 !cachedNode.modifiers.isConst() &&
1537 cachedNode.type === null) { 1548 cachedNode.type === null) {
1538 listener.cancel('A field declaration must start with var, final, ' 1549 listener.cancel('A field declaration must start with var, final, '
1539 'const, or a type annotation.', 1550 'const, or a type annotation.',
1540 cachedNode); 1551 cachedNode);
1541 } 1552 }
1542 return cachedNode; 1553 return cachedNode;
1543 } 1554 }
1544 1555
1545 Token position() => beginToken; // findMyName doesn't work. I'm nameless. 1556 Token position() => beginToken; // findMyName doesn't work. I'm nameless.
1557
1558 PartialFieldListElement cloneTo(Element enclosing,
1559 DiagnosticListener listener) {
1560 PartialFieldListElement result = new PartialFieldListElement(
1561 beginToken, endToken, modifiers, enclosing);
1562 result.scriptOverride = getScript();
1563 return result;
1564 }
1546 } 1565 }
1547 1566
1548 class PartialTypedefElement extends TypedefElement { 1567 class PartialTypedefElement extends TypedefElement {
1549 final Token token; 1568 final Token token;
1550 1569
1551 PartialTypedefElement(SourceString name, Element enclosing, this.token) 1570 PartialTypedefElement(SourceString name, Element enclosing, this.token)
1552 : super(name, enclosing); 1571 : super(name, enclosing);
1553 1572
1554 Node parseNode(DiagnosticListener listener) { 1573 Node parseNode(DiagnosticListener listener) {
1555 if (cachedNode !== null) return cachedNode; 1574 if (cachedNode !== null) return cachedNode;
1556 cachedNode = parse(listener, 1575 cachedNode = parse(listener,
1557 getCompilationUnit(), 1576 getCompilationUnit(),
1558 (p) => p.parseTopLevelDeclaration(token)); 1577 (p) => p.parseTopLevelDeclaration(token));
1559 return cachedNode; 1578 return cachedNode;
1560 } 1579 }
1561 1580
1562 position() => findMyName(token); 1581 position() => findMyName(token);
1582
1583 PartialTypedefElement cloneTo(Element enclosing,
1584 DiagnosticListener listener) {
1585 PartialTypedefElement result =
1586 new PartialTypedefElement(name, enclosing, token);
1587 result.scriptOverride = getScript();
1588 return result;
1589 }
1563 } 1590 }
1564 1591
1565 Node parse(DiagnosticListener diagnosticListener, 1592 Node parse(DiagnosticListener diagnosticListener,
1566 CompilationUnitElement element, 1593 CompilationUnitElement element,
1567 doParse(Parser parser)) { 1594 doParse(Parser parser)) {
1568 NodeListener listener = new NodeListener(diagnosticListener, element); 1595 NodeListener listener = new NodeListener(diagnosticListener, element);
1569 doParse(new Parser(listener)); 1596 doParse(new Parser(listener));
1570 Node node = listener.popNode(); 1597 Node node = listener.popNode();
1571 assert(listener.nodes.isEmpty()); 1598 assert(listener.nodes.isEmpty());
1572 return node; 1599 return node;
1573 } 1600 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/scanner/class_element_parser.dart ('k') | lib/compiler/implementation/scanner/scanner_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698