feat(change_detector): add support for ternary

This commit is contained in:
vsavkin
2014-11-11 17:18:09 -08:00
parent f38b94067a
commit 0e6d52306b
2 changed files with 15 additions and 1 deletions

View File

@ -3,7 +3,7 @@ import {ProtoRecord, Record, PROTO_RECORD_CONST, PROTO_RECORD_PURE_FUNCTION,
import {FIELD, IMPLEMENTS, isBlank, isPresent, int, toBool, autoConvertAdd, BaseException} from 'facade/lang';
import {ListWrapper} from 'facade/collection';
import {AST, AccessMember, ImplicitReceiver, AstVisitor, LiteralPrimitive,
Binary, Formatter, MethodCall, FunctionCall, PrefixNot} from './parser/ast';
Binary, Formatter, MethodCall, FunctionCall, PrefixNot, Conditional} from './parser/ast';
export class ProtoWatchGroup {
@FIELD('headRecord:ProtoRecord')
@ -214,6 +214,14 @@ class ProtoRecordCreator {
this.add(record);
}
visitConditional(ast:Conditional, dest) {
var record = this.construct(PROTO_RECORD_PURE_FUNCTION, _cond, 3, dest);
ast.condition.visit(this, new Destination(record, 0));
ast.trueExp.visit(this, new Destination(record, 1));
ast.falseExp.visit(this, new Destination(record, 2));
this.add(record);
}
createRecordsFromAST(ast:AST, memento){
ast.visit(this, memento);
}
@ -267,4 +275,5 @@ function _operation_less_or_equals_then(left, right) {return left <= right;}
function _operation_greater_or_equals_then(left, right) {return left >= right;}
function _operation_logical_and(left, right) {return left && right;}
function _operation_logical_or(left, right) {return left || right;}
function _cond(cond, trueVal, falseVal) {return cond ? trueVal : falseVal;}