NSString* text = @" \
__block int result = 0;\
UIView* view = [[UIView alloc]init];\
void(^blk)(int value) = ^(int value){\
view.tag = value;\
};\
blk(1024);\
return view.tag;";
ASTNode* root = [ASTUtil parseString:text];
[ASTUtil linkContextToRoot:root];
ASTVariable* result = [root execute];
NSAssert([result.value doubleValue] == 1024, nil);
int echo(int value) {
return value;
}
NSString* text = @" \
[OCCfuntionHelper defineCFunction:@\"echo\" types:@\"int, int\"]; \
return echo(1024);";
ASTNode* root = [ASTUtil parseString:text];
[ASTUtil linkContextToRoot:root];
ASTVariable* result = [root execute];
NSAssert([result.value doubleValue] == 1024, nil);
NSString* text = @" \
[OCCfuntionHelper defineCFunction:@\"objc_setAssociatedObject\" types:@\"void,id,void *,id,unsigned int\"];\
[OCCfuntionHelper defineCFunction:@\"objc_getAssociatedObject\" types:@\"id,id,void *\"];\
NSString* key = @\"key\"; \
objc_setAssociatedObject(self, key, @(1024), 1);\
return objc_getAssociatedObject(self, key);";
ASTNode* root = [ASTUtil parseString:text];
[ASTUtil linkContextToRoot:root];
ASTVariable* result = [root execute];
NSAssert([result.value doubleValue] == 1024, nil);
Copyright (c) 2019 dKingbin
Licensed under MIT or later
DynamicOC required features are based on or derives from projects below:
纯粹是技术分享,不要用于上架操作!
1
mrrobot97 2019-07-30 23:51:22 +08:00
你觉得 App Store 会容忍这么干吗
|
2
wobuhuicode 2019-07-31 16:09:44 +08:00
可以列出已经上线了的 APP 吗,想去举报
|