Lines Matching full:scope
70 * kind of a scope
78 * type of scope
94 export function isGlobalScope(scope: Scope): boolean {
95 return scope.kind === ScopeKind.GLOBAL;
98 export function isFunctionScope(scope: Scope): boolean {
99 return scope.kind === ScopeKind.FUNCTION;
102 export function isClassScope(scope: Scope): boolean {
103 return scope.kind === ScopeKind.CLASS;
106 export function isInterfaceScope(scope: Scope): boolean {
107 return scope.kind === ScopeKind.INTERFACE;
110 export function isEnumScope(scope: Scope): boolean {
111 return scope.kind === ScopeKind.ENUM;
114 export function isObjectLiteralScope(scope: Scope): boolean {
115 return scope.kind === ScopeKind.OBJECT_LITERAL;
119 * get a new scope.
120 * @param name - name of the scope.
121 * @param node - node of a current scope in ast.
122 * @param type - type of the scope.
123 * @param lexicalScope - indicates if the scope is a lexical scope.
124 * @param upper - parent scope of the current scope.
126 export class Scope { class
127 // scope name
129 // kind of a scope, such as global ,function like, block ..
131 // node of a current scope in ast.
133 // parent scope of current scope
134 parent: Scope | undefined;
135 // sub scopes of current scope
136 children: Scope[];
138 // symbols define in current scope
141 // labels in current scope
152 …structor(name: string, node: Node, type: ScopeKind, lexicalScope: boolean = false, upper?: Scope) {
169 * add a sub scope to current scope
173 addChild(child: Scope): void {
178 * add definition symbol into current scope
190 * add label to current scope
232 scope: Scope; property
235 …export function createLabel(node: LabeledStatement, scope: Scope, parent?: Label | undefined): Lab…
236 let labelName: string = '$' + scope.labels.length + '_' + node.label.text;
243 'scope': scope,
246 scope.labels.push(label);
260 * do scope analysis
268 * get root scope of a file
270 getRootScope(): Scope;
273 * find block Scope of a node
276 getScopeOfNode(node: Node): Scope | undefined;
281 let root: Scope;
282 let current: Scope;
283 let scopes: Scope[] = [];
306 function getRootScope(): Scope {
518 current = new Scope(scopeName, node, ScopeKind.OBJECT_LITERAL, false, current);
582 root = new Scope(scopeName, node, ScopeKind.GLOBAL, true);
587 // locals of a node(scope) is symbol that defines in current scope(node).
596 current = new Scope(scopeName, node, ScopeKind.CATCH, false, current);
627 current = new Scope(scopeName, node, ScopeKind.INTERFACE, true, current);
642 * if it is an anonymous scope, generate the scope name with a number,
643 * which is based on the order of its child scopes in the upper scope
646 current = new Scope(scopeName, node, ScopeKind.MODULE, true, current);
716 current = new Scope(scopeName, node, ScopeKind.FUNCTION, true, current);
746 …The `current` scope is the function's scope, the `current.parent` scope is where the function is d…
747 `foo` has already added in the parent scope, we need to add `bar` here too.
772 current = new Scope(scopeName, node, ScopeKind.SWITCH, false, current);
780 …* ES6+ class like scope, The members of a class aren't not allow to rename in rename identifiers t…
792 current = new Scope(scopeName, node, ScopeKind.CLASS, true, current);
813 current = new Scope(scopeName, node, ScopeKind.FOR, false, current);
823 // skip direct block scope in function scope
829 current = new Scope(scopeName, node, ScopeKind.BLOCK, false, current);
838 current = new Scope(scopeName, node, ScopeKind.INTERFACE, true, current);
858 current = new Scope(scopeName, node, ScopeKind.ENUM, true, current);
925 …// labels within the same scope are allowed to be duplicated, so label names need to have numberin…
931 function getScopeOfNode(node: Node): Scope | undefined {
941 for (const scope of scopes) { constant
942 if (scope?.defs.has(sym)) {
943 return scope;