Running arbitrary code at runtime

前端 未结 2 1450
名媛妹妹
名媛妹妹 2020-12-18 14:59

I know this is an odd question, but I\'m wondering if this is possible. Is there any method by which code (which would be typed by a user) could be run during runtime?

2条回答
  •  一生所求
    2020-12-18 15:17

    I see a few solutions:

    1. Create a language of your own, and parse it in-application
    2. If on mac, you could theoretically, create a function stub from what they enter in, and use GCC shipped with the application to compile the code at runtime into a dylib, and then use dylib functions to run the function you created.

提交回复
热议问题