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

Side by Side Diff: lib/syntax.dart

Issue 17553018: Initial stream support (Closed) Base URL: https://github.com/dart-lang/fancy-syntax.git@master
Patch Set: address review comments Created 7 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
« no previous file with comments | « lib/src/mirrors.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 fancy_syntax; 5 library fancy_syntax;
6 6
7 import 'dart:async';
7 import 'dart:html'; 8 import 'dart:html';
8 import 'dart:collection'; 9 import 'dart:collection';
9 import 'package:mdv_observe/mdv_observe.dart'; 10 import 'package:mdv_observe/mdv_observe.dart';
10 11
12 import 'async.dart';
11 import 'eval.dart'; 13 import 'eval.dart';
12 import 'expression.dart'; 14 import 'expression.dart';
13 import 'parser.dart'; 15 import 'parser.dart';
14 import 'visitor.dart'; 16 import 'visitor.dart';
15 17
16 class FancySyntax extends CustomBindingSyntax { 18 class FancySyntax extends CustomBindingSyntax {
17 19
18 final Map<String, Object> globals; 20 final Map<String, Object> globals;
19 21
20 FancySyntax({Map<String, Object> globals}) 22 FancySyntax({Map<String, Object> globals})
21 : globals = (globals == null) ? new Map<String, Object>() : globals; 23 : globals = (globals == null) ? new Map<String, Object>() : globals;
22 24
23 _Binding getBinding(model, String path, name, node) { 25 _Binding getBinding(model, String path, name, node) {
24 if (path != null) { 26 if (path != null) {
25 if (path.isEmpty) { 27 var expr = new Parser(path).parse();
26 // avoid creating an unneccesary scope for the top-level template 28 if (model is! Scope) {
27 return null;
28 } else if (model is! Scope) {
29 model = new Scope(model: model, variables: globals); 29 model = new Scope(model: model, variables: globals);
30 } 30 }
31 var expr = new Parser(path).parse();
32 return new _Binding(expr, model); 31 return new _Binding(expr, model);
33 } else { 32 } else {
34 return null; 33 return null;
35 } 34 }
36 } 35 }
37 36
38 getInstanceModel(Element template, model) { 37 getInstanceModel(Element template, model) {
39 if (model is! Scope) { 38 if (model is! Scope) {
40 var _scope = new Scope(model: model, variables: globals); 39 var _scope = new Scope(model: model, variables: globals);
41 return _scope; 40 return _scope;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 86
88 getValueWorkaround(key) { 87 getValueWorkaround(key) {
89 if (key == _VALUE) return value; 88 if (key == _VALUE) return value;
90 } 89 }
91 90
92 setValueWorkaround(key, v) { 91 setValueWorkaround(key, v) {
93 if (key == _VALUE) value = v; 92 if (key == _VALUE) value = v;
94 } 93 }
95 94
96 } 95 }
OLDNEW
« no previous file with comments | « lib/src/mirrors.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698