1717 assemblyscript = require ( "../src" ) ;
1818}
1919
20+ const SOURCEMAP_ROOT = "assemblyscript:///" ;
21+ const LIBRARY_PREFIX = assemblyscript . LIBRARY_PREFIX ;
22+
2023const conf = require ( "./asc.json" ) ;
2124const opts = { } ;
2225
@@ -126,7 +129,7 @@ libDirs.forEach(libDir => {
126129 var nextText = fs . readFileSync ( path . join ( libDir , file ) , { encoding : "utf8" } ) ;
127130 ++ readCount ;
128131 var time = measure ( ( ) => {
129- parser = assemblyscript . parseFile ( nextText , ".std/" + file , parser , false ) ;
132+ parser = assemblyscript . parseFile ( nextText , LIBRARY_PREFIX + file , parser , false ) ;
130133 } ) ;
131134 parseTime += time ;
132135 notIoTime += time ;
@@ -170,7 +173,7 @@ args._.forEach(filename => {
170173
171174 while ( ( nextFile = parser . nextFile ( ) ) != null ) {
172175 var found = false ;
173- if ( nextFile . startsWith ( ".std/" ) ) {
176+ if ( nextFile . startsWith ( LIBRARY_PREFIX ) ) {
174177 for ( var i = 0 ; i < libDirs . length ; ++ i ) {
175178 readTime += measure ( ( ) => {
176179 try {
@@ -311,15 +314,17 @@ if (runPasses.length)
311314
312315function processSourceMap ( sourceMap , sourceMapURL ) {
313316 var json = JSON . parse ( sourceMap ) ;
314- return SourceMapConsumer . with ( sourceMap , sourceMapURL , consumer => {
317+ json . sources = json . sources . map ( name => SOURCEMAP_ROOT + name ) ;
318+ var libPrefix = SOURCEMAP_ROOT + LIBRARY_PREFIX ;
319+ return SourceMapConsumer . with ( json , sourceMapURL , consumer => {
315320 var generator = SourceMapGenerator . fromSourceMap ( consumer ) ;
316321 json . sources . forEach ( name => {
317322 var text , found = false ;
318- if ( name . startsWith ( ".std/" ) ) {
323+ if ( name . startsWith ( libPrefix ) ) {
319324 for ( var i = 0 , k = libDirs . length ; i < k ; ++ i ) {
320325 readTime += measure ( ( ) => {
321326 try {
322- text = fs . readFileSync ( path . join ( libDirs [ i ] , name . substring ( 4 ) ) , { encoding : "utf8" } ) ;
327+ text = fs . readFileSync ( path . join ( libDirs [ i ] , name . substring ( libPrefix . length ) ) , { encoding : "utf8" } ) ;
323328 found = true ;
324329 } catch ( e ) { }
325330 } ) ;
@@ -328,15 +333,16 @@ function processSourceMap(sourceMap, sourceMapURL) {
328333 } else {
329334 readTime += measure ( ( ) => {
330335 try {
331- text = fs . readFileSync ( name , { encoding : "utf8" } ) ;
336+ text = fs . readFileSync ( name . substring ( SOURCEMAP_ROOT . length ) , { encoding : "utf8" } ) ;
332337 found = true ;
333338 } catch ( e ) { }
334339 } ) ;
335340 ++ readCount ;
336341 }
337- if ( found )
342+ if ( found ) {
338343 generator . setSourceContent ( name , text ) ;
339- else
344+ console . log ( name + " ???" ) ;
345+ } else
340346 console . error ( "No source content found for file '" + name + "'." ) ;
341347 } ) ;
342348 return generator . toString ( ) ;
@@ -362,7 +368,7 @@ if (!args.noEmit) {
362368 : null ;
363369 var binary ;
364370 writeTime += measure ( ( ) => {
365- binary = module . toBinary ( sourceMapURL ) ; // FIXME: 'not a valid URL' in FF
371+ binary = module . toBinary ( "http://127.0.0.1:8080/" + sourceMapURL ) ; // FIXME: 'not a valid URL' in FF
366372 fs . writeFileSync ( args . binaryFile , binary . output ) ;
367373 } ) ;
368374 ++ writeCount ;
0 commit comments