// Path: dex-reader-api/src/main/java/com/googlecode/d2j/node/DexFileNode.java
// public class DexFileNode extends DexFileVisitor {
//     public List<DexClassNode> clzs = new ArrayList<>();
//     public int dexVersion = DexConstants.DEX_035;
// 
//     @Override
//     public void visitDexFileVersion(int version) {
//         this.dexVersion = version;
//         super.visitDexFileVersion(version);
//     }
// 
//     @Override
//     public DexClassVisitor visit(int access_flags, String className, String superClass, String[] interfaceNames) {
//         DexClassNode cn = new DexClassNode(access_flags, className, superClass, interfaceNames);
//         clzs.add(cn);
//         return cn;
//     }
// 
//     public void accept(DexClassVisitor dcv) {
//         for (DexClassNode cn : clzs) {
//             cn.accept(dcv);
//         }
//     }
// 
//     public void accept(DexFileVisitor dfv) {
//         for (DexClassNode cn : clzs) {
//             cn.accept(dfv);
//         }
//     }
// }
// 
// Path: dex-reader-api/src/main/java/com/googlecode/d2j/visitors/DexFileVisitor.java
// public class DexFileVisitor {
//     protected DexFileVisitor visitor;
// 
//     public DexFileVisitor() {
//         super();
//     }
// 
//     public DexFileVisitor(DexFileVisitor visitor) {
//         super();
//         this.visitor = visitor;
//     }
// 
//     public void visitDexFileVersion(int version) {
//         if (visitor != null) {
//             visitor.visitDexFileVersion(version);
//         }
//     }
// 
//     public DexClassVisitor visit(int access_flags, String className, String superClass, String[] interfaceNames) {
//         if (visitor == null) {
//             return null;
//         }
//         return visitor.visit(access_flags, className, superClass, interfaceNames);
//     }
// 
//     public void visitEnd() {
//         if (visitor == null) {
//             return;
//         }
//         visitor.visitEnd();
//     }
// 
// }


import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import com.googlecode.d2j.node.DexClassNode;
import com.googlecode.d2j.node.DexFileNode;
import com.googlecode.d2j.smali.antlr4.SmaliLexer;
import com.googlecode.d2j.smali.antlr4.SmaliParser;
import com.googlecode.d2j.visitors.DexFileVisitor;
import org.antlr.v4.runtime.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
/*
 * dex2jar - Tools to work with android .dex and java .class files
 * Copyright (c) 2009-2013 Panxiaobo
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.googlecode.d2j.smali;



public class Smali {
    public static void smaliFile(Path path, DexFileVisitor dcv) throws IOException {
        try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
            ANTLRInputStream is = new ANTLRInputStream(reader);
            is.name = path.toString();
            smali0(dcv, is);
        }
    }

    public static void smaliFile(String name, String buff, DexFileVisitor dcv) throws IOException {
        ANTLRInputStream is = new ANTLRInputStream(buff);
        is.name = name;
        smali0(dcv, is);
    }

    public static void smaliFile(String name, InputStream in, DexFileVisitor dcv) throws IOException {
        try (InputStreamReader reader = new InputStreamReader(in, StandardCharsets.UTF_8)) {
            ANTLRInputStream is = new ANTLRInputStream(reader);
            is.name = name;
            smali0(dcv, is);
        }
    }

    public static DexClassNode smaliFile2Node(String name, InputStream in) throws IOException {
// Path: dex-reader-api/src/main/java/com/googlecode/d2j/node/DexFileNode.java
// public class DexFileNode extends DexFileVisitor {
//     public List<DexClassNode> clzs = new ArrayList<>();
//     public int dexVersion = DexConstants.DEX_035;
// 
//     @Override
//     public void visitDexFileVersion(int version) {
//         this.dexVersion = version;
//         super.visitDexFileVersion(version);
//     }
// 
//     @Override
//     public DexClassVisitor visit(int access_flags, String className, String superClass, String[] interfaceNames) {
//         DexClassNode cn = new DexClassNode(access_flags, className, superClass, interfaceNames);
//         clzs.add(cn);
//         return cn;
//     }
// 
//     public void accept(DexClassVisitor dcv) {
//         for (DexClassNode cn : clzs) {
//             cn.accept(dcv);
//         }
//     }
// 
//     public void accept(DexFileVisitor dfv) {
//         for (DexClassNode cn : clzs) {
//             cn.accept(dfv);
//         }
//     }
// }
// 
// Path: dex-reader-api/src/main/java/com/googlecode/d2j/visitors/DexFileVisitor.java
// public class DexFileVisitor {
//     protected DexFileVisitor visitor;
// 
//     public DexFileVisitor() {
//         super();
//     }
// 
//     public DexFileVisitor(DexFileVisitor visitor) {
//         super();
//         this.visitor = visitor;
//     }
// 
//     public void visitDexFileVersion(int version) {
//         if (visitor != null) {
//             visitor.visitDexFileVersion(version);
//         }
//     }
// 
//     public DexClassVisitor visit(int access_flags, String className, String superClass, String[] interfaceNames) {
//         if (visitor == null) {
//             return null;
//         }
//         return visitor.visit(access_flags, className, superClass, interfaceNames);
//     }
// 
//     public void visitEnd() {
//         if (visitor == null) {
//             return;
//         }
//         visitor.visitEnd();
//     }
// 
// }


// Path: d2j-smali/src/main/java/com/googlecode/d2j/smali/Smali.java
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import com.googlecode.d2j.node.DexClassNode;
import com.googlecode.d2j.node.DexFileNode;
import com.googlecode.d2j.smali.antlr4.SmaliLexer;
import com.googlecode.d2j.smali.antlr4.SmaliParser;
import com.googlecode.d2j.visitors.DexFileVisitor;
import org.antlr.v4.runtime.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;

/*
 * dex2jar - Tools to work with android .dex and java .class files
 * Copyright (c) 2009-2013 Panxiaobo
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.googlecode.d2j.smali;



public class Smali {
    public static void smaliFile(Path path, DexFileVisitor dcv) throws IOException {
        try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
            ANTLRInputStream is = new ANTLRInputStream(reader);
            is.name = path.toString();
            smali0(dcv, is);
        }
    }

    public static void smaliFile(String name, String buff, DexFileVisitor dcv) throws IOException {
        ANTLRInputStream is = new ANTLRInputStream(buff);
        is.name = name;
        smali0(dcv, is);
    }

    public static void smaliFile(String name, InputStream in, DexFileVisitor dcv) throws IOException {
        try (InputStreamReader reader = new InputStreamReader(in, StandardCharsets.UTF_8)) {
            ANTLRInputStream is = new ANTLRInputStream(reader);
            is.name = name;
            smali0(dcv, is);
        }
    }

    public static DexClassNode smaliFile2Node(String name, InputStream in) throws IOException {
        DexFileNode dfn = new DexFileNode();