{{format('0')}} {{format('341')}} {{format('628')}}

【AST 还原】一、还原数值常量 [ 编程杂谈 ]

大数据男孩 文章 正文

想做一个技术博客,奈何实力不够
分享

明妃

{{nature("2022-08-14 17:23:20")}}更新

实例

// 还原前
var flag = (326190 ^ 326191) > (60716 ^ 60709)

// 还原后
var flag = 1 > 9;

还原

遍历 二项式节点左右都是数字类型,则满足还原要求

是否通用:是

[mark]()

 traverse(ast, {
    BinaryExpression(path) {
        // 判断这样的 326190 ^ 326191 特征
        if (type.isNumericLiteral(path.node.left) && type.isNumericLiteral(path.node.right)) {
            let {confident, value} = path.evaluate() // 使用提供的 api 计算
            confident && path.replaceWith(type.valueToNode(value))
        }
    }
})
评论 0
0
{{userInfo.data?.nickname}}
{{userInfo.data?.email}}
TOP 2
Spark 2.0 单机模式与集群模式 安装

{{nature('2020-01-02 16:47:07')}} {{format('12522')}}人已阅读

TOP 3
Office 2016 Pro Plus 激活

{{nature('2019-12-11 20:43:10')}} {{format('9410')}}人已阅读

TOP 4
Linux上 MySQL 开启远程登陆的两种方法

{{nature('2019-12-26 17:20:52')}} {{format('7405')}}人已阅读

TOP 5
Linux 安装 MySQL 5.7

{{nature('2019-12-26 16:03:55')}} {{format('4880')}}人已阅读

目录

标签云

AST进阶 AST还原

一言

# {{hitokoto.data.from || '来自'}} #
{{hitokoto.data.hitokoto || '内容'}}
作者:{{hitokoto.data.from_who || '作者'}}
自定义UI
配色方案

侧边栏