expr.py 文件源码

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

项目:viper 作者: ethereum 项目源码 文件源码
def unary_operations(self):
        operand = Expr.parse_value_expr(self.expr.operand, self.context)
        if isinstance(self.expr.op, ast.Not):
            # Note that in the case of bool, num, address, decimal, num256 AND bytes32,
            # a zero entry represents false, all others represent true
            return LLLnode.from_list(["iszero", operand], typ='bool', pos=getpos(self.expr))
        elif isinstance(self.expr.op, ast.USub):
            if not is_numeric_type(operand.typ):
                raise TypeMismatchException("Unsupported type for negation: %r" % operand.typ, operand)
            return LLLnode.from_list(["sub", 0, operand], typ=operand.typ, pos=getpos(self.expr))
        else:
            raise StructureException("Only the 'not' unary operator is supported")

    # Function calls
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号