UNPKG

2.72 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8/// <amd-module name="@angular/compiler-cli/src/ngtsc/partial_evaluator/src/interpreter" />
9import ts from 'typescript';
10import { DependencyTracker } from '../../incremental/api';
11import { ReflectionHost } from '../../reflection';
12import { ForeignFunctionResolver } from './interface';
13import { ResolvedValue } from './result';
14/**
15 * Tracks the scope of a function body, which includes `ResolvedValue`s for the parameters of that
16 * body.
17 */
18declare type Scope = Map<ts.ParameterDeclaration, ResolvedValue>;
19interface Context {
20 originatingFile: ts.SourceFile;
21 /**
22 * The module name (if any) which was used to reach the currently resolving symbols.
23 */
24 absoluteModuleName: string | null;
25 /**
26 * A file name representing the context in which the current `absoluteModuleName`, if any, was
27 * resolved.
28 */
29 resolutionContext: string;
30 scope: Scope;
31 foreignFunctionResolver?: ForeignFunctionResolver;
32}
33export declare class StaticInterpreter {
34 private host;
35 private checker;
36 private dependencyTracker;
37 constructor(host: ReflectionHost, checker: ts.TypeChecker, dependencyTracker: DependencyTracker | null);
38 visit(node: ts.Expression, context: Context): ResolvedValue;
39 private visitExpression;
40 private visitArrayLiteralExpression;
41 protected visitObjectLiteralExpression(node: ts.ObjectLiteralExpression, context: Context): ResolvedValue;
42 private visitTemplateExpression;
43 private visitIdentifier;
44 private visitDeclaration;
45 private visitVariableDeclaration;
46 private visitEnumDeclaration;
47 private visitElementAccessExpression;
48 private visitPropertyAccessExpression;
49 private visitSourceFile;
50 private visitAmbiguousDeclaration;
51 private accessHelper;
52 private visitCallExpression;
53 /**
54 * Visit an expression which was extracted from a foreign-function resolver.
55 *
56 * This will process the result and ensure it's correct for FFR-resolved values, including marking
57 * `Reference`s as synthetic.
58 */
59 private visitFfrExpression;
60 private visitFunctionBody;
61 private visitConditionalExpression;
62 private visitPrefixUnaryExpression;
63 private visitBinaryExpression;
64 private visitParenthesizedExpression;
65 private evaluateFunctionArguments;
66 private visitSpreadElement;
67 private visitBindingElement;
68 private stringNameFromPropertyName;
69 private getResolvedEnum;
70 private getReference;
71 private visitType;
72 private visitTupleType;
73}
74export {};