Skip to content

Commit

Permalink
fix: cannot find decoder, proxy functions because of some empty
Browse files Browse the repository at this point in the history
statements
  • Loading branch information
khanhnb authored and relative committed Dec 18, 2023
1 parent 721cf5d commit 5d951b3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/transformers/demangle.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
Program,
BlockStatement,
sp,
Function,
Expand All @@ -17,6 +16,7 @@ import { Transformer, TransformerOptions } from './transformer'
import { walk } from '../util/walk'
import * as Guard from '../util/guard'
import Context from '../context'
import { filterEmptyStatements } from '../util/helpers'

export interface DemangleOptions extends TransformerOptions {}
export default class Demangle extends Transformer<DemangleOptions> {
Expand All @@ -29,6 +29,7 @@ export default class Demangle extends Transformer<DemangleOptions> {
demangleProxies(context: Context) {
function visitor(func: Function) {
if (!Guard.isBlockStatement(func.body)) return
func.body.body = filterEmptyStatements(func.body.body) as Statement[];
if (func.body.body.length !== 2) return
let body = func.body.body

Expand Down
9 changes: 2 additions & 7 deletions src/transformers/stringdecoder.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import {
Program,
BlockStatement,
Node,
sp,
VariableDeclaration,
ExpressionStatement,
ReturnStatement,
CallExpression,
FunctionExpression,
AssignmentExpression,
StringLiteral,
Identifier,
Statement,
Literal,
UnaryExpression,
Expression,
BinaryExpression,
VariableDeclarator,
Expand Down Expand Up @@ -338,7 +332,8 @@ export default class StringDecoder extends Transformer<StringDecoderOptions> {
const block = node.body
const fnId = node.id.name

if (block.body.length > 3 && block.body.length < 1) return
block.body = filterEmptyStatements(block.body) as Statement[];
if (block.body.length > 3 || block.body.length < 1) return
if (!block.body[0]) return
// stringArray declaration
if (
Expand Down

0 comments on commit 5d951b3

Please sign in to comment.