assignment.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:sherlock.py 作者: Luavis 项目源码 文件源码
def generate_aug_assign(self, node, ext_info):
    tmp_name = self.temp_variable.get_new_name()
    tmp_assign_code = '%s=%s' % (
        tmp_name,
        self.dispatch(node.value)
    )
    self.code_buffer.append(tmp_assign_code)
    target = self.dispatch(node.target)
    target_type = self.get_type(node.target)
    if target_type.is_number:
        op = self.generate_numeric_op(node.op, ext_info)
        return '%s=$(( $%s %s $%s ))'% (
            target,
            target,
            op,
            tmp_name
        )
    elif target_type.is_string:
        if isinstance(node.op, ast.Add):
            return '%s=%s$%s'% (
                target,
                target,
                tmp_name
            )
        else:
            raise SyntaxNotSupportError(
                "%s operation is not support yet."
                % node.op.__class__.__name__
            )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号