stmt.py 文件源码

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

项目:viper 作者: ethereum 项目源码 文件源码
def assign(self):
        from .parser import (
            make_setter,
        )
        # Assignment (eg. x[4] = y)
        if len(self.stmt.targets) != 1:
            raise StructureException("Assignment statement must have one target", self.stmt)
        sub = Expr(self.stmt.value, self.context).lll_node
        if isinstance(self.stmt.targets[0], ast.Name) and self.stmt.targets[0].id not in self.context.vars:
            pos = self.context.new_variable(self.stmt.targets[0].id, set_default_units(sub.typ))
            variable_loc = LLLnode.from_list(pos, typ=sub.typ, location='memory', pos=getpos(self.stmt), annotation=self.stmt.targets[0].id)
            o = make_setter(variable_loc, sub, 'memory', pos=getpos(self.stmt))
        else:
            # Checks to see if assignment is valid
            target = self.get_target(self.stmt.targets[0])
            o = make_setter(target, sub, target.location, pos=getpos(self.stmt))
        o.pos = getpos(self.stmt)
        return o
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号