cn.wensiqun.asmsupport.creator
类 MethodCreator

java.lang.Object
  继承者 cn.wensiqun.asmsupport.creator.MethodCreator
所有已实现的接口:
IMemberCreator, IMethodCreator, Executeable

public class MethodCreator
extends Object
implements IMethodCreator

作者:
温斯群(Joe Wen)

方法摘要
 void create(IClassContext context, ProductClass owner)
          创建逻辑实体
 void create(IClassContext context, SemiClass owner)
          创建逻辑实体
 void execute()
          执行
 int getAccess()
           
 String[] getArgNames()
           
 AClass[] getArguments()
           
 Class<?>[] getExceptions()
           
 String getMethodString()
           
 String getName()
           
 AClass getReturnClass()
           
static MethodCreator methodCreatorForAdd(String name, AClass[] arguments, String[] argNames, AClass returnClass, Class<?>[] exceptions, int access, SuperMethodBody mb)
           
static MethodCreator methodCreatorForModify(String name, AClass[] arguments, String[] argNames, AClass returnClass, Class<?>[] exceptions, int access, SuperMethodBody mb)
           
 void prepare()
          执行execute的预先操作 在此方法中如果要对执行队列操作 那么不能对执行队列做删除和添加操作 只能做替操作 除了MethodBody类型的Block是通过直接调用的方式执行Prepare方法之外, 其他Block 均在调用创建该Block的时候触发Prepare方法, 所有创建非MethodBody类型Block都在 jw.asmsupport.block.operator.CreateBlockOperator接口中 对于一般的Block,比如if...else...
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

方法详细信息

methodCreatorForModify

public static MethodCreator methodCreatorForModify(String name,
                                                   AClass[] arguments,
                                                   String[] argNames,
                                                   AClass returnClass,
                                                   Class<?>[] exceptions,
                                                   int access,
                                                   SuperMethodBody mb)

methodCreatorForAdd

public static MethodCreator methodCreatorForAdd(String name,
                                                AClass[] arguments,
                                                String[] argNames,
                                                AClass returnClass,
                                                Class<?>[] exceptions,
                                                int access,
                                                SuperMethodBody mb)

prepare

public void prepare()
从接口 Executeable 复制的描述

执行execute的预先操作 在此方法中如果要对执行队列操作 那么不能对执行队列做删除和添加操作 只能做替操作

除了MethodBody类型的Block是通过直接调用的方式执行Prepare方法之外, 其他Block 均在调用创建该Block的时候触发Prepare方法, 所有创建非MethodBody类型Block都在 jw.asmsupport.block.operator.CreateBlockOperator接口中

对于一般的Block,比如if...else... 比如如下代码:

 public void method(){
     if(...){
        while(....){
           ...
        }
     }else{
        for(...){
           ...
        }
     }
 }
 

通常执行prepare的顺序如下:

 $ 表示调用 CreateBlockOperator.xxx方法
 _\ 表示触发prepare方法
 
    MethodBody
         |
         |$
         |____\ IF Block
         |          |
         |          |$
         |          |____\ While Block
         |                       |
         |                       |
         |/______________________|
         |           
         |$
         |____\ Else Block 
                    |
                    |$
                    |____\ For Block
                                 |
                                 |
   Method Body End /_____________|
   
 

但是对于每个连续的Try...Catch...Finally...块, asmsupport会先将这一连续的 块逐一创建完成,再执行各自的Prepare方法。 如下图所示

 $ 表示调用 createBlockOperator.xxx方法
 _\ 表示出发prepare方法
 
    MethodBody
         |
         |$
         |____\ Try Block 1
         |          | 
         |          |
         |                         |
         |$                        |
         |____\ Catch Block 1      |
         |                         |
         |$                        |
         |____\ Finally Block 1    |
         |                         |
         |                         |
         |_________________________|
         
                                 |
   Method Body End /_____________|
   
 

指定者:
接口 Executeable 中的 prepare

execute

public void execute()
从接口 Executeable 复制的描述
执行

指定者:
接口 Executeable 中的 execute

create

public void create(IClassContext context,
                   SemiClass owner)
从接口 IMemberCreator 复制的描述
创建逻辑实体

指定者:
接口 IMemberCreator 中的 create

create

public void create(IClassContext context,
                   ProductClass owner)
从接口 IMemberCreator 复制的描述
创建逻辑实体

指定者:
接口 IMemberCreator 中的 create

getName

public String getName()
指定者:
接口 IMethodCreator 中的 getName

getArguments

public AClass[] getArguments()
指定者:
接口 IMethodCreator 中的 getArguments

getArgNames

public String[] getArgNames()

getReturnClass

public AClass getReturnClass()

getExceptions

public Class<?>[] getExceptions()

getAccess

public int getAccess()

getMethodString

public String getMethodString()
指定者:
接口 IMethodCreator 中的 getMethodString


Copyright © 2013. All Rights Reserved.