Package org.rsbot.loader.script.adapter

Source Code of org.rsbot.loader.script.adapter.AddMethodAdapter$Method

package org.rsbot.loader.script.adapter;

import org.rsbot.loader.asm.ClassAdapter;
import org.rsbot.loader.asm.ClassVisitor;
import org.rsbot.loader.asm.MethodVisitor;
import org.rsbot.loader.script.CodeReader;

/**
*/
public class AddMethodAdapter extends ClassAdapter {
  public static class Method {
    public int access;
    public String name;
    public String desc;
    public byte[] code;
    public int max_stack;
    public int max_locals;
  }

  private final Method[] methods;

  public AddMethodAdapter(final ClassVisitor delegate, final Method[] methods) {
    super(delegate);
    this.methods = methods;
  }

  @Override
  public void visitEnd() {
    for (final Method m : methods) {
      final MethodVisitor mv = cv.visitMethod(m.access, m.name, m.desc, null, null);
      mv.visitCode();
      new CodeReader(m.code).accept(mv);
      mv.visitMaxs(m.max_stack, m.max_locals);
      mv.visitEnd();
    }
    cv.visitEnd();
  }
}
TOP

Related Classes of org.rsbot.loader.script.adapter.AddMethodAdapter$Method

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.