zoukankan      html  css  js  c++  java
  • aspectc中this可以获取的东西

    this->kind  操作类型

    this->targetName 被调用函数名称

    this->funcName 调用函数名称

    this->argsCount 参数个数

    this->argType(i) 获取编号为i的参数类型

    this->arg(i) 获取编号为i的参数类型

    this->retType 返回值类型

    example:

    1.foo.c

    char * foo(int a) {
       return "just a test ";
    }
    
    void foo2(int a, double b) {
       foo(3);
    }
    
    void foo3() {
       foo2(5, 2.2);
    }
    
    int main() {
       foo3();
    }

    2.fooac.acc

    before(): call($ $(...)) {
       printf("%s " %s " in function %s 
    ", this->kind, this->targetName, this->funcName);
       
       printf(" "%s"  parameter type : 
    ", this->targetName);
    
       if ( this->argsCount == 0 ) printf("no parameter 
    ");
       else {
             for(int i = 1 ; i <= this->argsCount; i++) {
                      printf("arg[%d] = %s  ", i, this->argType(i));
                      
                      if(strcmp(this->argType(i), "int") == 0) {
                             printf(", value = %d ", *(int *)(this->arg(i)));
                      } else if(strcmp(this->argType(i), "double") == 0) {
                             printf(", value = %.2f ", *(double *)(this->arg(i)));
                      }
                      
                      printf("
    ");
              }
        }
    
        printf("return type = %s 
     
    ", this->retType);
    }

    3.Compile 2 files with the "tacc" 

    >tacc foo.c fooac.acc
    >

    4. Run the executable file:

    >./a.out
    call "foo3" in function main "foo3" parameter type: no parameter return type = void call "foo2" in function foo3 "foo2" parameter type: arg[1] = int , value = 5 arg[2] = double , value = 2.20 return type = void call "foo" in function foo2 "foo" parameter type: arg[1] = int , value = 3 return type = char*


  • 相关阅读:
    Windows Server 2003中不能安装MSN的解决方法
    招新人的一个标准
    SVN源代码服务器 证书通不过时的解决办法
    项目风险控制
    项目与团队管理体会
    季羡林老先生百年为人处世哲学
    李一男2003年在港湾给开发人员培训时的语录
    项目管理中的一些想法
    poj 1236 Network of Schools
    poj 2528 Mayor's posters
  • 原文地址:https://www.cnblogs.com/xiaohuihui123/p/4586263.html
Copyright © 2011-2022 走看看