Giter Club home page Giter Club logo

Comments (7)

AugustToko avatar AugustToko commented on September 15, 2024

只要设置一下 Procedure 的 parent 然后 将对应的 Procedure 传到 InstanceInvocation 即可完成转换, 具体可以参考我的fork

    // ...

    //目标新建stub函数,方便完成目标->aopstub->目标stub链路
    final Procedure originalStubProcedure = AopUtils.createStubProcedure(
        Name(originalProcedure.name.text + '_' + stubKey, originalProcedure.name.library),
        aopItemInfo,
        originalProcedure,
        body,
        shouldReturn,
    )..parent = originalProcedure.parent;

    // ...

    final mockedInvocation = InstanceInvocation(
        InstanceAccessKind.Instance,
        AsExpression(
          AopUtils.getPointCutClassInstanceGet(pointcutClass, 'target'),
          InterfaceType(originalClass, Nullability.nonNullable),
        ),
        originalStubProcedure.name,
        AopUtils.concatArguments4PointcutStubCall(originalProcedure),
        interfaceTarget: originalStubProcedure,
        functionType: originalStubProcedure.getterType as FunctionType
    );
    
    //...

from aspectd.

AugustToko avatar AugustToko commented on September 15, 2024

只要设置一下 Procedure 的 parent 然后 将对应的 Procedure 传到 InstanceInvocation 即可完成转换, 具体可以参考我的fork

    // ...

    //目标新建stub函数,方便完成目标->aopstub->目标stub链路
    final Procedure originalStubProcedure = AopUtils.createStubProcedure(
        Name(originalProcedure.name.text + '_' + stubKey, originalProcedure.name.library),
        aopItemInfo,
        originalProcedure,
        body,
        shouldReturn,
    )..parent = originalProcedure.parent;

    // ...

    final mockedInvocation = InstanceInvocation(
        InstanceAccessKind.Instance,
        AsExpression(
          AopUtils.getPointCutClassInstanceGet(pointcutClass, 'target'),
          InterfaceType(originalClass, Nullability.nonNullable),
        ),
        originalStubProcedure.name,
        AopUtils.concatArguments4PointcutStubCall(originalProcedure),
        interfaceTarget: originalStubProcedure,
        functionType: originalStubProcedure.getterType as FunctionType
    );
    
    //...

目前已经迁移了 call execute (构造器 hook 没搞,暂时用不到, 实例方法和静态方法简单测了 可以用)

from aspectd.

GvcZhang avatar GvcZhang commented on September 15, 2024

WechatIMG2
感兴趣的同学,加群,以上都在群里。

from aspectd.

littlezhuang avatar littlezhuang commented on September 15, 2024

2.5.4版本在哪里下的?我看flutter最新版本只支持到了2.5.3呀

from aspectd.

littlezhuang avatar littlezhuang commented on September 15, 2024

项目地址https://github.com/lancexin/aspect_frontend_server 现在暂时只支持execute模式

该方法和aspectd的区别

  1. aspectd不支持flutter 2.5.4,本项目是基于flutter 2.5.4测试
  2. aspectd的编译需要对dart sdk中的vm进行修改,本项目不需要
  3. aspectd使用前需要对flutter tools的代码进行修改,本项目只需要替换flutter sdk对应的frontend_server.dart.snapshot即可
  4. aspectd的实现原理过于复杂,本项目去掉了Call,Inject等用法保留了Execute用法的同时对注入逻辑进行了简化
  5. aspectd还需要aspect_impl等,本项目可以直接在主程序代码中添加注入代码,也可以用plugin的方式添加
  6. 本项目不需要引入任何第三方包,用pragma注解完成对应插桩
  7. 可以有限制支持hot reload,完全支持hot restart,免去了冷重启的烦恼
  8. 为了性能优化inject方法限制必须是static的

为什么用pragma注解,而不是自定义注解?

本项目是在aot优化后再对字节码进行修改,aot优化后只有白名单中的注解才能被识别到,pragma是在白名单中的注解.

2.5.4版本在哪里下的呀,我看最新版本只支持到了2.5.3呀

from aspectd.

lancexin avatar lancexin commented on September 15, 2024

项目地址https://github.com/lancexin/aspect_frontend_server 现在暂时只支持execute模式

该方法和aspectd的区别

  1. aspectd不支持flutter 2.5.4,本项目是基于flutter 2.5.4测试
  2. aspectd的编译需要对dart sdk中的vm进行修改,本项目不需要
  3. aspectd使用前需要对flutter tools的代码进行修改,本项目只需要替换flutter sdk对应的frontend_server.dart.snapshot即可
  4. aspectd的实现原理过于复杂,本项目去掉了Call,Inject等用法保留了Execute用法的同时对注入逻辑进行了简化
  5. aspectd还需要aspect_impl等,本项目可以直接在主程序代码中添加注入代码,也可以用plugin的方式添加
  6. 本项目不需要引入任何第三方包,用pragma注解完成对应插桩
  7. 可以有限制支持hot reload,完全支持hot restart,免去了冷重启的烦恼
  8. 为了性能优化inject方法限制必须是static的

为什么用pragma注解,而不是自定义注解?

本项目是在aot优化后再对字节码进行修改,aot优化后只有白名单中的注解才能被识别到,pragma是在白名单中的注解.

2.5.4版本在哪里下的呀,我看最新版本只支持到了2.5.3呀

flutter是 2.5.3

from aspectd.

bladeofgod avatar bladeofgod commented on September 15, 2024

WechatIMG2
感兴趣的同学,加群,以上都在群里。

朋友,二维码 过期了

from aspectd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.