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

Side by Side Diff: pkg/servicec/lib/stack.dart

Issue 2035023003: Remove service-compiler related code. (Closed) Base URL: git@github.com:dartino/sdk.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « pkg/servicec/lib/scanner.dart ('k') | pkg/servicec/lib/targets.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file
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.
4
5 import 'node.dart' show
6 Node;
7
8 class NodeStack {
9 List<Node> data = <Node>[];
10
11 int get size => data.length;
12
13 // Stack interface.
14 void pushNode(Node node) {
15 data.add(node);
16 }
17
18 Node popNode() {
19 return data.removeLast();
20 }
21
22 /// Returns the top of the stack or [null] if the stack is empty.
23 Node topNode() {
24 return data.isNotEmpty ? data.last : null;
25 }
26 }
27
28 class Popper<T extends Node> {
29 NodeStack stack;
30 Popper(this.stack);
31
32 T popNodeIfMatching() {
33 return (stack.topNode() is T) ? stack.popNode() : null;
34 }
35
36 List<T> popNodesWhileMatching() {
37 List<T> result = <T>[];
38 while (stack.topNode() is T) {
39 result.add(stack.popNode());
40 }
41 return result;
42 }
43
44 List<T> popNodes(int count) {
45 List<T> result = new List<T>(count);
46 assert(count <= stack.data.length);
47 int oldLength = stack.data.length;
48 int newLength = oldLength - count;
49 for (int i = newLength; i < oldLength; ++i) {
50 result[i - newLength] = stack.data[i];
51 }
52 stack.data.length = newLength;
53 return result;
54 }
55 }
OLDNEW
« no previous file with comments | « pkg/servicec/lib/scanner.dart ('k') | pkg/servicec/lib/targets.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698