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 | import { CompileReflector } from '../compile_reflector';
|
---|
9 | import { EmitterVisitorContext } from './abstract_emitter';
|
---|
10 | import { AbstractJsEmitterVisitor } from './abstract_js_emitter';
|
---|
11 | import * as o from './output_ast';
|
---|
12 | /**
|
---|
13 | * A helper class to manage the evaluation of JIT generated code.
|
---|
14 | */
|
---|
15 | export declare class JitEvaluator {
|
---|
16 | /**
|
---|
17 | *
|
---|
18 | * @param sourceUrl The URL of the generated code.
|
---|
19 | * @param statements An array of Angular statement AST nodes to be evaluated.
|
---|
20 | * @param reflector A helper used when converting the statements to executable code.
|
---|
21 | * @param createSourceMaps If true then create a source-map for the generated code and include it
|
---|
22 | * inline as a source-map comment.
|
---|
23 | * @returns A map of all the variables in the generated code.
|
---|
24 | */
|
---|
25 | evaluateStatements(sourceUrl: string, statements: o.Statement[], reflector: CompileReflector, createSourceMaps: boolean): {
|
---|
26 | [key: string]: any;
|
---|
27 | };
|
---|
28 | /**
|
---|
29 | * Evaluate a piece of JIT generated code.
|
---|
30 | * @param sourceUrl The URL of this generated code.
|
---|
31 | * @param ctx A context object that contains an AST of the code to be evaluated.
|
---|
32 | * @param vars A map containing the names and values of variables that the evaluated code might
|
---|
33 | * reference.
|
---|
34 | * @param createSourceMap If true then create a source-map for the generated code and include it
|
---|
35 | * inline as a source-map comment.
|
---|
36 | * @returns The result of evaluating the code.
|
---|
37 | */
|
---|
38 | evaluateCode(sourceUrl: string, ctx: EmitterVisitorContext, vars: {
|
---|
39 | [key: string]: any;
|
---|
40 | }, createSourceMap: boolean): any;
|
---|
41 | /**
|
---|
42 | * Execute a JIT generated function by calling it.
|
---|
43 | *
|
---|
44 | * This method can be overridden in tests to capture the functions that are generated
|
---|
45 | * by this `JitEvaluator` class.
|
---|
46 | *
|
---|
47 | * @param fn A function to execute.
|
---|
48 | * @param args The arguments to pass to the function being executed.
|
---|
49 | * @returns The return value of the executed function.
|
---|
50 | */
|
---|
51 | executeFunction(fn: Function, args: any[]): any;
|
---|
52 | }
|
---|
53 | /**
|
---|
54 | * An Angular AST visitor that converts AST nodes into executable JavaScript code.
|
---|
55 | */
|
---|
56 | export declare class JitEmitterVisitor extends AbstractJsEmitterVisitor {
|
---|
57 | private reflector;
|
---|
58 | private _evalArgNames;
|
---|
59 | private _evalArgValues;
|
---|
60 | private _evalExportedVars;
|
---|
61 | constructor(reflector: CompileReflector);
|
---|
62 | createReturnStmt(ctx: EmitterVisitorContext): void;
|
---|
63 | getArgs(): {
|
---|
64 | [key: string]: any;
|
---|
65 | };
|
---|
66 | visitExternalExpr(ast: o.ExternalExpr, ctx: EmitterVisitorContext): any;
|
---|
67 | visitWrappedNodeExpr(ast: o.WrappedNodeExpr<any>, ctx: EmitterVisitorContext): any;
|
---|
68 | visitDeclareVarStmt(stmt: o.DeclareVarStmt, ctx: EmitterVisitorContext): any;
|
---|
69 | visitDeclareFunctionStmt(stmt: o.DeclareFunctionStmt, ctx: EmitterVisitorContext): any;
|
---|
70 | visitDeclareClassStmt(stmt: o.ClassStmt, ctx: EmitterVisitorContext): any;
|
---|
71 | private _emitReferenceToExternal;
|
---|
72 | }
|
---|