MCPcopy Create free account
hub / github.com/angular/angular / Scope

Class Scope

packages/compiler/src/typecheck/ops/scope.ts:86–1036  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84 * If a `TcbOp` requires the output of another, it can call `resolve()`.
85 */
86export class Scope {
87 /**
88 * A queue of operations which need to be performed to generate the TCB code for this scope.
89 *
90 * This array can contain either a `TcbOp` which has yet to be executed, or a `TcbExpr|null`
91 * representing the memoized result of executing the operation. As operations are executed, their
92 * results are written into the `opQueue`, overwriting the original operation.
93 *
94 * If an operation is in the process of being executed, it is temporarily overwritten here with
95 * `INFER_TYPE_FOR_CIRCULAR_OP_EXPR`. This way, if a cycle is encountered where an operation
96 * depends transitively on its own result, the inner operation will infer the least narrow type
97 * that fits instead. This has the same semantics as TypeScript itself when types are referenced
98 * circularly.
99 */
100 private opQueue: (TcbOp | TcbExpr | null)[] = [];
101
102 /**
103 * A map of `Element`s to the index of their `TcbElementOp` in the `opQueue`
104 */
105 private elementOpMap = new Map<Element, number>();
106
107 /**
108 * A map of `HostElement`s to the index of their `TcbHostElementOp` in the `opQueue`
109 */
110 private hostElementOpMap = new Map<HostElement, number>();
111
112 /**
113 * A map of maps which tracks the index of `TcbDirectiveCtorOp`s in the `opQueue` for each
114 * directive on a `Element` or `Template` node.
115 */
116 private directiveOpMap = new Map<DirectiveOwner, Map<TcbDirectiveMetadata, number>>();
117
118 /**
119 * A map of `Reference`s to the index of their `TcbReferenceOp` in the `opQueue`
120 */
121 private referenceOpMap = new Map<Reference, number>();
122
123 /**
124 * Map of immediately nested <ng-template>s (within this `Scope`) represented by `Template`
125 * nodes to the index of their `TcbTemplateContextOp`s in the `opQueue`.
126 */
127 private templateCtxOpMap = new Map<Template, number>();
128
129 /**
130 * Map of variables declared on the template that created this `Scope` (represented by
131 * `Variable` nodes) to the index of their `TcbVariableOp`s in the `opQueue`, or to
132 * pre-resolved variable identifiers.
133 */
134 private varMap = new Map<Variable, number | TcbExpr>();
135
136 /**
137 * A map of the names of `LetDeclaration`s to the index of their op in the `opQueue`.
138 *
139 * Assumes that there won't be duplicated `@let` declarations within the same scope.
140 */
141 private letDeclOpMap = new Map<string, {opIndex: number; node: LetDeclaration}>();
142
143 /**

Callers 1

execute_runMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected