fix(static_reflector): resolve values of functions in the function context

This commit is contained in:
Tobias Bosch
2016-07-25 05:29:20 -07:00
parent 6f4e49ed53
commit d6b65db9a7
2 changed files with 20 additions and 12 deletions

View File

@ -279,16 +279,18 @@ export class StaticReflector implements ReflectorReader {
let callContext: {[name: string]: string}|undefined = undefined;
if (expression['__symbolic'] == 'call') {
let target = expression['expression'];
let functionSymbol: StaticSymbol;
let targetFunction: any;
if (target && target.__symbolic === 'reference') {
callContext = {name: target.name};
targetFunction = resolveReferenceValue(resolveReference(context, target));
functionSymbol = resolveReference(context, target);
targetFunction = resolveReferenceValue(functionSymbol);
}
if (targetFunction && targetFunction['__symbolic'] == 'function') {
if (calling.get(targetFunction)) {
if (calling.get(functionSymbol)) {
throw new Error('Recursion not supported');
}
calling.set(targetFunction, true);
calling.set(functionSymbol, true);
let value = targetFunction['value'];
if (value) {
// Determine the arguments
@ -302,13 +304,13 @@ export class StaticReflector implements ReflectorReader {
let result: any;
try {
scope = functionScope.done();
result = simplify(value);
result = simplifyInContext(functionSymbol, value, depth + 1);
} finally {
scope = oldScope;
}
return result;
}
calling.delete(targetFunction);
calling.delete(functionSymbol);
}
}