OLD | NEW |
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 // Utilities for building JS ASTs at runtime. Contains a builder class | 5 // Utilities for building JS ASTs at runtime. Contains a builder class |
6 // and a parser that parses part of the language. | 6 // and a parser that parses part of the language. |
7 | 7 |
8 part of js_ast; | 8 part of js_ast; |
9 | 9 |
10 | 10 |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 } | 322 } |
323 | 323 |
324 /// Creates a literal js string from [value]. | 324 /// Creates a literal js string from [value]. |
325 /// | 325 /// |
326 /// Note that this function only puts quotes around [value]. It does not do | 326 /// Note that this function only puts quotes around [value]. It does not do |
327 /// any escaping, so use only when you can guarantee that [value] does not | 327 /// any escaping, so use only when you can guarantee that [value] does not |
328 /// contain newlines or backslashes. For escaping the string use | 328 /// contain newlines or backslashes. For escaping the string use |
329 /// [escapedString]. | 329 /// [escapedString]. |
330 LiteralString string(String value) => new LiteralString('"$value"'); | 330 LiteralString string(String value) => new LiteralString('"$value"'); |
331 | 331 |
332 LiteralString name(String name) => new LiteralString(name); | |
333 | |
334 LiteralNumber number(num value) => new LiteralNumber('$value'); | 332 LiteralNumber number(num value) => new LiteralNumber('$value'); |
335 | 333 |
336 LiteralBool boolean(bool value) => new LiteralBool(value); | 334 LiteralBool boolean(bool value) => new LiteralBool(value); |
337 | 335 |
338 ArrayInitializer numArray(Iterable<int> list) => | 336 ArrayInitializer numArray(Iterable<int> list) => |
339 new ArrayInitializer(list.map(number).toList()); | 337 new ArrayInitializer(list.map(number).toList()); |
340 | 338 |
341 ArrayInitializer stringArray(Iterable<String> list) => | 339 ArrayInitializer stringArray(Iterable<String> list) => |
342 new ArrayInitializer(list.map(string).toList()); | 340 new ArrayInitializer(list.map(string).toList()); |
343 | 341 |
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1343 | 1341 |
1344 Catch parseCatch() { | 1342 Catch parseCatch() { |
1345 expectCategory(LPAREN); | 1343 expectCategory(LPAREN); |
1346 Declaration errorName = parseVariableDeclaration(); | 1344 Declaration errorName = parseVariableDeclaration(); |
1347 expectCategory(RPAREN); | 1345 expectCategory(RPAREN); |
1348 expectCategory(LBRACE); | 1346 expectCategory(LBRACE); |
1349 Block body = parseBlock(); | 1347 Block body = parseBlock(); |
1350 return new Catch(errorName, body); | 1348 return new Catch(errorName, body); |
1351 } | 1349 } |
1352 } | 1350 } |
OLD | NEW |