feat(parser): adds basic expressions to the parser.

Mostly copy pasta from angular.dart.

Remove GetterFactory in favor for ClosureMap (which has basically the same
implementation).
This commit is contained in:
Rado Kirov
2014-10-30 23:47:22 -07:00
parent 8c566dcfb5
commit 965fa1a985
11 changed files with 366 additions and 45 deletions

View File

@ -27,6 +27,26 @@ class IMPLEMENTS {
bool isPresent(obj) => obj != null;
bool isBlank(obj) => obj == null;
bool toBool(x) {
if (x is bool) return x;
if (x is num) return x != 0;
return false;
}
autoConvertAdd(a, b) {
if (a != null && b != null) {
if (a is String && b is! String) {
return a + b.toString();
}
if (a is! String && b is String) {
return a.toString() + b;
}
return a + b;
}
if (a != null) return a;
if (b != null) return b;
return 0;
}
String stringify(obj) => obj.toString();

View File

@ -20,6 +20,14 @@ export function isBlank(obj):boolean {
return obj === undefined || obj === null;
}
export function toBool(obj) {
return !!obj;
}
export function autoConvertAdd(a, b) {
return a + b;
}
export function stringify(token):string {
if (typeof token === 'string') {
return token;