| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 class CGBlock { | 5 class CGBlock { |
| 6 int _blockType; // Code type of this block | 6 int _blockType; // Code type of this block |
| 7 int _indent; // Number of spaces to prefix for each statement | 7 int _indent; // Number of spaces to prefix for each statement |
| 8 bool _inEach; // This block or any currently active blocks is a | 8 bool _inEach; // This block or any currently active blocks is a |
| 9 // #each. If so then any element marked with a | 9 // #each. If so then any element marked with a |
| 10 // var attribute is repeated therefore the var | 10 // var attribute is repeated therefore the var |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 } | 744 } |
| 745 | 745 |
| 746 // TODO(terry): Hack prefixing all names with "${scopeName}." but don't touch | 746 // TODO(terry): Hack prefixing all names with "${scopeName}." but don't touch |
| 747 // quoted strings. | 747 // quoted strings. |
| 748 String _resolveNames(String expr, String prefixPart) { | 748 String _resolveNames(String expr, String prefixPart) { |
| 749 StringBuffer newExpr = new StringBuffer(); | 749 StringBuffer newExpr = new StringBuffer(); |
| 750 Iterable<Match> matches = identRe.allMatches(expr); | 750 Iterable<Match> matches = identRe.allMatches(expr); |
| 751 | 751 |
| 752 int lastIdx = 0; | 752 int lastIdx = 0; |
| 753 for (Match m in matches) { | 753 for (Match m in matches) { |
| 754 if (m.start() > lastIdx) { | 754 if (m.start > lastIdx) { |
| 755 newExpr.add(expr.substring(lastIdx, m.start())); | 755 newExpr.add(expr.substring(lastIdx, m.start)); |
| 756 } | 756 } |
| 757 | 757 |
| 758 bool identifier = true; | 758 bool identifier = true; |
| 759 if (m.start() > 0) { | 759 if (m.start > 0) { |
| 760 int charCode = expr.charCodeAt(m.start() - 1); | 760 int charCode = expr.charCodeAt(m.start - 1); |
| 761 // Starts with ' or " then it's not an identifier. | 761 // Starts with ' or " then it's not an identifier. |
| 762 identifier = charCode != 34 /* " */ && charCode != 39 /* ' */; | 762 identifier = charCode != 34 /* " */ && charCode != 39 /* ' */; |
| 763 } | 763 } |
| 764 | 764 |
| 765 String strMatch = expr.substring(m.start(), m.end()); | 765 String strMatch = expr.substring(m.start, m.end); |
| 766 if (identifier) { | 766 if (identifier) { |
| 767 newExpr.add("${prefixPart}.${strMatch}"); | 767 newExpr.add("${prefixPart}.${strMatch}"); |
| 768 } else { | 768 } else { |
| 769 // Quoted string don't touch. | 769 // Quoted string don't touch. |
| 770 newExpr.add("${strMatch}"); | 770 newExpr.add("${strMatch}"); |
| 771 } | 771 } |
| 772 lastIdx = m.end(); | 772 lastIdx = m.end; |
| 773 } | 773 } |
| 774 | 774 |
| 775 if (expr.length > lastIdx) { | 775 if (expr.length > lastIdx) { |
| 776 newExpr.add(expr.substring(lastIdx)); | 776 newExpr.add(expr.substring(lastIdx)); |
| 777 } | 777 } |
| 778 | 778 |
| 779 return newExpr.toString(); | 779 return newExpr.toString(); |
| 780 } | 780 } |
| 781 | 781 |
| 782 /** | 782 /** |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1004 for (String name in names) { | 1004 for (String name in names) { |
| 1005 buff.add(" var ${name} = _scopes[\"${name}\"];\n"); | 1005 buff.add(" var ${name} = _scopes[\"${name}\"];\n"); |
| 1006 } | 1006 } |
| 1007 buff.add("\n"); | 1007 buff.add("\n"); |
| 1008 } | 1008 } |
| 1009 | 1009 |
| 1010 return buff.toString(); | 1010 return buff.toString(); |
| 1011 } | 1011 } |
| 1012 | 1012 |
| 1013 } | 1013 } |
| OLD | NEW |