@@ -10,10 +10,6 @@ function print(x) {
10
10
process . stdout . write ( x + '\n' ) ;
11
11
}
12
12
13
- function printErr ( x ) {
14
- process . stderr . write ( x + '\n' ) ;
15
- }
16
-
17
13
function read ( x ) {
18
14
return fs . readFileSync ( x ) . toString ( ) ;
19
15
}
@@ -33,13 +29,6 @@ function assertAt(condition, node, message = '') {
33
29
}
34
30
}
35
31
36
- function warnOnce ( msg ) {
37
- if ( ! warnOnce . msgs ) warnOnce . msgs = { } ;
38
- if ( msg in warnOnce . msgs ) return ;
39
- warnOnce . msgs [ msg ] = true ;
40
- printErr ( 'warning: ' + msg ) ;
41
- }
42
-
43
32
// Visits and walks
44
33
// (We don't use acorn-walk because it ignores x in 'x = y'.)
45
34
@@ -100,12 +89,6 @@ function emptyOut(node) {
100
89
node . type = 'EmptyStatement' ;
101
90
}
102
91
103
- function nullify ( node ) {
104
- node . type = 'Literal' ;
105
- node . value = null ;
106
- node . raw = 'null' ;
107
- }
108
-
109
92
// This converts the node into something that terser will ignore in a var
110
93
// declaration, that is, it is a way to get rid of initial values.
111
94
function convertToNothingInVarInit ( node ) {
@@ -114,11 +97,6 @@ function convertToNothingInVarInit(node) {
114
97
node . raw = 'undefined' ;
115
98
}
116
99
117
- function convertToNull ( node ) {
118
- node . type = 'Identifier' ;
119
- node . name = 'null' ;
120
- }
121
-
122
100
function convertToNullStatement ( node ) {
123
101
node . type = 'ExpressionStatement' ;
124
102
node . expression = {
@@ -304,13 +282,6 @@ function runJSDCE(ast, aggressive) {
304
282
function iteration ( ) {
305
283
let removed = 0 ;
306
284
const scopes = [ { } ] ; // begin with empty toplevel scope
307
- function DUMP ( ) {
308
- printErr ( 'vvvvvvvvvvvvvv' ) ;
309
- for ( let i = 0 ; i < scopes . length ; i ++ ) {
310
- printErr ( i + ' : ' + JSON . stringify ( scopes [ i ] ) ) ;
311
- }
312
- printErr ( '^^^^^^^^^^^^^^' ) ;
313
- }
314
285
function ensureData ( scope , name ) {
315
286
if ( Object . prototype . hasOwnProperty . call ( scope , name ) ) return scope [ name ] ;
316
287
scope [ name ] = {
@@ -549,7 +520,6 @@ function applyImportAndExportNameChanges(ast) {
549
520
}
550
521
} ) ;
551
522
} else if ( node . type === 'AssignmentExpression' ) {
552
- const target = node . left ;
553
523
const value = node . right ;
554
524
if ( isExportUse ( value ) ) {
555
525
const name = value . property . value ;
@@ -737,7 +707,6 @@ function emitDCEGraph(ast) {
737
707
emptyOut ( node ) ; // ignore this in the second pass; this does not root
738
708
} else if ( node . type === 'AssignmentExpression' ) {
739
709
const target = node . left ;
740
- const value = node . right ;
741
710
// Ignore assignment to the wasmExports object (as happens in
742
711
// applySignatureConversions).
743
712
if ( isExportUse ( target ) ) {
@@ -902,7 +871,7 @@ function emitDCEGraph(ast) {
902
871
info . reaches [ nameToGraphName [ import_ ] ] = 1 ;
903
872
} // otherwise, it's a number, ignore
904
873
}
905
- for ( const [ e , name ] of Object . entries ( exportNameToGraphName ) ) {
874
+ for ( const [ e , _ ] of Object . entries ( exportNameToGraphName ) ) {
906
875
const name = exportNameToGraphName [ e ] ;
907
876
infos [ name ] = {
908
877
name : name ,
@@ -1127,7 +1096,7 @@ function littleEndianHeap(ast) {
1127
1096
// replace the heap access with LE_HEAP_STORE
1128
1097
const name = target . object . name ;
1129
1098
const idx = target . property ;
1130
- switch ( target . object . name ) {
1099
+ switch ( name ) {
1131
1100
case 'HEAP8' :
1132
1101
case 'HEAPU8' : {
1133
1102
// no action required - storing only 1 byte
0 commit comments