@@ -37,7 +37,7 @@ import binaryen from "../lib/binaryen.js";
37
37
import * as assemblyscriptJS from "assemblyscript" ;
38
38
39
39
// Use the TS->JS variant by default
40
- var assemblyscript = assemblyscriptJS ;
40
+ let assemblyscript = assemblyscriptJS ;
41
41
42
42
// Use the AS->Wasm variant as an option (experimental)
43
43
const wasmPos = process . argv . indexOf ( "--wasm" ) ;
@@ -115,7 +115,7 @@ export function configToArguments(options, argv = []) {
115
115
/** Convenience function that parses and compiles source strings directly. */
116
116
export async function compileString ( sources , config = { } ) {
117
117
if ( typeof sources === "string" ) sources = { [ `input${ extension } ` ] : sources } ;
118
- var argv = [
118
+ let argv = [
119
119
"--outFile" , "binary" ,
120
120
"--textFile" , "text" ,
121
121
] ;
@@ -182,11 +182,11 @@ export async function main(argv, options) {
182
182
) ;
183
183
}
184
184
185
- var module = null ;
186
- var binaryenModule = null ;
185
+ let module = null ;
186
+ let binaryenModule = null ;
187
187
188
188
// Prepares the result object
189
- var prepareResult = ( error , result = { } ) => {
189
+ let prepareResult = ( error , result = { } ) => {
190
190
if ( error ) {
191
191
stderr . write ( `${ stderrColors . red ( "FAILURE " ) } ${ error . stack . replace ( / ^ E R R O R : / i, "" ) } ${ EOL } ` ) ;
192
192
}
@@ -213,8 +213,8 @@ export async function main(argv, options) {
213
213
214
214
// Print the help message if requested or no source files are provided
215
215
if ( opts . help || ( ! argv . length && ! configHasEntries ) ) {
216
- var out = opts . help ? stdout : stderr ;
217
- var colors = opts . help ? stdoutColors : stderrColors ;
216
+ let out = opts . help ? stdout : stderr ;
217
+ let colors = opts . help ? stdoutColors : stderrColors ;
218
218
out . write ( [
219
219
colors . white ( "SYNTAX" ) ,
220
220
" " + colors . cyan ( "asc" ) + " [entryFile ...] [options]" ,
@@ -295,7 +295,7 @@ export async function main(argv, options) {
295
295
}
296
296
297
297
// Set up options
298
- var program , runtime ;
298
+ let program , runtime ;
299
299
const compilerOptions = assemblyscript . newOptions ( ) ;
300
300
switch ( opts . runtime ) {
301
301
case "stub" : runtime = 0 ; break ;
@@ -358,7 +358,7 @@ export async function main(argv, options) {
358
358
}
359
359
360
360
// Disable default features if specified
361
- var features ;
361
+ let features ;
362
362
if ( ( features = opts . disable ) != null ) {
363
363
if ( typeof features === "string" ) features = features . split ( "," ) ;
364
364
for ( let i = 0 , k = features . length ; i < k ; ++ i ) {
@@ -381,8 +381,8 @@ export async function main(argv, options) {
381
381
}
382
382
383
383
// Set up optimization levels
384
- var optimizeLevel = 0 ;
385
- var shrinkLevel = 0 ;
384
+ let optimizeLevel = 0 ;
385
+ let shrinkLevel = 0 ;
386
386
if ( opts . optimize ) {
387
387
optimizeLevel = defaultOptimizeLevel ;
388
388
shrinkLevel = defaultShrinkLevel ;
@@ -518,8 +518,8 @@ export async function main(argv, options) {
518
518
519
519
// Gets the file matching the specified source path, imported at the given dependee path
520
520
async function getFile ( internalPath , dependeePath ) {
521
- var sourceText = null ; // text reported back to the compiler
522
- var sourcePath = null ; // path reported back to the compiler
521
+ let sourceText = null ; // text reported back to the compiler
522
+ let sourcePath = null ; // path reported back to the compiler
523
523
524
524
// Try file.ext, file/index.ext, file.d.ext
525
525
if ( ! internalPath . startsWith ( libraryPrefix ) ) {
@@ -602,7 +602,7 @@ export async function main(argv, options) {
602
602
603
603
// Parses the backlog of imported files after including entry files
604
604
async function parseBacklog ( ) {
605
- var backlog ;
605
+ let backlog ;
606
606
while ( ( backlog = getBacklog ( ) ) . length ) {
607
607
let files = [ ] ;
608
608
for ( let internalPath of backlog ) {
@@ -733,7 +733,7 @@ export async function main(argv, options) {
733
733
? assemblyscript . getBinaryenModuleRef ( module )
734
734
: module . ref
735
735
) ;
736
- var numErrors = checkDiagnostics ( program , stderr , opts . disableWarning , options . reportDiagnostic , stderrColors . enabled ) ;
736
+ let numErrors = checkDiagnostics ( program , stderr , opts . disableWarning , options . reportDiagnostic , stderrColors . enabled ) ;
737
737
if ( numErrors ) {
738
738
const err = Error ( `${ numErrors } compile error(s)` ) ;
739
739
err . stack = err . message ; // omit stack
@@ -1132,7 +1132,7 @@ async function getConfig(file, baseDir, readFile) {
1132
1132
/** Checks diagnostics emitted so far for errors. */
1133
1133
export function checkDiagnostics ( program , stderr , disableWarning , reportDiagnostic , useColors ) {
1134
1134
if ( typeof useColors === "undefined" && stderr ) useColors = stderr . isTTY ;
1135
- var numErrors = 0 ;
1135
+ let numErrors = 0 ;
1136
1136
do {
1137
1137
let diagnostic = assemblyscript . nextDiagnostic ( program ) ;
1138
1138
if ( ! diagnostic ) break ;
@@ -1224,13 +1224,13 @@ export class Stats {
1224
1224
}
1225
1225
}
1226
1226
1227
- var allocBuffer = typeof global !== "undefined" && global . Buffer
1227
+ let allocBuffer = typeof global !== "undefined" && global . Buffer
1228
1228
? global . Buffer . allocUnsafe || ( len => new global . Buffer ( len ) )
1229
1229
: len => new Uint8Array ( len ) ;
1230
1230
1231
1231
/** Creates a memory stream that can be used in place of stdout/stderr. */
1232
1232
export function createMemoryStream ( fn ) {
1233
- var stream = [ ] ;
1233
+ let stream = [ ] ;
1234
1234
stream . write = function ( chunk ) {
1235
1235
if ( fn ) fn ( chunk ) ;
1236
1236
if ( typeof chunk === "string" ) {
@@ -1244,9 +1244,9 @@ export function createMemoryStream(fn) {
1244
1244
stream . length = 0 ;
1245
1245
} ;
1246
1246
stream . toBuffer = function ( ) {
1247
- var offset = 0 , i = 0 , k = this . length ;
1247
+ let offset = 0 , i = 0 , k = this . length ;
1248
1248
while ( i < k ) offset += this [ i ++ ] . length ;
1249
- var buffer = allocBuffer ( offset ) ;
1249
+ let buffer = allocBuffer ( offset ) ;
1250
1250
offset = i = 0 ;
1251
1251
while ( i < k ) {
1252
1252
buffer . set ( this [ i ] , offset ) ;
@@ -1256,7 +1256,7 @@ export function createMemoryStream(fn) {
1256
1256
return buffer ;
1257
1257
} ;
1258
1258
stream . toString = function ( ) {
1259
- var buffer = this . toBuffer ( ) ;
1259
+ let buffer = this . toBuffer ( ) ;
1260
1260
return utf8 . read ( buffer , 0 , buffer . length ) ;
1261
1261
} ;
1262
1262
return stream ;
0 commit comments