Moved LexicalEnvironment to types.ts, minor fixes

This commit is contained in:
Ron Buckton
2016-02-09 12:39:46 -08:00
parent 6fa400254d
commit 0f2bbb181f
4 changed files with 28 additions and 23 deletions

View File

@@ -42,6 +42,7 @@ var compilerSources = [
"checker.ts",
"factory.ts",
"visitor.ts",
"transformer.ts",
"sourcemap.ts",
"declarationEmitter.ts",
"emitter.ts",
@@ -64,6 +65,7 @@ var servicesSources = [
"checker.ts",
"factory.ts",
"visitor.ts",
"transformer.ts",
"sourcemap.ts",
"declarationEmitter.ts",
"emitter.ts",

View File

@@ -2,12 +2,14 @@
/* @internal */
namespace ts {
export function getTransformers(compilerOptions: CompilerOptions) {
const transformers: Transformer[] = [];
// TODO(rbuckton): Add transformers
return transformers;
}
/**
* Transforms an array of SourceFiles by passing them through each transformer.
*
* @param resolver The emit resolver provided by the checker.
* @param host The emit host.
* @param sourceFiles An array of source files
* @param transforms An array of Transformers.
*/
export function transformFiles(resolver: EmitResolver, host: EmitHost, sourceFiles: SourceFile[], transformers: Transformer[]) {
const nodeToGeneratedName: Identifier[] = [];
const generatedNameSet: Map<string> = {};
@@ -19,6 +21,8 @@ namespace ts {
let hoistedFunctionDeclarations: FunctionDeclaration[];
let currentSourceFile: SourceFile;
// The transformation context is provided to each transformer as part of transformer
// initialization.
const context: TransformationContext = {
getCompilerOptions: () => host.getCompilerOptions(),
getEmitResolver: () => resolver,
@@ -42,6 +46,7 @@ namespace ts {
/**
* Transforms a source file.
*
* @param sourceFile The source file to transform.
*/
function transformSourceFile(sourceFile: SourceFile) {
@@ -161,9 +166,7 @@ namespace ts {
return generateNameForExportDefault();
case SyntaxKind.ClassExpression:
return generateNameForClassExpression();
case SyntaxKind.ComputedPropertyName:
case SyntaxKind.Parameter:
case SyntaxKind.TaggedTemplateExpression:
default:
return createTempVariable(TempVariableKind.Auto);
}
}

View File

@@ -2790,11 +2790,20 @@ namespace ts {
/* @internal */
export const enum NodeEmitFlags {
EmitHelpers = 1 << 0,
EmitExportStar = 1 << 1,
UMDDefine = 1 << 2,
NoLexicalEnvironment = 1 << 3,
SingleLine = 1 << 4,
EmitHelpers = 1 << 0, // Any emit helpers should be written to this node.
EmitExportStar = 1 << 1, // The export * helper should be written to this node.
UMDDefine = 1 << 2, // This node should be replaced with the UMD define helper.
NoLexicalEnvironment = 1 << 3, // A new LexicalEnvironment should *not* be introduced when emitting this node.
SingleLine = 1 << 4, // The contents of this node should be emit on a single line.
}
/** Additional context provided to `visitEachChild` */
export interface LexicalEnvironment {
/** Starts a new lexical environment. */
startLexicalEnvironment(): void;
/** Ends a lexical environment, returning any declarations. */
endLexicalEnvironment(): Statement[];
}
/* @internal */

View File

@@ -2,15 +2,6 @@
/* @internal */
namespace ts {
/** Additional context provided to `visitEachChild` */
export interface LexicalEnvironment {
/** Starts a new lexical environment. */
startLexicalEnvironment(): void;
/** Ends a lexical environment, returning any declarations. */
endLexicalEnvironment(): Statement[];
}
/**
* Describes an edge of a Node, used when traversing a syntax tree.
*/