@@ -40,12 +40,9 @@ exports.compile = function compile(options, paths, source, reloadTraceur) {
4040 moduleName = moduleName || inputPath ;
4141 moduleName = moduleName . replace ( / \. \w * $ / , '' ) ;
4242
43- var localOptions = extend ( options , {
44- moduleName : moduleName
45- } ) ;
4643 var CompilerCls = System . get ( 'transpiler/src/compiler' ) . Compiler ;
4744
48- var compiler = new CompilerCls ( localOptions ) ;
45+ var compiler = new CompilerCls ( options , moduleName ) ;
4946 var result = {
5047 js : compiler . compile ( source , inputPath , outputPath ) ,
5148 sourceMap : null
@@ -56,7 +53,7 @@ exports.compile = function compile(options, paths, source, reloadTraceur) {
5653 result . sourceMap = JSON . parse ( sourceMapString ) ;
5754 }
5855
59- if ( localOptions . outputLanguage === 'es6' && source . indexOf ( '$traceurRuntime' ) === - 1 ) {
56+ if ( options . outputLanguage === 'es6' && source . indexOf ( '$traceurRuntime' ) === - 1 ) {
6057 assert ( result . js . indexOf ( '$traceurRuntime' ) === - 1 ,
6158 'Transpile to ES6 must not add references to $traceurRuntime, '
6259 + inputPath + ' is transpiled to:\n' + result . js ) ;
@@ -94,7 +91,6 @@ function reloadCompiler(reloadTraceur) {
9491 useRttsAssertModuleForConvertingTypesToExpressions ( ) ;
9592 supportSuperCallsInEs6Patch ( ) ;
9693 convertTypesToExpressionsInEs6Patch ( ) ;
97- removeNonStaticFieldDeclarationsInEs6Patch ( ) ;
9894 disableGetterSetterAssertionPatch ( ) ;
9995 patchCommonJSModuleTransformerToSupportExportStar ( ) ;
10096}
@@ -111,9 +107,7 @@ function loadModule(filepath, transpile) {
111107 . replace ( __dirname , 'transpiler' )
112108 . replace ( / \\ / g, '/' )
113109 . replace ( / \. \w * $ / , '' ) ;
114- data = ( new traceur . NodeCompiler (
115- extend ( SELF_COMPILE_OPTIONS , { moduleName : moduleName } )
116- ) ) . compile ( data , filepath , filepath ) ;
110+ data = traceur . compile ( data , SELF_COMPILE_OPTIONS , moduleName ) ;
117111 }
118112
119113 ( 'global' , eval ) ( data ) ;
@@ -157,30 +151,15 @@ function convertTypesToExpressionsInEs6Patch() {
157151 PureES6Transformer . prototype . transform = function ( ) {
158152 if ( ! this . _patched ) {
159153 this . _patched = true ;
154+ var self = this ;
160155 this . treeTransformers_ . splice ( 0 , 0 , function ( tree ) {
161- return new TypeToExpressionTransformer ( new UniqueIdentifierGenerator ( ) , this . reporter_ ) . transformAny ( tree ) ;
156+ return new TypeToExpressionTransformer ( new UniqueIdentifierGenerator ( ) , self . reporter_ , self . options_ ) . transformAny ( tree ) ;
162157 } ) ;
163158 }
164159 return _transform . apply ( this , arguments ) ;
165160 } ;
166161}
167162
168- // TODO(tbosch): Don't write field declarations in classes when we output to ES6.
169- // This just patches the writer and does not support moving initializers to the constructor.
170- // See src/codegeneration/ClassTransformer.js for how to support initializers as well.
171- // see https://github.com/google/traceur-compiler/issues/1708
172- function removeNonStaticFieldDeclarationsInEs6Patch ( ) {
173- var traceurVersion = System . map [ 'traceur' ] ;
174- var ParseTreeWriter = System . get ( traceurVersion + '/src/outputgeneration/ParseTreeWriter' ) . ParseTreeWriter ;
175- var options = System . get ( traceurVersion + "/src/Options.js" ) . options ;
176- var _visitPropertyVariableDeclaration = ParseTreeWriter . prototype . visitPropertyVariableDeclaration ;
177- ParseTreeWriter . prototype . visitPropertyVariableDeclaration = function ( ) {
178- if ( options . outputLanguage !== 'es6' ) {
179- return _visitPropertyVariableDeclaration . apply ( this , arguments ) ;
180- }
181- } ;
182- }
183-
184163// TODO(tbosch): Disable getter/setters for assertions until traceur has a flag
185164// that allows to disable them while keeping assertions and member fields enabled.
186165// see https://github.com/google/traceur-compiler/issues/1625
0 commit comments