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AA,IAAI,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAC,UAAU,EAAE,WAAW,EAAE,IAAI,MAAA,EAAC,CAAC,EAAlD,CAAkD,CAAC,CAAC;AAC3E,CAAC","sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport * as ts from 'typescript';\n\nimport {MetadataSymbolicReferenceExpression, MetadataValue} from './schema';\n\nexport class Symbols {\n private _symbols: Map<string, MetadataValue>;\n private references = new Map<string, MetadataSymbolicReferenceExpression>();\n\n constructor(private sourceFile: ts.SourceFile) {}\n\n resolve(name: string, preferReference?: boolean): MetadataValue|undefined {\n return (preferReference && this.references.get(name)) || this.symbols.get(name);\n }\n\n define(name: string, value: MetadataValue) { this.symbols.set(name, value); }\n defineReference(name: string, value: MetadataSymbolicReferenceExpression) {\n this.references.set(name, value);\n }\n\n has(name: string): boolean { return this.symbols.has(name); }\n\n private get symbols(): Map<string, MetadataValue> {\n let result = this._symbols;\n if (!result) {\n result = this._symbols = new Map<string, MetadataValue>();\n populateBuiltins(result);\n this.buildImports();\n }\n return result;\n }\n\n private buildImports(): void {\n const symbols = this._symbols;\n // Collect the imported symbols into this.symbols\n const stripQuotes = (s: string) => s.replace(/^['\"]|['\"]$/g, '');\n const visit = (node: ts.Node) => {\n switch (node.kind) {\n case ts.SyntaxKind.ImportEqualsDeclaration:\n const importEqualsDeclaration = <ts.ImportEqualsDeclaration>node;\n if (importEqualsDeclaration.moduleReference.kind ===\n ts.SyntaxKind.ExternalModuleReference) {\n const externalReference =\n <ts.ExternalModuleReference>importEqualsDeclaration.moduleReference;\n // An `import <identifier> = require(<module-specifier>);\n if (!externalReference.expression.parent) {\n // The `parent` field of a node is set by the TypeScript binder (run as\n // part of the type checker). Setting it here allows us to call `getText()`\n // even if the `SourceFile` was not type checked (which looks for `SourceFile`\n // in the parent chain). This doesn't damage the node as the binder unconditionally\n // sets the parent.\n externalReference.expression.parent = externalReference;\n externalReference.parent = this.sourceFile as any;\n }\n const from = stripQuotes(externalReference.expression.getText());\n symbols.set(importEqualsDeclaration.name.text, {__symbolic: 'reference', module: from});\n } else {\n symbols.set(\n importEqualsDeclaration.name.text,\n {__symbolic: 'error', message: `Unsupported import syntax`});\n }\n break;\n case ts.SyntaxKind.ImportDeclaration:\n const importDecl = <ts.ImportDeclaration>node;\n if (!importDecl.importClause) {\n // An `import <module-specifier>` clause which does not bring symbols into scope.\n break;\n }\n if (!importDecl.moduleSpecifier.parent) {\n // See note above in the `ImportEqualDeclaration` case.\n importDecl.moduleSpecifier.parent = importDecl;\n importDecl.parent = this.sourceFile;\n }\n const from = stripQuotes(importDecl.moduleSpecifier.getText());\n if (importDecl.importClause.name) {\n // An `import <identifier> form <module-specifier>` clause. Record the defualt symbol.\n symbols.set(\n importDecl.importClause.name.text,\n {__symbolic: 'reference', module: from, default: true});\n }\n const bindings = importDecl.importClause.namedBindings;\n if (bindings) {\n switch (bindings.kind) {\n case ts.SyntaxKind.NamedImports:\n // An `import { [<identifier> [, <identifier>] } from <module-specifier>` clause\n for (const binding of (<ts.NamedImports>bindings).elements) {\n symbols.set(binding.name.text, {\n __symbolic: 'reference',\n module: from,\n name: binding.propertyName ? binding.propertyName.text : binding.name.text\n });\n }\n break;\n case ts.SyntaxKind.NamespaceImport:\n // An `input * as <identifier> from <module-specifier>` clause.\n symbols.set(\n (<ts.NamespaceImport>bindings).name.text,\n {__symbolic: 'reference', module: from});\n break;\n }\n }\n break;\n }\n ts.forEachChild(node, visit);\n };\n if (this.sourceFile) {\n ts.forEachChild(this.sourceFile, visit);\n }\n }\n}\n\nfunction populateBuiltins(symbols: Map<string, MetadataValue>) {\n // From lib.core.d.ts (all \"define const\")\n ['Object', 'Function', 'String', 'Number', 'Array', 'Boolean', 'Map', 'NaN', 'Infinity', 'Math',\n 'Date', 'RegExp', 'Error', 'Error', 'EvalError', 'RangeError', 'ReferenceError', 'SyntaxError',\n 'TypeError', 'URIError', 'JSON', 'ArrayBuffer', 'DataView', 'Int8Array', 'Uint8Array',\n 'Uint8ClampedArray', 'Uint16Array', 'Int16Array', 'Int32Array', 'Uint32Array', 'Float32Array',\n 'Float64Array']\n .forEach(name => symbols.set(name, {__symbolic: 'reference', name}));\n}\n"]}
\No newline at end of file