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

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

Issue 10702204: Revert "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: 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 }
1528 } 1517 }
1529 1518
1530 class PartialFieldListElement extends VariableListElement { 1519 class PartialFieldListElement extends VariableListElement {
1531 final Token beginToken; 1520 final Token beginToken;
1532 final Token endToken; 1521 final Token endToken;
1533 1522
1534 PartialFieldListElement(Token this.beginToken, 1523 PartialFieldListElement(Token this.beginToken,
1535 Token this.endToken, 1524 Token this.endToken,
1536 Modifiers modifiers, 1525 Modifiers modifiers,
1537 Element enclosing) 1526 Element enclosing)
1538 : super(ElementKind.VARIABLE_LIST, modifiers, enclosing); 1527 : super(ElementKind.VARIABLE_LIST, modifiers, enclosing);
1539 1528
1540 VariableDefinitions parseNode(DiagnosticListener listener) { 1529 VariableDefinitions parseNode(DiagnosticListener listener) {
1541 if (cachedNode != null) return cachedNode; 1530 if (cachedNode != null) return cachedNode;
1542 cachedNode = parse(listener, 1531 cachedNode = parse(listener,
1543 getCompilationUnit(), 1532 getCompilationUnit(),
1544 (p) => p.parseVariablesDeclaration(beginToken)); 1533 (p) => p.parseVariablesDeclaration(beginToken));
1545 if (!cachedNode.modifiers.isVar() && 1534 if (!cachedNode.modifiers.isVar() &&
1546 !cachedNode.modifiers.isFinal() && 1535 !cachedNode.modifiers.isFinal() &&
1547 !cachedNode.modifiers.isConst() && 1536 !cachedNode.modifiers.isConst() &&
1548 cachedNode.type === null) { 1537 cachedNode.type === null) {
1549 listener.cancel('A field declaration must start with var, final, ' 1538 listener.cancel('A field declaration must start with var, final, '
1550 'const, or a type annotation.', 1539 'const, or a type annotation.',
1551 cachedNode); 1540 cachedNode);
1552 } 1541 }
1553 return cachedNode; 1542 return cachedNode;
1554 } 1543 }
1555 1544
1556 Token position() => beginToken; // findMyName doesn't work. I'm nameless. 1545 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 }
1565 } 1546 }
1566 1547
1567 class PartialTypedefElement extends TypedefElement { 1548 class PartialTypedefElement extends TypedefElement {
1568 final Token token; 1549 final Token token;
1569 1550
1570 PartialTypedefElement(SourceString name, Element enclosing, this.token) 1551 PartialTypedefElement(SourceString name, Element enclosing, this.token)
1571 : super(name, enclosing); 1552 : super(name, enclosing);
1572 1553
1573 Node parseNode(DiagnosticListener listener) { 1554 Node parseNode(DiagnosticListener listener) {
1574 if (cachedNode !== null) return cachedNode; 1555 if (cachedNode !== null) return cachedNode;
1575 cachedNode = parse(listener, 1556 cachedNode = parse(listener,
1576 getCompilationUnit(), 1557 getCompilationUnit(),
1577 (p) => p.parseTopLevelDeclaration(token)); 1558 (p) => p.parseTopLevelDeclaration(token));
1578 return cachedNode; 1559 return cachedNode;
1579 } 1560 }
1580 1561
1581 position() => findMyName(token); 1562 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 }
1590 } 1563 }
1591 1564
1592 Node parse(DiagnosticListener diagnosticListener, 1565 Node parse(DiagnosticListener diagnosticListener,
1593 CompilationUnitElement element, 1566 CompilationUnitElement element,
1594 doParse(Parser parser)) { 1567 doParse(Parser parser)) {
1595 NodeListener listener = new NodeListener(diagnosticListener, element); 1568 NodeListener listener = new NodeListener(diagnosticListener, element);
1596 doParse(new Parser(listener)); 1569 doParse(new Parser(listener));
1597 Node node = listener.popNode(); 1570 Node node = listener.popNode();
1598 assert(listener.nodes.isEmpty()); 1571 assert(listener.nodes.isEmpty());
1599 return node; 1572 return node;
1600 } 1573 }
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